Skip to content

Commit

Permalink
More context menu 3: add support for removing DataResult from a spa…
Browse files Browse the repository at this point in the history
…ce view (#5407)

### What

As the title says ☝🏻 

Will easily trigger:
- #5404
- #5406


<img width="321" alt="image"
src="https://github.com/rerun-io/rerun/assets/49431240/e996ade1-2ad7-42a5-8b9a-852149d653a3">


### 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/5407/index.html)
* Using examples from latest `main` build:
[app.rerun.io](https://app.rerun.io/pr/5407/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/5407/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/5407)
- [Docs
preview](https://rerun.io/preview/4a94ddc1c02addd3e7a45a9241dcf57eade1df91/docs)
<!--DOCS-PREVIEW-->
- [Examples
preview](https://rerun.io/preview/4a94ddc1c02addd3e7a45a9241dcf57eade1df91/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 authored Mar 6, 2024
1 parent e77b518 commit 70fc212
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
19 changes: 17 additions & 2 deletions crates/re_viewport/src/context_menu/actions.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use re_entity_db::InstancePath;
use re_log_types::{EntityPath, EntityPathFilter};
use re_log_types::{EntityPath, EntityPathFilter, EntityPathRule};
use re_space_view::{DataQueryBlueprint, SpaceViewBlueprint};
use re_viewer_context::{ContainerId, Item, SpaceViewClassIdentifier, SpaceViewId};

Expand Down Expand Up @@ -168,7 +168,7 @@ fn set_data_result_visible(

// ---

/// Remove a container or space view
/// Remove a container, space view, or data result.
pub(super) struct RemoveAction;

impl ContextMenuAction for RemoveAction {
Expand All @@ -182,6 +182,7 @@ impl ContextMenuAction for RemoveAction {
Item::Container(container_id) => {
ctx.viewport_blueprint.root_container != Some(*container_id)
}
Item::DataResult(_, instance_path) => instance_path.is_splat(),
_ => false,
}
}
Expand All @@ -203,6 +204,20 @@ impl ContextMenuAction for RemoveAction {
ctx.viewport_blueprint
.remove_contents(Contents::SpaceView(*space_view_id));
}

fn process_data_result(
&self,
ctx: &ContextMenuContext<'_>,
space_view_id: &SpaceViewId,
instance_path: &InstancePath,
) {
if let Some(space_view) = ctx.viewport_blueprint.space_view(space_view_id) {
space_view.add_entity_exclusion(
ctx.viewer_context,
EntityPathRule::including_subtree(instance_path.entity_path.clone()),
);
}
}
}

// ---
Expand Down
2 changes: 2 additions & 0 deletions tests/python/release_checklist/check_context_menu.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
- Move to new container
* Right-click on a data result and check for the context menu content:
- Hide (or Show, depending on visibility)
- Remove
* Select a container and, in the Selection Panel, right click on either space view or container children:
- The context menu action should be the same as before.
- The selection state is not affected by the right-click.
Expand Down Expand Up @@ -62,6 +63,7 @@
* Select a mix of containers, space views, and data results, and check for context menu content:
- Hide All (if any are visible)
- Show All (if any are hidden)
- Remove
### Invalid sub-container kind
Expand Down

0 comments on commit 70fc212

Please sign in to comment.