[−][src]Crate imgui_ext
A crate to quickly build imgui GUIs using a #[derive]
macro.
Supported annotations
Annotations map to a subset of imgui types and methods:
Basic usage
use imgui_ext::ImGuiExt; // Make your type derive ImGuiExt and place annotations on the fields you want // to include in the ui #[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, // not every field has to be annotated _not_in_ui: Vec<u8> }
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::ImGuiExt; #[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); }
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))]
| ^^^^^^
Contributions
Feedback, suggestions, and contributions, are very much welcome!
Please file an issue or open a PR to germangb/imgui-ext
if you wish to do so.
Re-exports
pub use imgui_ext_derive::ImGuiExt; |
Modules
bullet |
|
button |
|
checkbox |
|
display |
|
drag |
|
image |
|
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 |