Trait re_context_menu::ContextMenuAction
source · pub(crate) trait ContextMenuAction {
Show 15 methods
// Provided methods
fn supports_selection(&self, ctx: &ContextMenuContext<'_>) -> bool { ... }
fn supports_multi_selection(&self, _ctx: &ContextMenuContext<'_>) -> bool { ... }
fn supports_item(&self, _ctx: &ContextMenuContext<'_>, _item: &Item) -> bool { ... }
fn ui(&self, ctx: &ContextMenuContext<'_>, ui: &mut Ui) -> Response { ... }
fn icon(&self) -> Option<&'static Icon> { ... }
fn label(&self, _ctx: &ContextMenuContext<'_>) -> String { ... }
fn process_selection(&self, ctx: &ContextMenuContext<'_>) { ... }
fn process_app_id(
&self,
_ctx: &ContextMenuContext<'_>,
_app_id: &ApplicationId,
) { ... }
fn process_data_source(
&self,
_ctx: &ContextMenuContext<'_>,
_data_source: &SmartChannelSource,
) { ... }
fn process_store_id(
&self,
_ctx: &ContextMenuContext<'_>,
_store_id: &StoreId,
) { ... }
fn process_container(
&self,
_ctx: &ContextMenuContext<'_>,
_container_id: &ContainerId,
) { ... }
fn process_view(&self, _ctx: &ContextMenuContext<'_>, _view_id: &ViewId) { ... }
fn process_data_result(
&self,
_ctx: &ContextMenuContext<'_>,
_view_id: &ViewId,
_instance_path: &InstancePath,
) { ... }
fn process_instance_path(
&self,
_ctx: &ContextMenuContext<'_>,
_instance_path: &InstancePath,
) { ... }
fn process_component_path(
&self,
_ctx: &ContextMenuContext<'_>,
_component_path: &ComponentPath,
) { ... }
}
Expand description
Context menu actions must implement this trait.
Actions must do three things, corresponding to three core methods:
- Decide if it can operate a given
ItemCollection
(Self::supports_selection
). - If so, draw some UI in the context menu (
Self::ui
). - If clicked, actually process the
ItemCollection
(Self::process_selection
).
For convenience, these core methods have default implementations which delegates to simpler methods (see their respective docstrings). Implementor may either implement the core method for complex cases, or one or more of the helper methods.
Provided Methods§
sourcefn supports_selection(&self, ctx: &ContextMenuContext<'_>) -> bool
fn supports_selection(&self, ctx: &ContextMenuContext<'_>) -> bool
Check if the action is able to operate on the provided selection.
The default implementation delegates to Self::supports_multi_selection
and
Self::supports_item
.
sourcefn supports_multi_selection(&self, _ctx: &ContextMenuContext<'_>) -> bool
fn supports_multi_selection(&self, _ctx: &ContextMenuContext<'_>) -> bool
Returns whether this action supports multi-selections.
sourcefn supports_item(&self, _ctx: &ContextMenuContext<'_>, _item: &Item) -> bool
fn supports_item(&self, _ctx: &ContextMenuContext<'_>, _item: &Item) -> bool
Returns whether this action supports operation on a selection containing this Item
.
sourcefn ui(&self, ctx: &ContextMenuContext<'_>, ui: &mut Ui) -> Response
fn ui(&self, ctx: &ContextMenuContext<'_>, ui: &mut Ui) -> Response
Draw the context menu UI for this action.
The default implementation delegates to Self::label
.
Note: this is run from inside a [egui::Response.context_menu()
] closure and must call
Self::process_selection
when triggered by the user.
fn icon(&self) -> Option<&'static Icon>
sourcefn label(&self, _ctx: &ContextMenuContext<'_>) -> String
fn label(&self, _ctx: &ContextMenuContext<'_>) -> String
Returns the label displayed by Self::ui
’s default implementation.
sourcefn process_selection(&self, ctx: &ContextMenuContext<'_>)
fn process_selection(&self, ctx: &ContextMenuContext<'_>)
Process the provided ItemCollection
.
The default implementation dispatches to Self::process_store_id
and friends.
fn process_app_id(&self, _ctx: &ContextMenuContext<'_>, _app_id: &ApplicationId)
fn process_data_source( &self, _ctx: &ContextMenuContext<'_>, _data_source: &SmartChannelSource, )
sourcefn process_store_id(&self, _ctx: &ContextMenuContext<'_>, _store_id: &StoreId)
fn process_store_id(&self, _ctx: &ContextMenuContext<'_>, _store_id: &StoreId)
Process a single recording.
sourcefn process_container(
&self,
_ctx: &ContextMenuContext<'_>,
_container_id: &ContainerId,
)
fn process_container( &self, _ctx: &ContextMenuContext<'_>, _container_id: &ContainerId, )
Process a single container.
sourcefn process_view(&self, _ctx: &ContextMenuContext<'_>, _view_id: &ViewId)
fn process_view(&self, _ctx: &ContextMenuContext<'_>, _view_id: &ViewId)
Process a single view.
sourcefn process_data_result(
&self,
_ctx: &ContextMenuContext<'_>,
_view_id: &ViewId,
_instance_path: &InstancePath,
)
fn process_data_result( &self, _ctx: &ContextMenuContext<'_>, _view_id: &ViewId, _instance_path: &InstancePath, )
Process a single data result.
sourcefn process_instance_path(
&self,
_ctx: &ContextMenuContext<'_>,
_instance_path: &InstancePath,
)
fn process_instance_path( &self, _ctx: &ContextMenuContext<'_>, _instance_path: &InstancePath, )
Process a single instance.
sourcefn process_component_path(
&self,
_ctx: &ContextMenuContext<'_>,
_component_path: &ComponentPath,
)
fn process_component_path( &self, _ctx: &ContextMenuContext<'_>, _component_path: &ComponentPath, )
Process a single component.