-
Notifications
You must be signed in to change notification settings - Fork 366
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
organize component agnostic editors neatly
- Loading branch information
Showing
5 changed files
with
57 additions
and
48 deletions.
There are no files selected for viewing
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,22 @@ | ||
use std::ops::DerefMut; | ||
|
||
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 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), | ||
) | ||
} |
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,22 @@ | ||
use std::ops::DerefMut; | ||
|
||
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 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), | ||
) | ||
} |
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,5 @@ | ||
mod float_drag; | ||
mod singleline_string; | ||
|
||
pub use float_drag::edit_f32_zero_to_inf; | ||
pub use singleline_string::edit_singleline_string; |
File renamed without changes.
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