forked from rerun-io/rerun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Expose ui point radii to logging & blueprint, remove old default radi…
…us settings in favor of blueprint default components (rerun-io#6678) ### What * Fixes rerun-io#6540 https://github.com/rerun-io/rerun/assets/1220815/07d736d9-5ba8-4563-8c70-b597e4c33a56 Also cleans up all the way down to re_renderer, removing the special auto size values we used to check for at rendering time. Adds 4 new code snippets: ui vs scene radius for point2d/point3d/line2d/line3d. It can be used with even more components but this should be enough to make it discoverable ### 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/6678?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/6678?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/6678) - [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
Showing
86 changed files
with
1,325 additions
and
358 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
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
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
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
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
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,66 @@ | ||
use egui::NumExt as _; | ||
use re_types::components::Radius; | ||
use re_viewer_context::ViewerContext; | ||
|
||
use crate::response_utils::response_with_changes_of_inner; | ||
|
||
pub fn edit_radius_ui( | ||
_ctx: &ViewerContext<'_>, | ||
ui: &mut egui::Ui, | ||
value: &mut Radius, | ||
) -> egui::Response { | ||
let mut abs_value = value.0.abs(); | ||
let speed = (abs_value * 0.01).at_least(0.001); | ||
|
||
let drag_response = ui.add( | ||
egui::DragValue::new(&mut abs_value) | ||
.range(0.0..=f32::INFINITY) | ||
.speed(speed), | ||
); | ||
|
||
let mut is_scene_units = value.scene_units().is_some(); | ||
let selected_label = label_for_unit(is_scene_units); | ||
|
||
if ui.is_enabled() { | ||
let combobox_response = egui::ComboBox::from_id_source("units") | ||
.selected_text(selected_label) | ||
.show_ui(ui, |ui| { | ||
ui.selectable_value(&mut is_scene_units, true, label_for_unit(true)) | ||
| ui.selectable_value(&mut is_scene_units, false, label_for_unit(false)) | ||
}); | ||
|
||
if combobox_response | ||
.inner | ||
.as_ref() | ||
.map_or(false, |r| r.changed()) | ||
{ | ||
// When we change the type of units,the value is likely going to be _very wrong_. | ||
// Unfortunately, we don't have knowledge of a fallback here, so we use hardcoded "reasonable" values. | ||
if is_scene_units { | ||
abs_value = 0.5; | ||
} else { | ||
abs_value = 2.5; | ||
}; | ||
} | ||
|
||
if is_scene_units { | ||
*value = Radius::new_scene_units(abs_value); | ||
} else { | ||
*value = Radius::new_ui_points(abs_value); | ||
} | ||
|
||
drag_response | response_with_changes_of_inner(combobox_response) | ||
} else { | ||
// Don't show the combo box drop down if this is disabled ui. | ||
// TODO(#6661): This shouldn't happen on disabled ui, but rather when this is simply not editable. | ||
ui.selectable_label(false, selected_label) | ||
} | ||
} | ||
|
||
fn label_for_unit(is_scene_units: bool) -> &'static str { | ||
if is_scene_units { | ||
"scene units" | ||
} else { | ||
"ui points" | ||
} | ||
} |
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
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
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
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
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
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
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
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
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
Oops, something went wrong.