-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
### What ... and use that to further simplify edit ui using this (that part is a refactor though, the title line is the user facing change here :)) * this addresses a comment on #6465 ### Checklist * [x] I have read and agree to [Contributor Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and the [Code of Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md) * [x] I've included a screenshot or gif (if applicable) * [x] I have tested the web demo (if applicable): * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6470?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/6470?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json) * [x] The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG * [x] If applicable, add a new check to the [release checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)! - [PR Build Summary](https://build.rerun.io/pr/6470) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html) To run all checks from `main`, comment on the PR with `@rerun-bot full-check`.
- Loading branch information
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.