imgui_inspect/default/
mod.rs

1mod default_bool;
2mod default_f32;
3mod default_option;
4mod default_u32;
5mod default_usize;
6mod default_string;
7
8pub use super::*;
9
10/// Options for using the default rendering style for the element. The options here are a superset
11/// of all other options since "default" could be any of the widgets
12///
13/// So, not all elements will necessarily be used/respected. Use the non-default traits for typesafe
14/// changes.
15///
16/// Marking a struct element with something like `#[inspect(min_value = 5.0, max_value = 53.0)]`
17/// will make the widget for that member default to those values.
18#[derive(Debug, Default, Clone)]
19pub struct InspectArgsDefault {
20    /// If true, the struct will have a visual/expandable header added to it. This defaults to true.
21    ///
22    /// To customize this, disable this header programmatically by passing your own
23    /// InspectArgsDefault into `render` or `render_mut`
24    pub header: Option<bool>,
25
26    /// If true, any child elements (i.e. struct members) will be indented. This defaults to true.
27    pub indent_children: Option<bool>,
28
29    /// Minimum value for the widget. The precise meaning of this can vary depending on the widget type
30    pub min_value: Option<f32>,
31
32    /// Maximum value for the widget. The precise meaning of this can vary depending on the widget type
33    pub max_value: Option<f32>,
34
35    /// Minimum value for the widget. The precise meaning of this can vary depending on the widget type
36    pub step: Option<f32>,
37}
38
39/// Renders a value using the default widget
40pub trait InspectRenderDefault<T> {
41    /// Render the element in an immutable way (i.e. static text)
42    ///
43    /// (Hopefully in the future this can be better. See
44    /// https://github.com/ocornut/imgui/issues/211)
45    fn render(
46        data: &[&T],
47        label: &'static str,
48        ui: &imgui::Ui,
49        args: &InspectArgsDefault,
50    );
51
52    /// Render the element in a mutable way. Using this trait, the default widget to use is based
53    /// on the type.
54    fn render_mut(
55        data: &mut [&mut T],
56        label: &'static str,
57        ui: &imgui::Ui,
58        args: &InspectArgsDefault,
59    ) -> bool;
60}