Expand description
A derive-macro for imgui.
§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 can be accessed either by field name or by
method:
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 method matches the name of the field on the Example 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.");
}
Modules§
- bullet
bullet(...)
docs.- button
button(...)
docs.- checkbox
checkbox(...)
docs.- color
color(...)
docs.- display
display(...)
docs.- drag
drag(...)
docs.- image
image(...)
docs.- image_
button image_button(...)
docs.- input
input(...)
docs.- misc
- nested
nested(...)
docs (used to build nested UIs).- progress
progress(...)
docs.- slider
slider(...)
docs.- text
text(...)
&text_wrap(...)
docs.- tree
tree(...)
docs.- vars
vars(...)
docs.