Skip to content

Commit

Permalink
Add selection hierarchy breadcrumbs (#8319)
Browse files Browse the repository at this point in the history
### Related

* Part of #4491

### What
This adds "breadcrumbs" to each selection header in the selection panel,
showing the ancestry of the selected thing.
That should make it obvious if the selection belong to the blueprint
tree panel, or the streams panel.


![image](https://github.com/user-attachments/assets/29c0b3de-3578-469f-8866-6d0b1dfa92b2)

![image](https://github.com/user-attachments/assets/17aa9dc0-6d89-413f-ba40-1b4c2c7dd63e)

![image](https://github.com/user-attachments/assets/8af19762-8ec3-48c8-9cd1-ef6d9459a6df)

![image](https://github.com/user-attachments/assets/dc1eaf3c-6aa8-4e4e-822e-c1e755a6f380)


### Future PR
* Make projections appear the same in breadcrumbs as in the blueprint
tree panel
  • Loading branch information
emilk authored Dec 6, 2024
1 parent 2a33e76 commit 003b00c
Show file tree
Hide file tree
Showing 19 changed files with 760 additions and 338 deletions.
22 changes: 11 additions & 11 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1923,7 +1923,7 @@ checksum = "0d6ef0072f8a535281e4876be788938b528e9a1d43900b82c2569af7da799125"
[[package]]
name = "ecolor"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"
dependencies = [
"bytemuck",
"color-hex",
Expand All @@ -1940,7 +1940,7 @@ checksum = "18aade80d5e09429040243ce1143ddc08a92d7a22820ac512610410a4dd5214f"
[[package]]
name = "eframe"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"
dependencies = [
"ahash",
"bytemuck",
Expand Down Expand Up @@ -1979,7 +1979,7 @@ dependencies = [
[[package]]
name = "egui"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"
dependencies = [
"accesskit",
"ahash",
Expand All @@ -1996,7 +1996,7 @@ dependencies = [
[[package]]
name = "egui-wgpu"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"
dependencies = [
"ahash",
"bytemuck",
Expand All @@ -2015,7 +2015,7 @@ dependencies = [
[[package]]
name = "egui-winit"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"
dependencies = [
"accesskit_winit",
"ahash",
Expand Down Expand Up @@ -2057,7 +2057,7 @@ dependencies = [
[[package]]
name = "egui_extras"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"
dependencies = [
"ahash",
"egui",
Expand All @@ -2074,7 +2074,7 @@ dependencies = [
[[package]]
name = "egui_glow"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"
dependencies = [
"ahash",
"bytemuck",
Expand All @@ -2092,7 +2092,7 @@ dependencies = [
[[package]]
name = "egui_kittest"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"
dependencies = [
"dify",
"egui",
Expand Down Expand Up @@ -2161,7 +2161,7 @@ checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0"
[[package]]
name = "emath"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"
dependencies = [
"bytemuck",
"serde",
Expand Down Expand Up @@ -2277,7 +2277,7 @@ dependencies = [
[[package]]
name = "epaint"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"
dependencies = [
"ab_glyph",
"ahash",
Expand All @@ -2296,7 +2296,7 @@ dependencies = [
[[package]]
name = "epaint_default_fonts"
version = "0.29.1"
source = "git+https://github.com/emilk/egui.git?rev=c5ac7d301a90afbaec843ee04fb43d8a0956cc90#c5ac7d301a90afbaec843ee04fb43d8a0956cc90"
source = "git+https://github.com/emilk/egui.git?rev=577ee8d22810752540636febac5660a5119c6550#577ee8d22810752540636febac5660a5119c6550"

[[package]]
name = "equivalent"
Expand Down
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -559,13 +559,13 @@ significant_drop_tightening = "allow" # An update of parking_lot made this trigg
# As a last resport, patch with a commit to our own repository.
# ALWAYS document what PR the commit hash is part of, or when it was merged into the upstream trunk.

ecolor = { git = "https://github.com/emilk/egui.git", rev = "c5ac7d301a90afbaec843ee04fb43d8a0956cc90" } # egui master 2024-12-03
eframe = { git = "https://github.com/emilk/egui.git", rev = "c5ac7d301a90afbaec843ee04fb43d8a0956cc90" } # egui master 2024-12-03
egui = { git = "https://github.com/emilk/egui.git", rev = "c5ac7d301a90afbaec843ee04fb43d8a0956cc90" } # egui master 2024-12-03
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "c5ac7d301a90afbaec843ee04fb43d8a0956cc90" } # egui master 2024-12-03
egui_kittest = { git = "https://github.com/emilk/egui.git", rev = "c5ac7d301a90afbaec843ee04fb43d8a0956cc90" } # egui master 2024-12-03
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "c5ac7d301a90afbaec843ee04fb43d8a0956cc90" } # egui master 2024-12-03
emath = { git = "https://github.com/emilk/egui.git", rev = "c5ac7d301a90afbaec843ee04fb43d8a0956cc90" } # egui master 2024-12-03
ecolor = { git = "https://github.com/emilk/egui.git", rev = "577ee8d22810752540636febac5660a5119c6550" } # egui master 2024-12-04
eframe = { git = "https://github.com/emilk/egui.git", rev = "577ee8d22810752540636febac5660a5119c6550" } # egui master 2024-12-04
egui = { git = "https://github.com/emilk/egui.git", rev = "577ee8d22810752540636febac5660a5119c6550" } # egui master 2024-12-04
egui_extras = { git = "https://github.com/emilk/egui.git", rev = "577ee8d22810752540636febac5660a5119c6550" } # egui master 2024-12-04
egui_kittest = { git = "https://github.com/emilk/egui.git", rev = "577ee8d22810752540636febac5660a5119c6550" } # egui master 2024-12-04
egui-wgpu = { git = "https://github.com/emilk/egui.git", rev = "577ee8d22810752540636febac5660a5119c6550" } # egui master 2024-12-04
emath = { git = "https://github.com/emilk/egui.git", rev = "577ee8d22810752540636febac5660a5119c6550" } # egui master 2024-12-04

# Useful while developing:
# ecolor = { path = "../../egui/crates/ecolor" }
Expand Down
9 changes: 9 additions & 0 deletions crates/store/re_entity_db/src/instance_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,15 @@ impl InstancePath {
instance: self.instance,
}
}

/// Human-readable description of the kind
pub fn kind(&self) -> &'static str {
if self.instance.is_specific() {
"Entity instance"
} else {
"Entity"
}
}
}

impl std::fmt::Display for InstancePath {
Expand Down
31 changes: 1 addition & 30 deletions crates/viewer/re_blueprint_tree/src/blueprint_tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use re_log_types::EntityPath;
use re_types::blueprint::components::Visible;
use re_ui::{drag_and_drop::DropTarget, list_item, ContextExt as _, DesignTokens, UiExt as _};
use re_viewer_context::{
contents_name_style, icon_for_container_kind, CollapseScope, Contents, DataResultTree,
contents_name_style, icon_for_container_kind, CollapseScope, Contents, DataResultNodeOrPath,
SystemCommandSender,
};
use re_viewer_context::{
Expand All @@ -18,35 +18,6 @@ use re_viewer_context::{
use re_viewport_blueprint::ui::show_add_space_view_or_container_modal;
use re_viewport_blueprint::{SpaceViewBlueprint, ViewportBlueprint};

enum DataResultNodeOrPath<'a> {
Path(&'a EntityPath),
DataResultNode(&'a DataResultNode),
}

impl<'a> DataResultNodeOrPath<'a> {
fn from_path_lookup(result_tree: &'a DataResultTree, path: &'a EntityPath) -> Self {
result_tree
.lookup_node_by_path(path)
.map_or(DataResultNodeOrPath::Path(path), |node| {
DataResultNodeOrPath::DataResultNode(node)
})
}

fn path(&self) -> &'a EntityPath {
match self {
DataResultNodeOrPath::Path(path) => path,
DataResultNodeOrPath::DataResultNode(node) => &node.data_result.entity_path,
}
}

fn data_result_node(&self) -> Option<&'a DataResultNode> {
match self {
DataResultNodeOrPath::Path(_) => None,
DataResultNodeOrPath::DataResultNode(node) => Some(node),
}
}
}

/// Holds the state of the blueprint tree UI.
#[derive(Default)]
pub struct BlueprintTree {
Expand Down
49 changes: 31 additions & 18 deletions crates/viewer/re_data_ui/src/item_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,30 +62,43 @@ pub fn entity_path_parts_buttons(
space_view_id: Option<SpaceViewId>,
entity_path: &EntityPath,
) -> egui::Response {
let with_icon = false; // too much noise with icons in a path
let with_individual_icons = false; // too much noise with icons in a path

ui.horizontal(|ui| {
ui.spacing_mut().item_spacing.x = 2.0;
{
ui.spacing_mut().item_spacing.x = 2.0;

// Show one single icon up-front instead:
let instance_path = InstancePath::entity_all(entity_path.clone());
ui.add(instance_path_icon(&query.timeline(), db, &instance_path).as_image());
// The last part points to the selected entity, but that's ugly, so remove the highlight:
let visuals = ui.visuals_mut();
visuals.selection.bg_fill = egui::Color32::TRANSPARENT;
visuals.selection.stroke = visuals.widgets.inactive.fg_stroke;
}

let mut accumulated = Vec::new();
for part in entity_path.iter() {
accumulated.push(part.clone());
if !with_individual_icons {
// Show one single icon up-front instead:
let instance_path = InstancePath::entity_all(entity_path.clone());
ui.add(instance_path_icon(&query.timeline(), db, &instance_path).as_image());
}

if entity_path.is_root() {
ui.strong("/");
instance_path_button_to_ex(
ctx,
query,
db,
ui,
space_view_id,
&InstancePath::entity_all(accumulated.clone().into()),
part.syntax_highlighted(ui.style()),
with_icon,
);
} else {
let mut accumulated = Vec::new();
for part in entity_path.iter() {
accumulated.push(part.clone());

ui.strong("/");
instance_path_button_to_ex(
ctx,
query,
db,
ui,
space_view_id,
&InstancePath::entity_all(accumulated.clone().into()),
part.syntax_highlighted(ui.style()),
with_individual_icons,
);
}
}
})
.response
Expand Down
Loading

0 comments on commit 003b00c

Please sign in to comment.