imgui-ext icon indicating copy to clipboard operation
imgui-ext copied to clipboard

Sensible default widgets

Open germangb opened this issue 4 years ago • 0 comments

At the moment, the default widget is a label, which means that if you don't specify a widget type inside an annotation, that particular struct field is rendered as a text label (provided it implements Display), which is not interactive.

The idea is to define the following default widgets for each type:

rust type default widget remarks
i32, u32, f32, [f32; 2], (f32, f32) etc... input
bool checkbox
String, ImString input String might need an extra allocation, which is not desirable

NOTE: Table not definitive

This way you can save a few keystrokes:

#[derive(imgui_ext::Gui)]
struct Example {
    #[imgui(checkbox)]
    a: bool,
    #[imgui(input)]
    b: [f32; 2],
}

// would become equivalent to:

#[derive(imgui_ext::Gui)]
struct Example {
    #[imgui]
    a: bool,
    #[imgui]
    b: [f32; 2],
}

germangb avatar Nov 12 '19 18:11 germangb