Expand description
This crate expose macros and traits to generate boilerplate code for structs inspection and edition.
Basic usage would be:
use egui_field_editor::{EguiInspect, EguiInspector};
use eframe::egui;
#[derive(EguiInspect, Default)]
struct MyApp {
#[inspect(read_only)]
string: String,
#[inspect(multiline)]
code: String,
#[inspect(range(min = 12.0, max = 53.0))]
unsigned32: u32,
#[inspect(hidden)]
#[allow(dead_code)]
skipped: bool,
#[inspect(tooltip = "A boolean")]
boolean: bool,
raw_string: &'static str,
#[inspect(slider(min = "-43.0", max = 125.0))]
float64: f32,
#[inspect(name = "A proper field name")]
ugly_internal_field_name: u16,
}
impl eframe::App for MyApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::CentralPanel::default().show(ctx, |ui| {
ui.add(EguiInspector::new(self));
});
}
}
fn main() {
let options = eframe::NativeOptions::default();
let _ = eframe::run_native("EGui Inspector Very Simple Example", options,
Box::new(|_cc|
Ok(Box::new(MyApp {
raw_string:"A raw string which is not editable, even is read_only=false",
string: "A read only string".to_string(),
..Default::default()
}))
)
);
}You can add attributes to structures field.
Currently supported attributes are defined in the struct AttributeArgs of egui_field_editor_derive
Here is a list of supported attributes:
-
name(String): Use custom label for the given field instead of the internal field name -
hidden(bool): If true, doesn’t generate code for the given field -
read_only(bool): If true, the field is not editable (and color is grayed) -
slider(min=f32, max=f32): If present, use a slider when inspecting numbers -
range(min=f32, max=f32): Min/Max value for inspecting numbers -
multiline(optional u8): If set, display the text on multiple lines. If affected to a u8, it defines the number of rows to display -
tooltip(String): Tooltip to display when cursor is hover -
color(bool): Display the field has a color (field type needs to implementFrom<Color32Wrapper>/Into<Color32Wrapper>- seeColor32Wrapper) -
custom_fn(String): Use a custom function instead of callingEguiInspect::inspect_with_custom_id -
from_string: (bool): Force edition from string conversion (needs type to implementFromStrandDisplay)Compatible with
multiline.` -
date(DatePickerParams): Parameters to customize the Date Picker widget:-
combo_boxes: (optionalbool) Show combo boxes in date picker popup. (Default: true). -
arrows: (optionalbool) Show arrows in date picker popup. (Default: true). -
calendar: (optionalbool) Show calendar in date picker popup. (Default: true). -
calendar_week: (optionalbool) Show calendar week in date picker popup. (Default: true). -
show_icon: (optionalbool) Show the calendar icon on the button. (Default: true). -
format:StringChange the format shown on the button. (Default:"%Y-%m-%d").See
chrono::format::strftimefor valid formats. -
highlight_weekends: (optionalbool). Highlight weekend days. (Default: true) -
start_end_years: (min =String|i32, max =String|i32):Set the start and end years for the date picker. (Default: today’s year - 100 to today’s year + 10)
This will limit the years you can choose from in the dropdown to the specified range.
For example, if you want to provide the range of years from 2000 to 2035, you can use:
start_end_years(min=2000, max=2035).
-
§Feature Flags
This crate provides optional features to extend functionality with external libraries. You can enable them selectively to reduce compile time and dependency footprint.
-
nalgebra_glm: Enables support for inspecting nalgebra-glm types like Vec3, Vec4, etc.This adds a dependency to nalgebra-glm.
-
datepicker: Enables date picker UI using chrono and egui_extras.This adds a dependency to egui_extras datepicker feature and to chrono.
-
all: A shortcut to activate all features.
§Default Features
No features are activated by default.
default = []Structs§
- Color32
Wrapper - An utility wrapper around
egui::Color32. - Egui
Inspector - A wrapper widget that renders an object implementing
EguiInspectinside aneguiUI.
Traits§
- Egui
Inspect - A trait for rendering custom UI inspectors using
egui.
Functions§
- add_
bool - Adds a boolean checkbox.
- add_
button - Add a egui::Button
- add_
color - Adds a color picker for custom color types convertible to/from
Color32Wrapper. - add_
color32 - Adds a color picker for
egui::Color32. - add_
combobox - Adds a egui::ComboBox to modify the index of chosed in the
choicesarray. - add_
custom_ ui - Adds a custom field with layout and tooltip support.
- add_
date - Adds a date picker for date types.
- add_
dquat - Adds an editor for
DQuatusingegui::DragValuefor each field. - add_
dvec2 - Adds an editor for
DVec2usingegui::DragValuefor each field. - add_
dvec3 - Adds an editor for
DVec3usingegui::DragValuefor each field. - add_
dvec4 - Adds an editor for
DVec4usingegui::DragValuefor each field. - add_
mat2x2 - Adds an editor for
Mat2x2usingegui::DragValuefor each field. - add_
mat2x3 - Adds an editor for
Mat2x3usingegui::DragValuefor each field. - add_
mat2x4 - Adds an editor for
Mat2x4usingegui::DragValuefor each field. - add_
mat3x2 - Adds an editor for
Mat3x2usingegui::DragValuefor each field. - add_
mat3x3 - Adds an editor for
Mat3x3usingegui::DragValuefor each field. - add_
mat3x4 - Adds an editor for
Mat3x4usingegui::DragValuefor each field. - add_
mat4x2 - Adds an editor for
Mat4x2usingegui::DragValuefor each field. - add_
mat4x3 - Adds an editor for
Mat4x3usingegui::DragValuefor each field. - add_
mat4x4 - Adds an editor for
Mat4x4usingegui::DragValuefor each field. - add_
number - Adds a numeric drag field to the UI.
- add_
number_ slider - Adds a numeric slider to the given
eguiUI. - add_
path - Add a path (a singleline string editor) with a button next to it to open a file picker if the feature “filepicker” is active
- add_
quat - Adds an editor for
Quatusingegui::DragValuefor each field. - add_
string_ convertible - Add a single line text field which use string conversions to edit.
- add_
string_ convertible_ multiline - Add a multiline line text field which use string conversions to edit.
- add_
string_ multiline - Adds a multi-line text field with a specified number of visible lines.
- add_
string_ singleline - Adds a single-line text field.
- add_
vec2 - Adds an editor for
Vec2usingegui::DragValuefor each field. - add_
vec3 - Adds an editor for
Vec3usingegui::DragValuefor each field. - add_
vec4 - Adds an editor for
Vec4usingegui::DragValuefor each field. - add_
vec2i8 - Adds an editor for
I8Vec2usingegui::DragValuefor each field. - add_
vec2i16 - Adds an editor for
I16Vec2usingegui::DragValuefor each field. - add_
vec2i32 - Adds an editor for
I32Vec2usingegui::DragValuefor each field. - add_
vec2i64 - Adds an editor for
I64Vec2usingegui::DragValuefor each field. - add_
vec2u8 - Adds an editor for
U8Vec2usingegui::DragValuefor each field. - add_
vec2u16 - Adds an editor for
U16Vec2usingegui::DragValuefor each field. - add_
vec2u32 - Adds an editor for
U32Vec2usingegui::DragValuefor each field. - add_
vec2u64 - Adds an editor for
U64Vec2usingegui::DragValuefor each field. - add_
vec3i8 - Adds an editor for
I8Vec3usingegui::DragValuefor each field. - add_
vec3i16 - Adds an editor for
I16Vec3usingegui::DragValuefor each field. - add_
vec3i32 - Adds an editor for
I32Vec3usingegui::DragValuefor each field. - add_
vec3i64 - Adds an editor for
I64Vec3usingegui::DragValuefor each field. - add_
vec3u8 - Adds an editor for
U8Vec3usingegui::DragValuefor each field. - add_
vec3u16 - Adds an editor for
U16Vec3usingegui::DragValuefor each field. - add_
vec3u32 - Adds an editor for
U32Vec3usingegui::DragValuefor each field. - add_
vec3u64 - Adds an editor for
U64Vec3usingegui::DragValuefor each field. - add_
vec4i8 - Adds an editor for
I8Vec4usingegui::DragValuefor each field. - add_
vec4i16 - Adds an editor for
I16Vec4usingegui::DragValuefor each field. - add_
vec4i32 - Adds an editor for
I32Vec4usingegui::DragValuefor each field. - add_
vec4i64 - Adds an editor for
I64Vec4usingegui::DragValuefor each field. - add_
vec4u8 - Adds an editor for
U8Vec4usingegui::DragValuefor each field. - add_
vec4u16 - Adds an editor for
U16Vec4usingegui::DragValuefor each field. - add_
vec4u32 - Adds an editor for
U32Vec4usingegui::DragValuefor each field. - add_
vec4u64 - Adds an editor for
U64Vec4usingegui::DragValuefor each field. - add_
widget - Adds a labeled widget to the UI with layout and tooltip support.
Derive Macros§
- Egui
Inspect - See also EguiInspect