Skip to main content

Module widget

Module widget 

Source
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 BoxConstraints and return a chosen Size.
  • paint — emit draw commands into a scene.

Structs§

ChildPod
A container’s owned child: a boxed widget plus the layout geometry and capture bookkeeping the container maintains for it.
CornerRadii
The per-corner radii and dash-pattern vocabulary PaintScene’s own signatures name, re-exported from frust-scene so a widget calling PaintScene::fill_rounded_rect_radii/PaintScene::push_clip_rounded_radii/ PaintScene::stroke_path_dashed can name their arguments through the same paint surface it already paints through (mirrors the crate-root accesskit re-export). Per-corner radii for a rounded rectangle, in the pre-transform coordinate space.
DashPattern
The per-corner radii and dash-pattern vocabulary PaintScene’s own signatures name, re-exported from frust-scene so a widget calling PaintScene::fill_rounded_rect_radii/PaintScene::push_clip_rounded_radii/ PaintScene::stroke_path_dashed can name their arguments through the same paint surface it already paints through (mirrors the crate-root accesskit re-export). A stroke’s dash pattern: an on run, an off gap, and a phase offset into that repeating cycle — all lengths in the pre-transform coordinate space.
DiscardScene
A PaintScene sink that accepts every paint command and records nothing — the zero-GPU-cost target for a subtree that still needs its paint pass driven for the pass’s side effects (hero-rect reporting through PaintCtx::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.
HeroFrames
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.
LayoutCtx
Context passed to Widget::layout.
PaintCtx
Context passed to Widget::paint.
PaintOutcome
The result of a whole crate::app::RenderRoot::paint pass.
PlatformViewFrame
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§

HeroDirective
What a reported hero should do this paint — the reply PaintCtx::report_hero hands back to a tagged (“hero”) wrapper.
TickClass
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::paint and the frame gate).

Traits§

PaintScene
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_id was torn down (its View::teardown ran), 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_slot since the last call, in teardown order. Drained once per frame by a shell through crate::app::RenderRoot::take_retired_platform_views.