Skip to main content

HostContext

Trait HostContext 

Source
pub trait HostContext {
    // Required methods
    fn add_toolbar_button(
        &mut self,
        button: ToolbarButtonRegistration,
    ) -> PluginResult<()>;
    fn open_plugin_window(
        &mut self,
        plugin_id: &str,
        ui_path: &Path,
        component: &str,
    ) -> PluginResult<()>;

    // Provided methods
    fn add_hud_toolbar_button(
        &mut self,
        _button: HudToolbarButtonRegistration,
    ) -> PluginResult<()> { ... }
    fn show_sidebar(
        &mut self,
        plugin_id: &str,
        _request: SidebarRequest,
    ) -> PluginResult<()> { ... }
    fn hide_sidebar(&mut self, plugin_id: &str) -> PluginResult<()> { ... }
    fn set_undo_redo_state(
        &mut self,
        plugin_id: &str,
        _state: PluginUndoRedoState,
    ) -> PluginResult<()> { ... }
}
Expand description

Trait implemented by the host and passed to plugins during activation.

Plugins call methods on the host context to register toolbar buttons and request windows. The trait is object-safe so it can be used with dyn.

Required Methods§

Source

fn add_toolbar_button( &mut self, button: ToolbarButtonRegistration, ) -> PluginResult<()>

Register a toolbar button. The button is appended after all built-in toolbar items.

Source

fn open_plugin_window( &mut self, plugin_id: &str, ui_path: &Path, component: &str, ) -> PluginResult<()>

Request the host to open a plugin window.

ui_path is an absolute path to the .slint file. component is the exported component name within that file.

Provided Methods§

Source

fn add_hud_toolbar_button( &mut self, _button: HudToolbarButtonRegistration, ) -> PluginResult<()>

Register an icon button in the viewport HUD toolbar.

Source

fn show_sidebar( &mut self, plugin_id: &str, _request: SidebarRequest, ) -> PluginResult<()>

Show a plugin-owned sidebar inside the main application window.

Source

fn hide_sidebar(&mut self, plugin_id: &str) -> PluginResult<()>

Hide the currently active sidebar if it belongs to plugin_id.

Source

fn set_undo_redo_state( &mut self, plugin_id: &str, _state: PluginUndoRedoState, ) -> PluginResult<()>

Update plugin-owned undo/redo visibility and availability state.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§