[−][src]Crate imgui_ext
A crate to quickly build imgui GUIs using a #[derive]
macro.
Annotations map to a subset of imgui types and methods:
Basic usage
use imgui_ext::prelude::*; #[derive(ImGuiExt)] struct Example { #[imgui(slider(min = 0.0, max = 4.0))] x: f32, #[imgui(input(step = 2))] y: i32, #[imgui(drag(label = "Drag 2D"))] drag_2d: [f32; 2], #[imgui( checkbox(label = "Turbo mode"), display(label = "Is turbo enabled?"), )] turbo: bool, }
Input events
Most annotations can take an optional catch = "..."
parameter which can be used to identify
when a button is pressed, an input has changed, etc.., later on:
use imgui_ext::prelude::*; #[derive(ImGuiExt)] struct Example { #[imgui(checkbox(catch = "check"))] input_check: bool, #[imgui(text(catch = "text"))] text: ImString, } // init imgui (ui)... let events = ui.imgui_ext(&mut example); if events.check { println!("New value: {}", example.input_check); } if events.text { println!("New text value: {:?}", example.text); }
Combining UI and non-UI fields
If a field is not annotated, it will be ignored in the UI.
use imgui_ext::prelude::*; #[derive(ImGuiExt)] struct Example { #[imgui(label = "Some i32")] in_ui: u32, // since this field is not annotated, it is ignored by the UI not_in_ui: Vec<u8>, }
Descriptive errors
UI correctness is checked at compile time.
#[derive(ImGuiExt)] struct Example { #[imgui(slider(min = 0.0))] foo: f32, }
error: Parameter `max` missing.
--> example/src/main.rs:10:13
|
10 | #[imgui(slider(min = 0.0))]
| ^^^^^^
Re-exports
pub use imgui_ext_derive::ImGuiExt; |
Modules
bullet |
|
button |
|
checkbox |
|
display |
|
drag |
|
input |
|
layout | Support for some (basic) layout annotations. |
nested |
|
prelude | |
progress |
|
slider |
|
text |
|
Macros
Events | A macro that expands to the type that contains the UI events. |
Traits
ImGuiExt | Trait implemented by the derive macro. |
UiExt | Extension trait for imgui Ui. |
Functions
imgui_ext | Render imgui UI and collect all the events |