-
Notifications
You must be signed in to change notification settings - Fork 373
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
unify enum edit ui and add background kind
- Loading branch information
Showing
4 changed files
with
33 additions
and
37 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use crate::response_utils::response_with_changes_of_inner; | ||
|
||
pub fn edit_enum<Value: PartialEq + std::fmt::Display + Copy>( | ||
ui: &mut egui::Ui, | ||
id_source: &str, | ||
value: &mut Value, | ||
variants: &[Value], | ||
) -> egui::Response { | ||
response_with_changes_of_inner( | ||
egui::ComboBox::from_id_source(id_source) | ||
.selected_text(format!("{value}")) | ||
.show_ui(ui, |ui| { | ||
let mut iter = variants.iter().copied(); | ||
let Some(first) = iter.next() else { | ||
return ui.label("<no variants>"); | ||
}; | ||
|
||
let mut response = ui.selectable_value(value, first, format!("{first}")); | ||
for variant in iter { | ||
response |= ui.selectable_value(value, variant, format!("{variant}")); | ||
} | ||
response | ||
}), | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
mod bool_toggle; | ||
mod enum_combobox; | ||
mod float_drag; | ||
mod singleline_string; | ||
|
||
pub use bool_toggle::edit_bool; | ||
pub use enum_combobox::edit_enum; | ||
pub use float_drag::edit_f32_zero_to_inf; | ||
pub use singleline_string::edit_singleline_string; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters