pub trait Widget: Any {
// Required methods
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size;
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene);
// Provided methods
fn event(
&mut self,
_ctx: &mut EventCtx<'_>,
_event: &InputEvent,
) -> EventResult { ... }
fn semantics(&self, _ctx: &mut SemanticsCtx) { ... }
fn type_name(&self) -> &'static str { ... }
fn visit_children(&self, _visitor: &mut dyn FnMut(&ChildPod)) { ... }
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)> { ... }
}Expand description
A retained UI element living in the widget tree.
Widget: Any so the render root can downcast a boxed widget back to the
concrete element type its originating view produced (needed during rebuild).
Implementing types get [Widget::downcast_mut] for free — no boilerplate
method to write.
Required Methods§
Sourcefn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
Choose a size within bc and return it. The chosen size must satisfy
bc (callers may additionally clamp via BoxConstraints::constrain).
§Layout may be skipped
Under a crate::app::RenderRoot a widget sitting in a ChildPod is
not laid out every frame: ChildPod::layout_child returns the size
it recorded last time, without calling this method, when the pod is clean,
its constraints are equal to last time’s, the window insets it sees are
unchanged, and the root’s layout epoch has not moved (see that method for
the full rule). So the result of layout must be a function of bc, the
context’s global inputs, and widget state that only changes through one of
the channels that dirty the pod:
- a rebuild returning
ChangeFlags::LAYOUT; PaintCtx::request_layout(orEventCtx::request_layout);PaintCtx::request_frame(any frame request — an animating subtree is laid out again on the next pass, conservatively; a pacedTickClass::CosmeticLooprequest marks the pod but forces no pass of its own, so a loop that changes layout must not be paced);- an event the widget consumed (
EventResult::Handled) or that asked for a redraw (EventCtx::request_redraw).
A widget must not change layout-affecting state any other way — a change made behind the pod’s back is invisible to the skip and lays out stale until something else dirties the path.
Sourcefn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
Emit draw commands for this widget into scene.
Paint may advance a widget’s own animation state (e.g. a scroll
fling integrated from a monotonic clock) as a v1 seam. A widget that does
so must call PaintCtx::request_frame while the animation is still
running so the shell re-invokes paint absent any external event —
otherwise the desktop ControlFlow::Wait loop idles and the animation
stalls. It must stop signalling once the animation reaches rest.
Provided Methods§
Sourcefn event(&mut self, _ctx: &mut EventCtx<'_>, _event: &InputEvent) -> EventResult
fn event(&mut self, _ctx: &mut EventCtx<'_>, _event: &InputEvent) -> EventResult
Handle an input event, optionally mutating application state through
ctx and reporting whether it was consumed.
Defaulted to EventResult::Ignored so non-interactive widgets are
unaffected. Interactive widgets
(Button/Checkbox/Slider) override this; containers forward to
their ChildPod children via ChildPod::event_child.
Sourcefn semantics(&self, _ctx: &mut SemanticsCtx)
fn semantics(&self, _ctx: &mut SemanticsCtx)
Contribute this widget’s accessibility node(s) into ctx.
Defaulted to a no-op so non-semantic widgets (and every widget written
before this seam) are unaffected — exactly like Widget::event. A leaf
widget overrides it to call SemanticsCtx::push_node with its role and
state; a container overrides it to forward to each child via
ChildPod::semantics_child (a transparent container contributes no node
of its own, only recursion). The pass runs after layout, so
SemanticsCtx::origin/SemanticsCtx::size carry valid absolute
geometry.
Sourcefn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
This widget’s concrete type name, for read-only tooling.
Defaulted to core::any::type_name of the implementing type, so every
widget reports its own name through the vtable — including one reached
as a dyn Widget, where the concrete type is otherwise unrecoverable.
Asking the live widget beats recording a name when it was built: a
rebuild that swaps a child’s concrete type cannot leave a stale name
behind, not even through wrapper views that re-box an inner AnyView
(docs/LIMITATIONS.md’s focus-wrapper-erasure-swap-blind).
Diagnostic only: type_name’s output is not a stable contract across
compiler versions, so never parse or match on it. Overriding it is
sanctioned only for a transparent wrapper reporting what it wraps (the
Box<dyn Widget> blanket impl is the one in-crate case).
Sourcefn visit_children(&self, _visitor: &mut dyn FnMut(&ChildPod))
fn visit_children(&self, _visitor: &mut dyn FnMut(&ChildPod))
Visit this widget’s owned ChildPods, in declaration (paint) order —
the read-only seam that makes the retained hierarchy enumerable.
Containers own their children as ChildPod fields rather than as arena
nodes (see ChildPod), so nothing outside a container could walk into
its subtree; this is that walk, and
WidgetTree::inspect is its one
in-crate consumer.
Defaulted to visiting nothing, exactly like Widget::event and
Widget::semantics: a leaf widget needs no impl and pays nothing, and
a container that never overrides it simply reads as a leaf to tooling. It
runs behind &self and must not mutate anything a pass depends on — no
build/layout/paint/event behavior may be routed through it.
No cycles by construction. A ChildPod owns its widget (Box<dyn Widget>); ownership is a tree, so a descent through visit_children
terminates without any runtime cycle check. A widget that handed the
visitor a pod it does not own would break that, which is why the visitor
takes &ChildPod — there is no way to publish a shared one.
Sourcefn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
This widget as a sliver, if it speaks the sliver protocol — the opt-in
seam a scrolling viewport lays its children out through (see
crate::sliver and ChildPod::layout_sliver_child).
Defaulted to None, exactly like Widget::visit_children: a box
widget needs no impl and is laid out through Widget::layout as
always. A type implementing SliverWidget overrides it to return
Some(self). A transparent wrapper (a type-erasing box, a component
boundary, an either-arm) forwards it to what it wraps, so a sliver stays
a sliver however it was erased.
Implementations§
Trait Implementations§
Source§impl Widget for Box<dyn Widget>
A boxed widget is itself a Widget, delegating every pass to its contents.
impl Widget for Box<dyn Widget>
A boxed widget is itself a Widget, delegating every pass to its contents.
This blanket impl is what makes type-erased children work: a
crate::view::AnyView’s element is a Box<dyn Widget>, and
View::Element must implement Widget — so the box has to be a widget too.
It also lets a Box<dyn Widget> be stored inside a ChildPod like any
concrete widget. Box<dyn Widget> is 'static (hence Any), so it satisfies
the Widget: Any bound and can be recovered by
[downcast_mut](dyn Widget::downcast_mut) during rebuild.
Source§fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
The boxed widget’s sliver face, so type erasure never hides a sliver from the viewport laying it out.
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Report the boxed widget’s name, not Box<dyn Widget> — the box is a
storage detail of type erasure, never a tree element in its own right,
and it nests (a doubly-boxed pod resolves through both layers).
Source§fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
bc and return it. The chosen size must satisfy
bc (callers may additionally clamp via BoxConstraints::constrain). Read moreSource§fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
scene. Read moreSource§fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
ctx and reporting whether it was consumed. Read moreSource§fn semantics(&self, ctx: &mut SemanticsCtx)
fn semantics(&self, ctx: &mut SemanticsCtx)
ctx. Read moreDyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl Widget for AlignWidget
impl Widget for AlignWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for Box<dyn Widget>
A boxed widget is itself a Widget, delegating every pass to its contents.
impl Widget for Box<dyn Widget>
A boxed widget is itself a Widget, delegating every pass to its contents.
This blanket impl is what makes type-erased children work: a
crate::view::AnyView’s element is a Box<dyn Widget>, and
View::Element must implement Widget — so the box has to be a widget too.
It also lets a Box<dyn Widget> be stored inside a ChildPod like any
concrete widget. Box<dyn Widget> is 'static (hence Any), so it satisfies
the Widget: Any bound and can be recovered by
[downcast_mut](dyn Widget::downcast_mut) during rebuild.
Source§fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
The boxed widget’s sliver face, so type erasure never hides a sliver from the viewport laying it out.
Source§fn type_name(&self) -> &'static str
fn type_name(&self) -> &'static str
Report the boxed widget’s name, not Box<dyn Widget> — the box is a
storage detail of type erasure, never a tree element in its own right,
and it nests (a doubly-boxed pod resolves through both layers).
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for ButtonWidget
impl Widget for ButtonWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for CheckboxWidget
impl Widget for CheckboxWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for FlexWidget
impl Widget for FlexWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for GestureDetectorWidget
impl Widget for GestureDetectorWidget
Source§fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
A detector is a sliver exactly when its child is: the transparent layout
runs through the child pod, so the sliver face is the detector itself
and the pod stays sized for this wrapper’s own paint and hit test (the
ComponentWidget pattern).
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for HeroWidget
impl Widget for HeroWidget
Source§fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
A hero is a sliver exactly when its child is. The sliver face is the hero
itself, so the layout runs through the child pod and leaves it sized for
this wrapper’s own paint (the ComponentWidget
pattern).
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for IconButtonWidget
impl Widget for IconButtonWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for ImageWidget
impl Widget for ImageWidget
Source§impl Widget for IndexedStackWidget
impl Widget for IndexedStackWidget
Source§fn semantics(&self, ctx: &mut SemanticsCtx)
fn semantics(&self, ctx: &mut SemanticsCtx)
Forwards the selected child only. This is the input-gating carve-out of the forward-every-child rule: the accessibility tree follows input routing (R23), and only the selected child receives input.
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for PaddingWidget
impl Widget for PaddingWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for PinchDetectorWidget
impl Widget for PinchDetectorWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for PlatformViewWidget
impl Widget for PlatformViewWidget
fn layout(&mut self, _ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn semantics(&self, ctx: &mut SemanticsCtx)
Source§impl Widget for RepaintBoundaryWidget
impl Widget for RepaintBoundaryWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for SafeAreaWidget
impl Widget for SafeAreaWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for ScaffoldWidget
impl Widget for ScaffoldWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for ScrollWidget
impl Widget for ScrollWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for ShieldWidget
impl Widget for ShieldWidget
Source§fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
A shield is a sliver exactly when its child is: the transparent layout
runs through the child pod, so the sliver face is the shield itself and
the pod stays sized for this wrapper’s own paint (the
ComponentWidget pattern).
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for SizedBoxWidget
impl Widget for SizedBoxWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for SliderWidget
impl Widget for SliderWidget
fn layout(&mut self, _ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
Source§impl Widget for SliverBoxWidget
impl Widget for SliverBoxWidget
Source§fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
Outside a viewport the adapter is transparent: the child is laid out
under bc at the origin, uncut.
Source§fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
The viewport only delivers a positional event inside this sliver’s paint extent (or to a captured child), and that extent lies inside the child’s own bounds, so the ordinary single-child routing applies.
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn semantics(&self, ctx: &mut SemanticsCtx)
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for SliverFillRemainingWidget
impl Widget for SliverFillRemainingWidget
Source§fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
Outside a viewport there is nothing to fill: the child is laid out
under bc at the origin, uncut.
Source§fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
The viewport only delivers a positional event inside this sliver’s paint extent (or to a captured child), so the ordinary single-child routing applies.
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn semantics(&self, ctx: &mut SemanticsCtx)
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for SliverFixedExtentListWidget
impl Widget for SliverFixedExtentListWidget
Source§fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
Outside a viewport the list lays out as if it were the only sliver of a
viewport bc.max() long, scrolled to its start: it materialises (at
the next rebuild) and sizes itself to the rows that fit, or to all of
them under an unbounded constraint.
Source§fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
Delivers a near-edge fire observed at layout, then routes the event to the rows: the viewport only delivers a positional event inside this sliver’s paint extent, where only painted rows sit.
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn semantics(&self, ctx: &mut SemanticsCtx)
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for SliverGridWidget
impl Widget for SliverGridWidget
Source§fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
Outside a viewport the grid lays out as if it were the only sliver of a
viewport bc.max() long, scrolled to its start (the fixed-extent
list’s rule).
Source§fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
The viewport only delivers a positional event inside this sliver’s paint extent, where only painted cells sit.
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn semantics(&self, ctx: &mut SemanticsCtx)
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for SliverListWidget
impl Widget for SliverListWidget
Source§fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
Outside a viewport the list lays out as if it were the only sliver of a
viewport bc.max() long, scrolled to its start (the fixed-extent
list’s rule).
Source§fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
Delivers a near-edge fire observed at layout, then routes the event to the materialised rows (parked rows receive nothing).
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn semantics(&self, ctx: &mut SemanticsCtx)
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for SliverPaddingWidget
impl Widget for SliverPaddingWidget
Source§fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
Outside a viewport the padding is a plain Padding:
the child is laid out under bc deflated by the insets, at the
leading insets.
Source§fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
The viewport delivers a positional event only inside this sliver’s hit-test extent, so the ordinary single-child routing applies.
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn semantics(&self, ctx: &mut SemanticsCtx)
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for SliverPersistentHeaderWidget
impl Widget for SliverPersistentHeaderWidget
Source§fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
Outside a viewport the header is unscrolled: the child is laid out at
max_extent along the axis of the last sliver layout (vertical before
one), clamped into bc, and at bc’s largest finite cross extent.
Source§fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
Paints the child, and requests the frame whose rebuild brings the content up to the shrink offset this frame’s layout computed.
Source§fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
The viewport delivers a positional event only inside the header’s hit-test extent (or to a captured child), so the ordinary single-child routing applies.
fn semantics(&self, ctx: &mut SemanticsCtx)
fn as_sliver(&mut self) -> Option<&mut (dyn SliverWidget + 'static)>
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for StackWidget
impl Widget for StackWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§impl Widget for TextInputWidget
impl Widget for TextInputWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
Source§impl Widget for TextWidget
impl Widget for TextWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn semantics(&self, ctx: &mut SemanticsCtx)
Source§impl Widget for ViewportWidget
impl Widget for ViewportWidget
fn layout(&mut self, ctx: &mut LayoutCtx<'_>, bc: &BoxConstraints) -> Size
fn paint(&mut self, ctx: &mut PaintCtx<'_>, scene: &mut dyn PaintScene)
fn event(&mut self, ctx: &mut EventCtx<'_>, event: &InputEvent) -> EventResult
fn semantics(&self, ctx: &mut SemanticsCtx)
fn visit_children(&self, visitor: &mut dyn FnMut(&ChildPod))
Source§fn semantics(&self, ctx: &mut SemanticsCtx)
fn semantics(&self, ctx: &mut SemanticsCtx)
R23 — semantics forwarding follows input routing, exactly.
A transparent container (like Stack): the navigator
contributes no node of its own and forwards
ChildPod::semantics_child for exactly the pages
input_routed_pages says an input event
could reach — today { pages.last() }. Every other page is omitted:
no node, no recursion. Offering a screen-reader user a control they
physically cannot activate is worse than not offering it, so the two
reaches are derived from one function rather than kept in sync by hand.
§This omits more than paint culling does
A page under a transparent overlay is PageVisibility::Visible —
still painted — yet it is omitted here, because R23 tracks input
routing, not painting, and route_top routes only
to the top page. The divergence is deliberate: it is what makes a modal
modal to assistive technology for free (the page beneath a dialog is
already inert to a finger). The topmost transparent page — the dialog
itself — is forwarded, since it is pages.last().
§Why omission and not an accesskit flag
Not hidden: it would need a synthesized per-page wrapper node to carry
the flag (churning node ids on every navigation for nodes that exist
only to say “ignore me”), it would publish the stale bounds of a
covered page that layout skipped, and whether every platform adapter
honours the flag is unverified — omission needs no such trust. Not
clips_children, which asserts overflow: hidden and would be simply
false here. Not modal, which is the right flag but belongs on the
dialog widget: the navigator does not know a page is a dialog and cannot
infer it from BackPolicy (most shipped modals push through
push_transparent_for_result and so take the default
BackPolicy::Pop).
§During a transition
No special case: pages.last() is the destination page for a push,
pop and replace alike, and its mid-flight bounds are the animated pod
origins paint is using — consistent with the screen and
self-correcting within one transition. Input is fully suppressed
mid-transition (event_at), so a screen reader
activating a node during those ≤340ms hits exactly the same suppression
a finger would.