Skip to content

Commit efca999

Browse files
authored
Do not show the remove button when the origin is empty (#5840)
### What - Closes #5835 <img width="291" alt="image" src="https://github.com/rerun-io/rerun/assets/49431240/6a7a204a-53d8-48ec-8e31-3f08619380ea"> ### 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: [rerun.io/viewer](https://rerun.io/viewer/pr/5840) * Using examples from latest `main` build: [rerun.io/viewer](https://rerun.io/viewer/pr/5840?manifest_url=https://app.rerun.io/version/main/examples_manifest.json) * Using full set of examples from `nightly` build: [rerun.io/viewer](https://rerun.io/viewer/pr/5840?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/5840) - [Recent benchmark results](https://build.rerun.io/graphs/crates.html) - [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)
1 parent 793c822 commit efca999

File tree

1 file changed

+24
-29
lines changed

1 file changed

+24
-29
lines changed

crates/re_viewport/src/viewport_blueprint_ui.rs

+24-29
Original file line numberDiff line numberDiff line change
@@ -573,53 +573,48 @@ impl Viewport<'_, '_> {
573573

574574
let subdued = !space_view_visible || !visible;
575575

576-
let list_item = ListItem::new(ctx.re_ui, item_label)
576+
let mut list_item = ListItem::new(ctx.re_ui, item_label)
577577
.selected(is_selected)
578578
.with_icon(guess_instance_path_icon(
579579
ctx,
580580
&InstancePath::from(entity_path.clone()),
581581
))
582582
.subdued(subdued)
583-
.force_hovered(is_item_hovered)
584-
.with_buttons(|re_ui: &_, ui: &mut egui::Ui| {
585-
let vis_response = if !empty_origin {
586-
let mut visible_after = visible;
587-
let vis_response =
588-
visibility_button_ui(re_ui, ui, space_view_visible, &mut visible_after);
589-
if visible_after != visible {
590-
if let Some(data_result_node) = data_result_node {
591-
data_result_node
592-
.data_result
593-
.save_recursive_override_or_clear_if_redundant(
594-
ctx,
595-
&query_result.tree,
596-
&Visible(visible_after),
597-
);
598-
}
583+
.force_hovered(is_item_hovered);
584+
585+
// We force the origin to be displayed, even if it's fully empty, in which case it can be
586+
// neither shown/hidden nor removed.
587+
if !empty_origin {
588+
list_item = list_item.with_buttons(|re_ui: &_, ui: &mut egui::Ui| {
589+
let mut visible_after = visible;
590+
let vis_response =
591+
visibility_button_ui(re_ui, ui, space_view_visible, &mut visible_after);
592+
if visible_after != visible {
593+
if let Some(data_result_node) = data_result_node {
594+
data_result_node
595+
.data_result
596+
.save_recursive_override_or_clear_if_redundant(
597+
ctx,
598+
&query_result.tree,
599+
&Visible(visible_after),
600+
);
599601
}
602+
}
600603

601-
Some(vis_response)
602-
} else {
603-
None
604-
};
605-
606-
let mut response = remove_button_ui(
604+
let response = remove_button_ui(
607605
re_ui,
608606
ui,
609-
"Remove group and all its children from the space view",
607+
"Remove this entity and all its children from the space view",
610608
);
611609
if response.clicked() {
612610
space_view
613611
.contents
614612
.remove_subtree_and_matching_rules(ctx, entity_path.clone());
615613
}
616614

617-
if let Some(vis_response) = vis_response {
618-
response |= vis_response;
619-
}
620-
621-
response
615+
response | vis_response
622616
});
617+
}
623618

624619
// If there's any children on the data result nodes, show them, otherwise we're good with this list item as is.
625620
let has_children = data_result_node.map_or(false, |n| !n.children.is_empty());

0 commit comments

Comments
 (0)