#gui #imgui #macro

macro imgui-ext-derive

Procedural macro for the imgui-ext crate

16 releases

0.3.0 Aug 25, 2019
0.2.1 Jun 3, 2019
0.1.8 Apr 3, 2019
0.1.7 Mar 1, 2019
0.1.6 Feb 9, 2019

#127 in GUI

Download history 22/week @ 2020-05-29 32/week @ 2020-06-05 19/week @ 2020-06-12 2/week @ 2020-06-19 2/week @ 2020-06-26 35/week @ 2020-07-03 19/week @ 2020-07-10 3/week @ 2020-07-17 1/week @ 2020-07-24 1/week @ 2020-07-31 21/week @ 2020-08-07 38/week @ 2020-08-14 26/week @ 2020-08-21 26/week @ 2020-08-28 56/week @ 2020-09-04 8/week @ 2020-09-11

132 downloads per month
Used in imgui-ext

MIT license

79KB
2K SLoC

⚠️ imgui-ext needs a full rewrite. Since it was my first attempt at making a procedural macro, it has grown messy and difficult to maintain due to lack of planning. Until the rewrite happens, use with caution.

You can also check out imgui-inspect-derive, which looks neat!

imgui-ext

Build Status Cargo package docs.rs docs Master docs

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);
    }
})

Examples

# codegen example (see examples/codegen.rs to see the macro expansion)
cargo run --example codegen

# integration with nalgebra types
cargo run --example nalgebra

Limitations

  • #[derive(imgui_ext::Gui)] is only supported for structs with named fields.

License

MIT

Dependencies

~0.5–0.9MB
~22K SLoC