Skip to content

Commit

Permalink
Do not duplicate the space origin subtree in the blueprint tree UI (#…
Browse files Browse the repository at this point in the history
…5371)

### What

Follow-up to:
- #5342

After #5342, it was possible for a data result subtree to be displayed
twice in the blueprint tree UI, for example:

<img width="778" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/13da8014-5abf-4206-bba8-d9d5a33d3919">

<br/>

This is a problem for storing collapsed state (#5362) and is generally a
weird UX.

This PR replaces the origin subtree by a link which, when clicked,
selects the actual origin subtree (which is always displayed above the
projections).


https://github.com/rerun-io/rerun/assets/49431240/6655a187-c786-4d30-8451-e473267e4526


### 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 newly built examples:
[app.rerun.io](https://app.rerun.io/pr/5371/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5371/index.html?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[app.rerun.io](https://app.rerun.io/pr/5371/index.html?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/5371)
- [Docs
preview](https://rerun.io/preview/8f4012dfde1a2d023ed2493bb7009fd342989b53/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/8f4012dfde1a2d023ed2493bb7009fd342989b53/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 committed Mar 2, 2024
1 parent 166721d commit 99b683a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
Binary file added crates/re_ui/data/icons/link.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions crates/re_ui/src/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ pub const ENTITY_EMPTY: Icon = Icon::new(
"entity_empty",
include_bytes!("../data/icons/entity_empty.png"),
);
pub const LINK: Icon = Icon::new("link", include_bytes!("../data/icons/link.png"));
pub const COMPONENT: Icon = Icon::new("component", include_bytes!("../data/icons/component.png"));

pub const STORE: Icon = Icon::new("store", include_bytes!("../data/icons/store.png"));
Expand Down
25 changes: 25 additions & 0 deletions crates/re_viewport/src/viewport_blueprint_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ impl Viewport<'_, '_> {
&DataResultNodeOrPath::from_path_lookup(result_tree, &space_view.space_origin),
space_view,
space_view_visible,
false,
);

// Show 'projections' if there's any items that weren't part of the tree under origin but are directly included.
Expand Down Expand Up @@ -317,6 +318,7 @@ impl Viewport<'_, '_> {
&DataResultNodeOrPath::DataResultNode(projection),
space_view,
space_view_visible,
true,
);
}
}
Expand Down Expand Up @@ -357,10 +359,32 @@ impl Viewport<'_, '_> {
node_or_path: &DataResultNodeOrPath<'_>,
space_view: &SpaceViewBlueprint,
space_view_visible: bool,
projection_mode: bool,
) {
let store = ctx.entity_db.store();

let entity_path = node_or_path.path();

if projection_mode && entity_path == &space_view.space_origin {
if ListItem::new(ctx.re_ui, "$origin")
.subdued(true)
.italics(true)
.with_icon(&re_ui::icons::LINK)
.show(ui)
.on_hover_text(
"This subtree corresponds to the Space View's origin, and is displayed above \
the 'Projections' section. Click to select it.",
)
.clicked()
{
ctx.selection_state().set_selection(Item::InstancePath(
Some(space_view.id),
InstancePath::entity_splat(entity_path.clone()),
));
}
return;
}

let data_result_node = node_or_path.data_result_node();

let item = Item::InstancePath(
Expand Down Expand Up @@ -460,6 +484,7 @@ impl Viewport<'_, '_> {
&DataResultNodeOrPath::DataResultNode(child_node),
space_view,
space_view_visible,
projection_mode,
);
}
},
Expand Down

0 comments on commit 99b683a

Please sign in to comment.