[][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,
}

]result

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

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.

Traits

Gui

Trait implemented by the derive macro.

UiExt

Extension trait for imgui's Ui.