Skip to content

Commit

Permalink
More context menu 3: add support to remove DataResult from a space …
Browse files Browse the repository at this point in the history
…view
  • Loading branch information
abey79 committed Mar 5, 2024
1 parent b279f68 commit 18a252f
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 @@ -167,7 +167,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 @@ -181,6 +181,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 @@ -202,6 +203,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 18a252f

Please sign in to comment.