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§
Register a toolbar button. The button is appended after all built-in toolbar items.
Sourcefn open_plugin_window(
&mut self,
plugin_id: &str,
ui_path: &Path,
component: &str,
) -> PluginResult<()>
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§
Register an icon button in the viewport HUD toolbar.
Show a plugin-owned sidebar inside the main application window.
Hide the currently active sidebar if it belongs to plugin_id.
Sourcefn set_undo_redo_state(
&mut self,
plugin_id: &str,
_state: PluginUndoRedoState,
) -> PluginResult<()>
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".