Skip to content

Commit

Permalink
Default spaceview names are now last space path bit only unless it is…
Browse files Browse the repository at this point in the history
… root (rerun-io#1103)

* Default spaceview names are now last space path bit only unless it is root
* still name space views after single entity if they only have a single entity. remove unnecessary comment
  • Loading branch information
Wumpf authored Feb 6, 2023
1 parent 0c9936e commit 23dfd97
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion crates/re_viewer/src/misc/viewer_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ impl<'a> ViewerContext<'a> {
) -> egui::Response {
self.space_view_button_to(
ui,
space_view.name.clone(),
space_view.display_name.clone(),
space_view.id,
space_view.category,
)
Expand Down
6 changes: 5 additions & 1 deletion crates/re_viewer/src/ui/auto_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,11 @@ pub(crate) fn tree_from_space_views(
.filter(|(space_view_id, _space_view)| visible.contains(space_view_id))
// Sort for determinism:
.sorted_by_key(|(space_view_id, space_view)| {
(&space_view.space_path, &space_view.name, *space_view_id)
(
&space_view.space_path,
&space_view.display_name,
*space_view_id,
)
})
.map(|(space_view_id, space_view)| {
let aspect_ratio = match space_view.category {
Expand Down
4 changes: 2 additions & 2 deletions crates/re_viewer/src/ui/selection_history_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ fn item_to_string(blueprint: &Blueprint, item: &Item) -> String {
match item {
Item::SpaceView(sid) => {
if let Some(space_view) = blueprint.viewport.space_view(sid) {
space_view.name.clone()
space_view.display_name.clone()
} else {
"<removed space view>".to_owned()
}
Expand All @@ -187,7 +187,7 @@ fn item_to_string(blueprint: &Blueprint, item: &Item) -> String {
if let Some(group) = space_view.data_blueprint.group(*handle) {
group.display_name.clone()
} else {
format!("<removed group in {}>", space_view.name)
format!("<removed group in {}>", space_view.display_name)
}
} else {
"<group in removed space view>".to_owned()
Expand Down
6 changes: 3 additions & 3 deletions crates/re_viewer/src/ui/selection_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ pub fn what_is_selected_ui(
if let Some(space_view) = blueprint.viewport.space_view_mut(space_view_id) {
ui.horizontal(|ui| {
ui.label("Space view:");
ui.text_edit_singleline(&mut space_view.name);
ui.text_edit_singleline(&mut space_view.display_name);
});
}
}
Expand Down Expand Up @@ -193,7 +193,7 @@ pub fn what_is_selected_ui(
ui.label("in Space View:");
ctx.space_view_button_to(
ui,
space_view.name.clone(),
space_view.display_name.clone(),
space_view.id,
space_view.category,
);
Expand Down Expand Up @@ -352,7 +352,7 @@ fn list_existing_data_blueprints(
ui,
Some(*space_view_id),
entity_path,
&space_view.name,
&space_view.display_name,
);
}
}
Expand Down
13 changes: 8 additions & 5 deletions crates/re_viewer/src/ui/space_view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ impl SpaceViewId {
#[derive(Clone, serde::Deserialize, serde::Serialize)]
pub struct SpaceView {
pub id: SpaceViewId,
pub name: String,
pub display_name: String,

/// The "anchor point" of this space view.
/// It refers to a [`SpaceInfo`] which forms our reference point for all scene->world transforms in this space view.
Expand All @@ -66,19 +66,22 @@ impl SpaceView {
space_info: &SpaceInfo,
queries_entities: &[EntityPath],
) -> Self {
let name = if queries_entities.len() == 1 {
// a single entity in this space-view - name the space after it
let display_name = if queries_entities.len() == 1 {
// A single entity in this space-view - name the space after it.
queries_entities[0].to_string()
} else if let Some(name) = space_info.path.iter().last() {
name.to_string()
} else {
space_info.path.to_string()
// Include category name in the display for root paths because they look a tad bit too short otherwise.
format!("/ ({category})")
};

let mut data_blueprint_tree = DataBlueprintTree::default();
data_blueprint_tree
.insert_entities_according_to_hierarchy(queries_entities.iter(), &space_info.path);

Self {
name,
display_name,
id: SpaceViewId::random(),
space_path: space_info.path.clone(),
data_blueprint: data_blueprint_tree,
Expand Down
11 changes: 8 additions & 3 deletions crates/re_viewer/src/ui/viewport.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ impl Viewport {
let space_view_ids = self
.space_views
.keys()
.sorted_by_key(|space_view_id| &self.space_views[space_view_id].name)
.sorted_by_key(|space_view_id| &self.space_views[space_view_id].space_path)
.copied()
.collect_vec();

Expand Down Expand Up @@ -626,7 +626,11 @@ impl Viewport {
.selectable_label_with_icon(
ui,
space_view.category.icon(),
space_view.name.clone(),
if space_view.space_path.is_root() {
space_view.display_name.clone()
} else {
space_view.space_path.to_string()
},
false,
)
.clicked()
Expand Down Expand Up @@ -785,7 +789,8 @@ impl<'a, 'b> egui_dock::TabViewer for TabViewer<'a, 'b> {
.get_mut(tab)
.expect("Should have been populated beforehand");

let mut text = egui::WidgetText::RichText(egui::RichText::new(space_view.name.clone()));
let mut text =
egui::WidgetText::RichText(egui::RichText::new(space_view.display_name.clone()));

if self.ctx.selection().contains(&Item::SpaceView(*tab)) {
// Show that it is selected:
Expand Down

0 comments on commit 23dfd97

Please sign in to comment.