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:

  1. Decide if it can operate a given ItemCollection (Self::supports_selection).
  2. If so, draw some UI in the context menu (Self::ui).
  3. 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§

source

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.

source

fn supports_multi_selection(&self, _ctx: &ContextMenuContext<'_>) -> bool

Returns whether this action supports multi-selections.

source

fn supports_item(&self, _ctx: &ContextMenuContext<'_>, _item: &Item) -> bool

Returns whether this action supports operation on a selection containing this Item.

source

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.

source

fn icon(&self) -> Option<&'static Icon>

source

fn label(&self, _ctx: &ContextMenuContext<'_>) -> String

Returns the label displayed by Self::ui’s default implementation.

source

fn process_selection(&self, ctx: &ContextMenuContext<'_>)

Process the provided ItemCollection.

The default implementation dispatches to Self::process_store_id and friends.

source

fn process_app_id(&self, _ctx: &ContextMenuContext<'_>, _app_id: &ApplicationId)

source

fn process_data_source( &self, _ctx: &ContextMenuContext<'_>, _data_source: &SmartChannelSource, )

source

fn process_store_id(&self, _ctx: &ContextMenuContext<'_>, _store_id: &StoreId)

Process a single recording.

source

fn process_container( &self, _ctx: &ContextMenuContext<'_>, _container_id: &ContainerId, )

Process a single container.

source

fn process_view(&self, _ctx: &ContextMenuContext<'_>, _view_id: &ViewId)

Process a single view.

source

fn process_data_result( &self, _ctx: &ContextMenuContext<'_>, _view_id: &ViewId, _instance_path: &InstancePath, )

Process a single data result.

source

fn process_instance_path( &self, _ctx: &ContextMenuContext<'_>, _instance_path: &InstancePath, )

Process a single instance.

source

fn process_component_path( &self, _ctx: &ContextMenuContext<'_>, _component_path: &ComponentPath, )

Process a single component.

Implementors§