Skip to content

Commit

Permalink
Improve the Selection Panel with better title, context, and Space Vie…
Browse files Browse the repository at this point in the history
…w key properties (#4324)

### What

~~Do not merge until after 0.11.~~

This PR reworks the Selection Panel to improve the title ("What is
selected?"), the context ("Where is the selected thing to be found?"),
and the key properties of Space Views (name, origin, type). This is a
first step towards the WIP designs by @martenbjork related to
blueprints.

Changes:
- Full-width, blue title bar consistent with other panel's style and
with the idea that this thing is selected.
- "Context" section listing the place(s) this thing is to be found.
- This is much more consistant across `Item` kinds. Previously, stuff
was displayed all over the place.
- From StreamEntity, it's now it's possible to navigate to any related
SpaceViewEntity _or_ Space Views. Previously, a button confusingly named
after the space view would actually lead to the SpaceViewEntity.
- For Space Views, the Name/Origin/Type are now displayed on top (for
all types of space views).
- This greatly increase the discoverability of the "Name" property.
Previously it was hiding in plain sight in what appeared to be
contextual information.

**Note**: the end-game for context is bread-crumbs like these, but
that's for another day as we're don't yet have an easy way to walk _up_
the hierarchy:

<img width="628" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/8f241bfe-c348-41a6-aa13-dde76475b6c2">

<br/>
<br/>

* Closes #4159
* Closes #4288
* Closes #4160

### Screenshots

Space View:
<img width="380" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/cd6c3e2f-4a34-44b2-b0ff-604274459298">

Group:

<img width="429" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/362ae16b-c821-420d-a1c3-2da514c14ba4">


Entity in Space View:

<img width="380" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/ab609404-f41c-4ffe-8035-7f69ea697c44">

Entity in Streams:

<img width="424" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/97995350-ab55-471d-a6f1-34ab208a6a5b">

Component:

<img width="428" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/0ac3f439-fd32-4c90-99e9-409aea9676c9">



### 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 [demo.rerun.io](https://demo.rerun.io/pr/4324) (if
applicable)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG

- [PR Build Summary](https://build.rerun.io/pr/4324)
- [Docs
preview](https://rerun.io/preview/ed064713de2471df1cac9eeeea2173a4f4fd7c7e/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/ed064713de2471df1cac9eeeea2173a4f4fd7c7e/examples)
<!--EXAMPLES-PREVIEW-->
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
  • Loading branch information
abey79 authored Nov 27, 2023
1 parent 69fdded commit 7789517
Show file tree
Hide file tree
Showing 5 changed files with 218 additions and 129 deletions.
10 changes: 2 additions & 8 deletions crates/re_space_view_spatial/src/space_view_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,9 @@ impl SpaceViewClass for SpatialSpaceView2D {
ui: &mut egui::Ui,
state: &mut Self::State,
space_origin: &EntityPath,
space_view_id: SpaceViewId,
_space_view_id: SpaceViewId,
) {
state.selection_ui(
ctx,
ui,
space_origin,
space_view_id,
SpatialSpaceViewKind::TwoD,
);
state.selection_ui(ctx, ui, space_origin, SpatialSpaceViewKind::TwoD);
}

fn ui(
Expand Down
10 changes: 2 additions & 8 deletions crates/re_space_view_spatial/src/space_view_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,15 +108,9 @@ impl SpaceViewClass for SpatialSpaceView3D {
ui: &mut egui::Ui,
state: &mut Self::State,
space_origin: &EntityPath,
space_view_id: SpaceViewId,
_space_view_id: SpaceViewId,
) {
state.selection_ui(
ctx,
ui,
space_origin,
space_view_id,
SpatialSpaceViewKind::ThreeD,
);
state.selection_ui(ctx, ui, space_origin, SpatialSpaceViewKind::ThreeD);
}

fn ui(
Expand Down
16 changes: 3 additions & 13 deletions crates/re_space_view_spatial/src/ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ use re_types::components::{DepthMeter, InstanceKey, TensorData};
use re_types::tensor_data::TensorDataMeaning;
use re_viewer_context::{
resolve_mono_instance_path, HoverHighlight, HoveredSpace, Item, SelectionHighlight,
SpaceViewHighlights, SpaceViewId, SpaceViewState, SpaceViewSystemExecutionError,
TensorDecodeCache, TensorStatsCache, UiVerbosity, ViewContextCollection, ViewPartCollection,
ViewQuery, ViewerContext,
SpaceViewHighlights, SpaceViewState, SpaceViewSystemExecutionError, TensorDecodeCache,
TensorStatsCache, UiVerbosity, ViewContextCollection, ViewPartCollection, ViewQuery,
ViewerContext,
};

use super::{eye::Eye, ui_2d::View2DState, ui_3d::View3DState};
Expand Down Expand Up @@ -116,7 +116,6 @@ impl SpatialSpaceViewState {
ctx: &mut ViewerContext<'_>,
ui: &mut egui::Ui,
space_origin: &EntityPath,
space_view_id: SpaceViewId,
spatial_kind: SpatialSpaceViewKind,
) {
let re_ui = ctx.re_ui;
Expand All @@ -131,15 +130,6 @@ impl SpatialSpaceViewState {
.show(ui, |ui| {
let auto_size_world = auto_size_world_heuristic(&self.scene_bbox_accum, self.scene_num_primitives);

ctx.re_ui.grid_left_hand_label(ui, "Space origin")
.on_hover_text("The origin is at the origin of this Entity. All transforms are relative to it");
item_ui::entity_path_button(ctx,
ui,
Some(space_view_id),
space_origin,
);
ui.end_row();

ctx.re_ui.grid_left_hand_label(ui, "Default size");
ui.vertical(|ui| {
ui.horizontal(|ui| {
Expand Down
13 changes: 12 additions & 1 deletion crates/re_ui/src/list_item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ pub struct ListItem<'a> {
subdued: bool,
force_hovered: bool,
collapse_openness: Option<f32>,
height: f32,
width_allocation_mode: WidthAllocationMode,
icon_fn:
Option<Box<dyn FnOnce(&ReUi, &mut egui::Ui, egui::Rect, egui::style::WidgetVisuals) + 'a>>,
Expand All @@ -133,6 +134,7 @@ impl<'a> ListItem<'a> {
subdued: false,
force_hovered: false,
collapse_openness: None,
height: ReUi::list_item_height(),
width_allocation_mode: Default::default(),
icon_fn: None,
buttons_fn: None,
Expand Down Expand Up @@ -171,6 +173,15 @@ impl<'a> ListItem<'a> {
self
}

/// Set the item height.
///
/// The default is provided by [`ReUi::list_item_height`] and is suitable for hierarchical
/// lists.
pub fn with_height(mut self, height: f32) -> Self {
self.height = height;
self
}

/// Set the width allocation mode.
pub fn width_allocation_mode(mut self, mode: WidthAllocationMode) -> Self {
self.width_allocation_mode = mode;
Expand Down Expand Up @@ -292,7 +303,7 @@ impl<'a> ListItem<'a> {
}
};

let desired_size = egui::vec2(desired_width, ReUi::list_item_height());
let desired_size = egui::vec2(desired_width, self.height);
let (rect, mut response) = ui.allocate_at_least(desired_size, egui::Sense::click());

// compute the full-span background rect
Expand Down
Loading

0 comments on commit 7789517

Please sign in to comment.