Expand description
Layer 2: the retained Widget trait and its layout/paint contexts.
Widgets are the long-lived counterpart to crate::view::Views. A view is
rebuilt every frame; the widget it produced persists in the arena and is
mutated in place. Widgets participate in two passes:
- layout — receive
BoxConstraintsand return a chosenSize. - paint — emit draw commands into a scene.
Structs§
- Child
Pod - A container’s owned child: a boxed widget plus the layout geometry and capture bookkeeping the container maintains for it.
- Corner
Radii - The per-corner radii and dash-pattern vocabulary
PaintScene’s own signatures name, re-exported fromfrust-sceneso a widget callingPaintScene::fill_rounded_rect_radii/PaintScene::push_clip_rounded_radii/PaintScene::stroke_path_dashedcan name their arguments through the same paint surface it already paints through (mirrors the crate-rootaccesskitre-export). Per-corner radii for a rounded rectangle, in the pre-transform coordinate space. - Dash
Pattern - The per-corner radii and dash-pattern vocabulary
PaintScene’s own signatures name, re-exported fromfrust-sceneso a widget callingPaintScene::fill_rounded_rect_radii/PaintScene::push_clip_rounded_radii/PaintScene::stroke_path_dashedcan name their arguments through the same paint surface it already paints through (mirrors the crate-rootaccesskitre-export). A stroke’s dash pattern: anonrun, anoffgap, and aphaseoffset into that repeating cycle — all lengths in the pre-transform coordinate space. - Discard
Scene - A
PaintScenesink that accepts every paint command and records nothing — the zero-GPU-cost target for a subtree that still needs itspaintpass driven for the pass’s side effects (hero-rect reporting throughPaintCtx::with_hero_registry, other paint-time widget state) even though its pixels will never be composited. The navigator’s transition machinery is the motivating case: a page whose resolved alpha is 0 still has to paint to report hero rects and advance animating children, but every command it emits is otherwise wasted GPU work. - Hero
Frames - A tagged-rect reporter threaded through the paint pass, letting a container discover where tagged (“hero”) descendants painted and drive a shared-element morph between two of them across a navigation transition.
- Layout
Ctx - Context passed to
Widget::layout. - Paint
Ctx - Context passed to
Widget::paint. - Paint
Outcome - The result of a whole
crate::app::RenderRoot::paintpass. - Platform
View Frame - A platform-view child’s paint-time frame — everything a shell’s native compositor needs to place, size, clip, and dispose a native sibling view for one paint pass.
Enums§
- Hero
Directive - What a reported hero should do this paint — the reply
PaintCtx::report_herohands back to a tagged (“hero”) wrapper. - Tick
Class - The class of a continuation-frame request a widget makes during paint —
how urgent the next frame is, so the mobile frame gate can decide whether it
may be paced (see
crate::app::RenderRoot::paintand the frame gate).
Traits§
- Paint
Scene - The renderer-agnostic paint target a widget draws into.
- Widget
- A retained UI element living in the widget tree.
Functions§
- next_
slot_ id - Allocate a fresh, stable platform-view slot id.
- report_
retired_ slot - Record that the widget owning
slot_idwas torn down (itsView::teardownran), so the shell can dispose the native view promptly instead of waiting out the differ’s missing-streak heuristic. - take_
retired_ slots - Take (and clear) every slot id reported to
report_retired_slotsince the last call, in teardown order. Drained once per frame by a shell throughcrate::app::RenderRoot::take_retired_platform_views.