Skip to content

Improve the Selection Panel with better title, context, and Space View key properties #4324

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

Merged
merged 6 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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