pub struct RenderRoot<State: 'static, V: View<State>> { /* private fields */ }Expand description
Owns the retained tree and drives the rebuild/layout/paint/event passes of a single-root app.
Implementations§
Source§impl<State: 'static, V: View<State>> RenderRoot<State, V>
impl<State: 'static, V: View<State>> RenderRoot<State, V>
Sourcepub fn set_focus_ring_policy(&mut self, policy: FocusRingPolicy)
pub fn set_focus_ring_policy(&mut self, policy: FocusRingPolicy)
Choose when the focused widget draws a ring (default FocusRingPolicy::KeyboardOnly).
Sourcepub fn focus_ring_policy(&self) -> FocusRingPolicy
pub fn focus_ring_policy(&self) -> FocusRingPolicy
The policy RenderRoot::set_focus_ring_policy last set.
Sourcepub fn set_tab_traversal(&mut self, enabled: bool)
pub fn set_tab_traversal(&mut self, enabled: bool)
Switch Tab traversal on (the default) or off. Off, a bare Tab/Shift+Tab the tree, the forward and the shortcut table declined stays unhandled, for the host’s own tab order. On, each such Tab rebuilds the walk’s stops (accepted: Tab is rare).
Sourcepub fn tab_traversal(&self) -> bool
pub fn tab_traversal(&self) -> bool
Whether a declined bare Tab runs traversal (RenderRoot::set_tab_traversal).
Sourcepub fn set_layout_skip(&mut self, skip: bool)
pub fn set_layout_skip(&mut self, skip: bool)
Switch the layout skip on (the default) or off; false lays out every pod every pass.
Sourcepub fn layout_skip(&self) -> bool
pub fn layout_skip(&self) -> bool
Whether layout passes may skip clean pods (RenderRoot::set_layout_skip).
Sourcepub fn set_layout_audit(&mut self, audit: bool)
pub fn set_layout_audit(&mut self, audit: bool)
Turn the layout audit (a debug aid that doubles layout cost) on or off; off by default.
With the skip on, layout re-runs forced and warns layout-audit: per pod moved >1e-3 px.
Sourcepub fn layout_audit(&self) -> bool
pub fn layout_audit(&self) -> bool
Whether the layout audit is on (RenderRoot::set_layout_audit).
Sourcepub fn layout_audit_mismatches(&self) -> u64
pub fn layout_audit_mismatches(&self) -> u64
Pods the layout audit has found with mismatched geometry since creation, every occurrence counted (unlike the rate-limited log).
Sourcepub fn layout_epoch(&self) -> u64
pub fn layout_epoch(&self) -> u64
The global layout epoch the next layout pass runs under, for tooling and tests.
Sourcepub fn set_retained_layers(&mut self, enabled: bool)
pub fn set_retained_layers(&mut self, enabled: bool)
Enable or disable retained layers (default on); off, every boundary repaints its child.
Sourcepub fn set_retained_ledger(&mut self, ledger: &RetainedLedger)
pub fn set_retained_ledger(&mut self, ledger: &RetainedLedger)
Hand the root the renderer’s resident-key ledger from the previous frame (one frame stale by design); cloned only when it differs.
Sourcepub fn retained_layers(&self) -> bool
pub fn retained_layers(&self) -> bool
Whether retained layers are enabled (RenderRoot::set_retained_layers).
Sourcepub fn set_theme(&mut self, theme: Box<dyn Any>)
pub fn set_theme(&mut self, theme: Box<dyn Any>)
Store (replace) the app’s type-erased theme, recovered by widgets via theme_as. Marks
LAYOUT | PAINT and invalidates every cached layout: widgets bake themed state at layout.
Sourcepub fn set_insets(&mut self, insets: WindowInsets)
pub fn set_insets(&mut self, insets: WindowInsets)
Store the window’s insets, recovered by widgets via window_insets. An actual change
dirties exactly like RenderRoot::set_theme; pushing the current value is a no-op.
Sourcepub fn insets(&self) -> WindowInsets
pub fn insets(&self) -> WindowInsets
The window’s insets currently threaded into the layout/paint passes.
Sourcepub fn set_presented_frames(&mut self, presented: u64)
pub fn set_presented_frames(&mut self, presented: u64)
Store the shell’s presented-frame count (pushed once per UI frame, before paint). Dirties
nothing: a ticking count marked dirty would keep the mobile frame gate from ever idling.
Sourcepub fn presented_frames(&self) -> Option<u64>
pub fn presented_frames(&self) -> Option<u64>
The presented-frame count currently threaded into the paint pass, or
None if no shell has pushed one.
Sourcepub fn set_surface_translucent(&mut self, translucent: bool)
pub fn set_surface_translucent(&mut self, translucent: bool)
Store the surface’s resolved translucency (what the backend granted, not what the app
asked: a refused request must stay opaque, or every platform-view slot punches a black
hole). An actual change marks PAINT and invalidates retained paint; no relayout.
Sourcepub fn is_surface_translucent(&self) -> bool
pub fn is_surface_translucent(&self) -> bool
Whether the shell’s GPU surface is currently marked translucent.
Source§impl<State: 'static, V: View<State>> RenderRoot<State, V>
impl<State: 'static, V: View<State>> RenderRoot<State, V>
Sourcepub fn event(&mut self, state: &mut State, event: &InputEvent) -> EventOutcome
pub fn event(&mut self, state: &mut State, event: &InputEvent) -> EventOutcome
Deliver an input event to the widget tree. The outcome’s handled is the
dispatch’s result; needs_redraw is set when a widget consumed the event
or asked for a redraw, and for a hover that ended with nothing taking it
(the one repaint no widget can request). The pass never rebuilds or
repaints: the shell runs RenderRoot::rebuild afterwards, which itself
calls this sequentially with InputEvent::Housekeeping.
Beside the outcome it resolves the cursor (RenderRoot::cursor, on a
pointer Move), the clipboard write and paste request (every pass), the
IME state and the focus epoch. A FileDropPhase::Drop or Cancel is
followed in the same call by a FileDropPhase::Ended broadcast to the
whole tree; an unhandled Key goes on (dispatch_declined_key); the outcome folds all.
Source§impl<State: 'static, V: View<State>> RenderRoot<State, V>
impl<State: 'static, V: View<State>> RenderRoot<State, V>
Sourcepub fn layout(&mut self, window_size: Size) -> Size
pub fn layout(&mut self, window_size: Size) -> Size
Lay out the root widget against window_size and record its geometry.
The root gets loose constraints and sits at the origin; returns its size.
No text context is threaded (use RenderRoot::layout_with_text).
Sourcepub fn layout_with_text(
&mut self,
window_size: Size,
text_ctx: &mut dyn Any,
) -> Size
pub fn layout_with_text( &mut self, window_size: Size, text_ctx: &mut dyn Any, ) -> Size
Lay out the root widget, threading a shared text-shaping context down to text widgets.
text_ctx is the shell-owned frust_text::TextContext, type-erased so
this crate needs no frust-text dependency; widgets recover it via
crate::widget::LayoutCtx::text_context.
Source§impl<State: 'static, V: View<State>> RenderRoot<State, V>
impl<State: 'static, V: View<State>> RenderRoot<State, V>
Sourcepub fn paint(
&mut self,
scene: &mut dyn PaintScene,
frame_time: FrameTime,
) -> PaintOutcome
pub fn paint( &mut self, scene: &mut dyn PaintScene, frame_time: FrameTime, ) -> PaintOutcome
Paint the root widget into scene. The outcome reports a continuation
frame (PaintCtx::request_frame → PaintOutcome::needs_frame) and a
paint-time PaintCtx::request_layout, which is also folded into the
pending ChangeFlags as LAYOUT. frame_time is the shell’s clock for
the frame, threaded unchanged to every widget (PaintCtx::frame_time).
§The overlay post-pass
Surfaces registered during the main walk (PaintCtx::register_overlay)
are painted after it in band order, escaping their owner’s paint order and
clips; their routing rects are kept for the next event pass to hit-test
first, and their outcomes merge into this one.
Sourcepub fn selection_toolbar(&self) -> Option<SelectionToolbarRequest>
pub fn selection_toolbar(&self) -> Option<SelectionToolbarRequest>
The selection-toolbar request the focused field published during the most
recent RenderRoot::paint, or None when no field is focused. A level:
a shell driving the platform edit menu
(SelectionToolbarPolicy::Native)
reads it beside RenderRoot::ime_state. Present with a bare caret too
(paste applies), and under the framework policy as well.
Sourcepub fn selection_toolbar_generation(&self) -> u64
pub fn selection_toolbar_generation(&self) -> u64
A generation bumped on every change to the menu-significant part of
RenderRoot::selection_toolbar (present_menu and actions, clearing
included). A moved anchor is not an edge: a shell re-reads it per frame,
caching this value like RenderRoot::focus_ime_generation.
Source§impl<State: 'static, V: View<State>> RenderRoot<State, V>
impl<State: 'static, V: View<State>> RenderRoot<State, V>
Sourcepub fn platform_view_frames(&self) -> &[PlatformViewFrame]
pub fn platform_view_frames(&self) -> &[PlatformViewFrame]
The PlatformViewFrames the most recent paint published, in paint order (never stale).
Sourcepub fn input_shields(&self) -> &[Rect]
pub fn input_shields(&self) -> &[Rect]
The z-shield rects the most recent paint reported, in paint order (never stale).
Sourcepub fn take_retired_platform_views(&mut self) -> Vec<u64>
pub fn take_retired_platform_views(&mut self) -> Vec<u64>
Drain the slot ids whose platform_view widgets were torn down since the last call, so a
shell retires their native views at once. Each id is reported exactly once; a merely culled
slot never appears (culling runs no teardown).
Sourcepub fn take_change_flags(&mut self) -> ChangeFlags
pub fn take_change_flags(&mut self) -> ChangeFlags
Take (and clear) the dirtiness accumulated since the last call.
Sourcepub fn has_pending_change_flags(&self) -> bool
pub fn has_pending_change_flags(&self) -> bool
Non-draining peek: whether any LAYOUT/PAINT bit is pending. A frame gate reads it before
deciding, so a skipped frame leaves the flags for the next running frame to drain.
Sourcepub fn tree(&self) -> &WidgetTree
pub fn tree(&self) -> &WidgetTree
Shared access to the retained tree (for the shell / tests).
Sourcepub fn inspect(&self) -> Vec<InspectNode>
pub fn inspect(&self) -> Vec<InspectNode>
A read-only pre-order snapshot of the retained tree, container-owned pods included, for tooling: per node its id, parent, children, type name, debug label and absolute border box. Bounds are the last layout pass’s (all zero before the first).
Sourcepub fn inspect_layout_dirty(&self) -> Vec<(WidgetId, bool)>
pub fn inspect_layout_dirty(&self) -> Vec<(WidgetId, bool)>
Per-node layout-dirty state in RenderRoot::inspect’s order and ids, for tooling/tests.
Sourcepub fn inspect_paint_dirty(&self) -> Vec<(WidgetId, bool)>
pub fn inspect_paint_dirty(&self) -> Vec<(WidgetId, bool)>
Per-node paint-dirty state, read-only — see WidgetTree::inspect_paint_dirty.
Sourcepub fn rebuild(
&mut self,
build: &mut impl FnMut(&mut State) -> V,
state: &mut State,
) -> ChangeFlags
pub fn rebuild( &mut self, build: &mut impl FnMut(&mut State) -> V, state: &mut State, ) -> ChangeFlags
Run the build closure, then build (first call) or rebuild the root widget, returning what changed. The closure re-runs in full every rebuild, so it must be cheap.
§Deferred-callback flush
While a structural op has raised mark_pending_result_flush, each pass dispatches one
InputEvent::Housekeeping broadcast (where &mut State is in scope) and re-diffs, capped
by MAX_PENDING_RESULT_FLUSH_PASSES: past it the mark stays raised and one more frame is
requested. A broadcast’s needs_redraw requests that frame too.
Source§impl<State: 'static, V: View<State>> RenderRoot<State, V>
impl<State: 'static, V: View<State>> RenderRoot<State, V>
Sourcepub fn semantics(&self) -> SemanticsUpdate
pub fn semantics(&self) -> SemanticsUpdate
Collect the accessibility tree as a SemanticsUpdate for a platform
accesskit_* adapter. Pull-based (the shell calls it on demand, never per
frame) and valid only after RenderRoot::layout, since bounds come from
post-layout geometry. Always rooted at a synthetic window-sized
accesskit::Role::Window node; an unbuilt tree yields that node alone.
Sourcepub fn semantics_generation(&self) -> u64
pub fn semantics_generation(&self) -> u64
The semantics dirty gate: bumped by a rebuild that returned change flags,
a theme swap, and an inset change. A shell records the value it last
pushed and compares (RenderRoot::semantics_if_changed).
Sourcepub fn semantics_if_changed(&self, last_seen: u64) -> Option<SemanticsUpdate>
pub fn semantics_if_changed(&self, last_seen: u64) -> Option<SemanticsUpdate>
A fresh whole-tree SemanticsUpdate if the generation moved past
last_seen, else None (the shell skips the walk and the push). Call it
post-layout; on Some, store RenderRoot::semantics_generation.
Sourcepub fn perform_accessibility_action(
&mut self,
state: &mut State,
node_id: NodeId,
action: Action,
) -> EventOutcome
pub fn perform_accessibility_action( &mut self, state: &mut State, node_id: NodeId, action: Action, ) -> EventOutcome
Perform a platform accessibility action by synthesizing pointer input at
the node’s bounds center through RenderRoot::event, returning the
combined EventOutcome. Handles Click and Focus only:
accesskit::Action::Click→DownthenUp, as a real tap.accesskit::Action::Focus→DownthenCancel: theDownclaims focus for a widget that opts in onDown; theCancelreleases its capture without touching focus or firing an on-press callback.
Any other action, or a node_id not in the tree, is a no-op. Requires a
prior RenderRoot::layout; a widget needing a real drag is not operable.
Source§impl<State: 'static, V: View<State>> RenderRoot<State, V>
impl<State: 'static, V: View<State>> RenderRoot<State, V>
Sourcepub fn is_pointer_captured(&self) -> bool
pub fn is_pointer_captured(&self) -> bool
Whether a captured pointer gesture is currently in flight.
Sourcepub fn pointer_capture_claimant(&self) -> Option<PointerId>
pub fn pointer_capture_claimant(&self) -> Option<PointerId>
The contact that claimed the capture in flight (only its Up/Cancel ends it), or None.
Sourcepub fn pointer_capture_contacts(&self) -> bool
pub fn pointer_capture_contacts(&self) -> bool
Whether the capture in flight routes the gesture’s other contacts to its captor.
Sourcepub fn is_focus_active(&self) -> bool
pub fn is_focus_active(&self) -> bool
Whether some widget in the tree currently holds keyboard/IME focus.
Sourcepub fn is_hover_active(&self) -> bool
pub fn is_hover_active(&self) -> bool
Whether the last hover pass left a widget holding the hover link; a rebuild removing the
claimant ends it. A touch drag raises it too (LIMITATIONS hover-window-leave-standing).
Sourcepub fn cursor(&self) -> CursorIcon
pub fn cursor(&self) -> CursorIcon
The cursor the tree last asked the host to show: re-resolved on every pointer Move
(CursorIcon::Default when nothing asked) and standing through every other pass.
Residual: a widget that is torn down (or moves out from under a stationary pointer) while
its request stands leaves the last shape in place until the next Move re-resolves it.
Sourcepub fn take_clipboard_write(&mut self) -> Option<String>
pub fn take_clipboard_write(&mut self) -> Option<String>
Take (and clear) the text a widget asked the shell to put on the host clipboard; drain after
every RenderRoot::event. Destructive: a write is an edge, so a dropped result is lost.
Sourcepub fn take_paste_request(&mut self) -> bool
pub fn take_paste_request(&mut self) -> bool
Take (and clear) whether a widget asked to read the host clipboard; the shell answers with a
new EditCommand::Paste dispatch, dropping an async answer once focus_epoch has moved.
Sourcepub fn ime_state(&self) -> Option<ImeState>
pub fn ime_state(&self) -> Option<ImeState>
The IME surface the focused widget published, for the platform input method. None is the
only no-session form: an inactive publish is a release, so is_some() means a live session.
Sourcepub fn focus_ime_generation(&self) -> u64
pub fn focus_ime_generation(&self) -> u64
Bumped on every actual change of is_focus_active or ime_state — the frame gate’s
focus_or_ime_changed edge. It counts surface changes, not sessions (see focus_epoch).
Sourcepub fn focus_epoch(&self) -> u64
pub fn focus_epoch(&self) -> u64
The live focus session’s identity. It advances once per honoured claim (an
EventCtx::request_focus or a traversal grant) and once per release, so a Tab step that
lands from a live session moves it by two (by one from none) and one that lands nowhere leaves it unchanged. It moves when focus
crosses fields that publish alike. Never 0: a safe sentinel.
Source§impl<State: 'static, V: View<State>> RenderRoot<State, V>
impl<State: 'static, V: View<State>> RenderRoot<State, V>
Sourcepub fn shortcut_hints(
&self,
filter: impl FnMut(&ShortcutHint) -> bool,
) -> Vec<ShortcutHint>
pub fn shortcut_hints( &self, filter: impl FnMut(&ShortcutHint) -> bool, ) -> Vec<ShortcutHint>
The last paint’s shortcut declarations filter keeps, in paint order: a palette’s list.