You can also check out imgui-inspect-derive, which looks neat!
A derive-macro for imgui.
#[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"))]
turbo: bool,
}
let mut example = Example { /* skipped */ };
imgui::Window::new(im_str!("debug")).build(ui, || {
use imgui_ext::UiExt;
if ui.draw_gui(&mut example).turbo() {
println!("Turbo mode value changed: {}", example.turbo);
}
})
# codegen example (see examples/codegen.rs to see the macro expansion)
cargo run --example codegen
# integration with nalgebra types
cargo run --example nalgebra
#[derive(imgui_ext::Gui)]
is only supported forstruct
s with named fields.