[−][src]Crate imgui_ext
Derive macro that allows you to quickly build immediate mode UIs (based on the imgui crate).
Basic usage
#[derive(imgui_ext::Gui)] 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
Rendering a UI with imgui
& imgui-ext
returns a type with all the
triggered input events (which are generally stored as booleans):
use imgui_ext::UiExt; #[derive(imgui_ext::Gui)] struct Example { #[imgui(checkbox(label = "Checkbox"))] check: bool, } let mut example = Example { check: false }; let events = ui.draw_gui(&mut example); if events.check() { println!("checkbox state changed."); }
The checkbox event is mapped to the method check
on the returned type. The
name of the field & method on the returned type matches the name of the
field from the UI type.
You can override this default naming by defining the "catch" attribute on the annotation (all widgets support this attribute, not just checkbox):
use imgui_ext::UiExt; #[derive(imgui_ext::Gui)] struct Example { #[imgui(checkbox(label = "Checkbox", catch = "checkbox_event"))] check: bool, } let mut example = Example { check: false }; let events = ui.draw_gui(&mut example); if events.checkbox_event() { println!("checkbox state changed."); }
Re-exports
pub use imgui_ext_derive::Gui; |
Modules
bullet |
|
button |
|
checkbox |
|
color |
|
display |
|
drag |
|
image |
|
image_button |
|
input |
|
misc | |
nested |
|
progress |
|
slider |
|
text |
|
tree |
|
vars |
|
Traits
Gui | Trait implemented by the derive macro. |
UiExt | Extension trait for imgui's |