pub trait RootPlugin: Render + Sized {
// Provided methods
fn prepare(&mut self, _window: &mut Window, _cx: &mut Context<'_, Self>) { ... }
fn style(
&self,
_surface: &mut Stateful<Div>,
_window: &mut Window,
_cx: &mut App,
) { ... }
fn decorate(
&self,
surface: AnyElement,
_root: &Root,
_window: &mut Window,
_cx: &mut App,
) -> impl IntoElement { ... }
}Expand description
A presentation layer’s retained, per-window facilities.
Register during explicit application initialization, before creating windows. The view renders above application content. Base owns the root regardless of which plugins are registered; Cargo features never select its type.
On every root render, each plugin participates in three stages:
RootPlugin::preparesynchronizes window state before elements are built.RootPlugin::stylesupplies defaults for the root surface.RootPlugin::decoratewraps the completed surface in presentation owned by the plugin.
The plugin’s Render output is mounted as an overlay above application
content. Plugins and their overlays are processed in registration order, so
later plugins appear above earlier ones. Notify the plugin entity after its
state changes to render the root again; prepare and style must not notify,
because they run during that render.
Factories are captured when a root is created, so registration affects only future windows.
Provided Methods§
Sourcefn prepare(&mut self, _window: &mut Window, _cx: &mut Context<'_, Self>)
fn prepare(&mut self, _window: &mut Window, _cx: &mut Context<'_, Self>)
Synchronize settings derived from this plugin with the window.
This runs before the root surface and plugin overlays are built. It is intended for window-scoped state such as rem size or the active text selection scope, not for producing elements.
Sourcefn style(
&self,
_surface: &mut Stateful<Div>,
_window: &mut Window,
_cx: &mut App,
)
fn style( &self, _surface: &mut Stateful<Div>, _window: &mut Window, _cx: &mut App, )
Apply this plugin’s default styles directly to the root surface.
Styles set on the Root instance are refined onto the surface after
this hook and therefore take precedence over plugin defaults.
Sourcefn decorate(
&self,
surface: AnyElement,
_root: &Root,
_window: &mut Window,
_cx: &mut App,
) -> impl IntoElement
fn decorate( &self, surface: AnyElement, _root: &Root, _window: &mut Window, _cx: &mut App, ) -> impl IntoElement
Add presentation around the completed root surface.
This runs after plugin defaults and instance styles have been applied.
Return surface unchanged when no outer presentation is needed. Typical
uses include client-side window borders or another structural wrapper.
root provides read-only access to the root and its application view.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".