-
Notifications
You must be signed in to change notification settings - Fork 366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Codegen DerefMut
& Deref
for all trivial components
#6470
Changes from 5 commits
98dbd7f
2834631
3b3a669
2580249
251b5fb
bd063f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/// Generic editor for a boolean value. | ||
pub fn edit_bool( | ||
_ctx: &re_viewer_context::ViewerContext<'_>, | ||
ui: &mut egui::Ui, | ||
value: &mut impl std::ops::DerefMut<Target = bool>, | ||
) -> egui::Response { | ||
edit_bool_impl(ui, value) | ||
} | ||
|
||
/// Non monomorphized implementation of [`edit_bool`]. | ||
fn edit_bool_impl(ui: &mut egui::Ui, value: &mut bool) -> egui::Response { | ||
ui.scope(move |ui| { | ||
ui.visuals_mut().widgets.hovered.expansion = 0.0; | ||
ui.visuals_mut().widgets.active.expansion = 0.0; | ||
ui.add(re_ui::toggle_switch(15.0, value)) | ||
}) | ||
.inner | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
use egui::NumExt as _; | ||
|
||
/// Generic editor for a f32 value from zero to infinity. | ||
pub fn edit_f32_zero_to_inf( | ||
_ctx: &re_viewer_context::ViewerContext<'_>, | ||
ui: &mut egui::Ui, | ||
value: &mut impl std::ops::DerefMut<Target = f32>, | ||
) -> egui::Response { | ||
edit_f32_zero_to_inf_impl(ui, value) | ||
} | ||
|
||
/// Non monomorphized implementation of [`edit_f32_zero_to_inf`]. | ||
fn edit_f32_zero_to_inf_impl(ui: &mut egui::Ui, value: &mut f32) -> egui::Response { | ||
let speed = (*value * 0.01).at_least(0.001); | ||
ui.add( | ||
egui::DragValue::new(value) | ||
.clamp_range(0.0..=f32::INFINITY) | ||
.speed(speed), | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
mod bool_toggle; | ||
mod float_drag; | ||
mod singleline_string; | ||
|
||
pub use bool_toggle::edit_bool; | ||
pub use float_drag::edit_f32_zero_to_inf; | ||
pub use singleline_string::edit_singleline_string; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/// Generic singleline string editor. | ||
pub fn edit_singleline_string( | ||
_ctx: &re_viewer_context::ViewerContext<'_>, | ||
ui: &mut egui::Ui, | ||
value: &mut impl std::ops::DerefMut<Target = re_types::datatypes::Utf8>, | ||
) -> egui::Response { | ||
edit_singleline_string_impl(ui, value) | ||
} | ||
|
||
/// Non monomorphized implementation of [`edit_singleline_string`]. | ||
fn edit_singleline_string_impl( | ||
ui: &mut egui::Ui, | ||
value: &mut re_types::datatypes::Utf8, | ||
) -> egui::Response { | ||
let mut edit_name = value.to_string(); | ||
let response = egui::TextEdit::singleline(&mut edit_name).show(ui).response; | ||
*value = edit_name.into(); | ||
response | ||
} |
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We really need to do that everywhere... or rather, the compiler should 😒