Skip to main content

frus_widgets/
widget.rs

1//! The [`Widget`] trait, generic over the message type emitted on interaction.
2
3use frus_core::{Rect, Scene, SemanticsProperties, Size};
4use frus_layout::Style;
5
6use crate::interaction::{Cursor, Key, Status};
7use crate::portal::Placement;
8use crate::runtime::Edit;
9use crate::scroll::Axis;
10use crate::theme::Theme;
11
12/// A slot built on demand: the closure a `Table` header, a `Table` row or a `Kanban`
13/// column takes for a cell that holds a **widget** rather than a string. It is called
14/// again on every rebuild, so it hands back a fresh widget each time.
15pub type CellFn<Msg = crate::callback::Callback> = Box<dyn Fn() -> Box<dyn Widget<Msg>>>;
16
17/// Axis along which a **reorderable** widget moves while dragging: `Table` columns slide
18/// **horizontally** (the default), `Kanban` cards **vertically**. The shell adapts the drag
19/// preview (ghost direction, insertion indicator) to this axis.
20#[derive(Clone, Copy, Debug, PartialEq, Eq, Default)]
21pub enum ReorderAxis {
22    /// Horizontal reordering (columns) — the default.
23    #[default]
24    Horizontal,
25    /// Vertical reordering (stacked cards).
26    Vertical,
27}
28
29/// The **sizing** half of a style: the fields that decide how big a box is, and none
30/// of the ones that decide what happens inside it.
31///
32/// For a wrapper that nests its child ([`crate::Draggable`], [`crate::Hero`]) and wants
33/// the box its child would have had. Copying the *whole* style would inset that child
34/// twice — once by the wrapper's padding, then again by the child's, which is the same
35/// number.
36pub(crate) fn sizing_of(style: Style) -> Style {
37    Style {
38        width: style.width,
39        height: style.height,
40        min_width: style.min_width,
41        min_height: style.min_height,
42        max_width: style.max_width,
43        max_height: style.max_height,
44        flex_grow: style.flex_grow,
45        flex_shrink: style.flex_shrink,
46        flex_basis: style.flex_basis,
47        aspect_ratio: style.aspect_ratio,
48        ..Default::default()
49    }
50}
51
52/// A widget: a composable interface element.
53///
54/// `Msg` is the application message type emitted on interaction (a message-passing
55/// model, in the Elm/iced style).
56/// What the paint walk knows and a widget does not, at the moment its layer filter is
57/// asked for.
58///
59/// Both fields are there for the same reason: they are properties of *where the widget
60/// turned out to be*, not of what it was built with. A mask is written in fractions of
61/// a box, and the box is only a place on screen once layout has run; a shared backdrop
62/// belongs to the nearest enclosing group, and a widget cannot see its own ancestors.
63#[derive(Clone, Copy, Debug)]
64pub struct FilterContext {
65    /// The widget's own box, on screen.
66    pub box_rect: frus_core::Rect,
67    /// The identity of the nearest enclosing [`crate::BackdropGroup`], if any — the
68    /// key a backdrop asking to be shared should use.
69    pub backdrop_group: Option<u64>,
70}
71
72/// The axes a widget asks to **fill**: on each, it takes the room its parent leaves it
73/// rather than shrink-wrapping its children.
74///
75/// # Why this is asked and not declared
76///
77/// `width: 100%` looks like the same thing and is not. A percentage resolves against the
78/// parent's **resolved** width, which a parent that shrink-wraps has not got yet — it is
79/// waiting on this very child to find out how wide it should be. Both are "full width" in
80/// English, and only one can be computed in time:
81///
82/// | | what it needs | known |
83/// |---|---|---|
84/// | `width: 100%` | the parent's own width | on the way back **up** |
85/// | a fill request | the room being offered | on the way **down** |
86///
87/// Fifteen widgets in this crate said it the first way and every one of them collapsed
88/// under a plain column (milestone 404). Asking is the only phrasing the layout can answer.
89#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
90pub struct FillAxes {
91    /// Take the width the parent offers.
92    pub horizontal: bool,
93    /// Take the height the parent offers.
94    pub vertical: bool,
95}
96
97impl FillAxes {
98    /// Shrink-wrap on both axes — what a widget with no opinion answers.
99    pub const NONE: Self = Self {
100        horizontal: false,
101        vertical: false,
102    };
103    /// Take the width offered; hug the content vertically.
104    pub const WIDTH: Self = Self {
105        horizontal: true,
106        vertical: false,
107    };
108    /// Take the height offered; hug the content horizontally.
109    pub const HEIGHT: Self = Self {
110        horizontal: false,
111        vertical: true,
112    };
113    /// Take everything offered — a full-screen shell.
114    pub const BOTH: Self = Self {
115        horizontal: true,
116        vertical: true,
117    };
118
119    /// The axes asked for, as one flex direction, or `None` where that cannot be said —
120    /// neither axis, or both. For the walk, which resolves each axis separately anyway.
121    pub fn single(self) -> Option<frus_layout::FlexDirection> {
122        match (self.horizontal, self.vertical) {
123            (true, false) => Some(frus_layout::FlexDirection::Row),
124            (false, true) => Some(frus_layout::FlexDirection::Column),
125            _ => None,
126        }
127    }
128
129    /// Whether one axis is asked for.
130    pub fn wants(self, horizontal: bool) -> bool {
131        if horizontal {
132            self.horizontal
133        } else {
134            self.vertical
135        }
136    }
137
138    /// The axis a [`frus_layout::FlexDirection`] names, and nothing else.
139    pub fn along(direction: frus_layout::FlexDirection) -> Self {
140        if direction.is_horizontal() {
141            Self::WIDTH
142        } else {
143            Self::HEIGHT
144        }
145    }
146}
147
148/// A **widget**: a node of the tree that is laid out by [`Widget::style`], painted by
149/// [`Widget::paint`] and asked what a click means by [`Widget::on_click`]; `Msg` is the
150/// message it emits when the reader interacts with it.
151///
152/// Only those four are required. Everything else — focus, scrolling, editing, semantics,
153/// the hooks a container uses to build its children late — has a default that does nothing,
154/// so a widget implements what it takes part in and no more.
155pub trait Widget<Msg = crate::callback::Callback> {
156    /// Layout style (handed to `frus-layout`).
157    fn style(&self) -> Style;
158
159    /// The widget's children (possibly empty).
160    fn children(&self) -> &[Box<dyn Widget<Msg>>];
161
162    /// Paints the widget's own decoration, according to its status (hover / focus /
163    /// cursor / selection) and the current theme.
164    fn paint(&self, bounds: Rect, status: Status, theme: &Theme, scene: &mut Scene);
165
166    /// Message to emit on click (`None` = not clickable).
167    fn on_click(&self) -> Option<Msg>;
168
169    /// Whether a press that lands on this widget and on **nothing inside it** stops
170    /// here.
171    ///
172    /// An ordinary widget is transparent to a press it has no message for: the press
173    /// carries on to whatever is behind. That is right for a label on a card and wrong
174    /// for a **surface** — a floating panel, a sheet, a bar — where the thing behind is
175    /// the page and the press reaching it means the panel is dismissed by a click on its
176    /// own padding, or on a row that said it was unavailable.
177    ///
178    /// It is registered **before** the widget's children, so anything inside still wins;
179    /// all this catches is what nothing inside claimed. `false` by default, because a
180    /// widget that stops presses it does not use is the surprising one.
181    ///
182    /// This is not [`crate::AbsorbPointer`], which discards the whole subtree's targets.
183    /// Here the subtree keeps every one of them and only the gaps between them are
184    /// closed.
185    fn opaque(&self) -> bool {
186        false
187    }
188
189    /// **Stable** identity key (independent of the position among siblings).
190    /// `None` = positional identity. See [`crate::Keyed`].
191    fn key(&self) -> Option<u64> {
192        None
193    }
194
195    /// **Short** name of the widget — for the inspector and diagnostic dumps.
196    /// Defaults to the name of the concrete type, without module path or
197    /// generics (each implementation gets its own monomorphised copy of this
198    /// default body). Transparent wrappers (`Box`, [`crate::Keyed`]…) delegate
199    /// to their content.
200    fn debug_name(&self) -> &'static str {
201        short_type_name::<Self>()
202    }
203
204    /// The widget's **accessibility annotation** (role, label, value, state),
205    /// exposed to assistive technologies through the AccessKit tree. `None` =
206    /// no semantics of its own (a layout container — its children, though,
207    /// may have some). See [`frus_core::SemanticsProperties`].
208    fn semantics(&self) -> Option<SemanticsProperties> {
209        None
210    }
211
212    /// What this widget says about its **child's** subtree, when it knows something the
213    /// child cannot know about itself — the [`crate::Semantics`] wrapper, and nothing else
214    /// so far.
215    ///
216    /// [`Widget::semantics`] is a widget answering for itself and covers the ordinary
217    /// case. This covers the one it cannot: a caller handed an already-built widget, with
218    /// no way in. Read in one place in the walk, the way a
219    /// [`ModalBarrier`](crate::barrier::ModalBarrier) is — the subtree is walked exactly as
220    /// usual and what it produced is reconciled afterwards, so a widget deep inside
221    /// annotates itself without knowing anything is speaking for it.
222    fn describes(&self) -> Option<crate::semantics::Description> {
223        None
224    }
225
226    /// Applies a key to the focused widget: mutates the edit state
227    /// (cursor/selection) and returns a message if the **value** changes.
228    fn on_edit(&self, _edit: &mut Edit, _key: &Key) -> Option<Msg> {
229        None
230    }
231
232    /// **Positional** click: a message emitted according to where the click landed (local
233    /// coordinates from the widget's top-left corner, within the `width × height` box), taking
234    /// **priority** over [`on_click`](Self::on_click). For clickable sub-regions — e.g. the
235    /// **suffix** icon of a [`crate::TextField`] (clear / reveal) or a chart **point**
236    /// (milestone 221). `None` (the default) = no sub-region; the shell falls back to `on_click`.
237    fn positional_click(
238        &self,
239        _local_x: f32,
240        _local_y: f32,
241        _width: f32,
242        _height: f32,
243    ) -> Option<Msg> {
244        None
245    }
246
247    /// Shape of the **system cursor** wanted at the **local** position `(local_x, local_y)` inside
248    /// the widget's `width × height` box (milestone 205): `Some(Cursor::Pointer)` over a clickable
249    /// sub-region (a suffix icon…), `None` (the default) = no opinion, the shell keeps the default
250    /// cursor. Does not affect clicking; this is purely the pointer's appearance on hover.
251    fn cursor_icon(
252        &self,
253        _local_x: f32,
254        _local_y: f32,
255        _width: f32,
256        _height: f32,
257    ) -> Option<Cursor> {
258        None
259    }
260
261    /// Cursor index matching a local position (px from the widget's top-left
262    /// corner) — for placing the caret on click. `local_y` picks the **line** in a
263    /// multi-line field (ignored on a single line).
264    ///
265    /// `width` = the field's width, `scroll_cursor` = the cursor from which to recompute
266    /// the current **scroll** (the same one the render used), so that a click lands right
267    /// even when the text is scrolled. `None` = not a text field.
268    fn cursor_at(
269        &self,
270        _local_x: f32,
271        _local_y: f32,
272        _width: f32,
273        _scroll_cursor: usize,
274    ) -> Option<usize> {
275        None
276    }
277
278    /// SingleChildScrollView metrics of a **multi-line** field, for a widget width and a cursor:
279    /// `(content height, visible box height, caret top, caret height)`, in content
280    /// space (px). The shell uses them to register the scrollable region and to keep
281    /// the caret in view. `None` otherwise.
282    fn text_metrics(&self, _width: f32, _cursor: usize) -> Option<(f32, f32, f32, f32)> {
283        None
284    }
285
286    /// Frame (input box) of a **multi-line** field within its `rect` — the area where
287    /// the text scrolls, below the label. Used to place the scrollbar and the
288    /// scrollable region exactly on the box. `None` otherwise.
289    fn text_viewport(&self, _rect: crate::Rect) -> Option<crate::Rect> {
290        None
291    }
292
293    /// Moves the caret vertically in a multi-line field and returns
294    /// `(new index, visual column used)`.
295    ///
296    /// - `down`: down (`true`) or up. `page`: jump by a **page** (the visible
297    ///   height) rather than by a **line**.
298    /// - `goal_x`: remembered target visual column (px) to preserve while crossing
299    ///   shorter lines; `None` = start from the current column. The returned value
300    ///   is the column to remember again for the next jump.
301    /// - **Line**: `None` if already on the first/last line (or not multi-line) —
302    ///   the shell then moves the focus instead.
303    /// - **Page**: clamped to the field (it never leaves it); `None` only when not
304    ///   multi-line.
305    fn caret_vertical(
306        &self,
307        _width: f32,
308        _cursor: usize,
309        _down: bool,
310        _page: bool,
311        _goal_x: Option<f32>,
312    ) -> Option<(usize, f32)> {
313        None
314    }
315
316    /// The currently selected text (for copy/cut).
317    fn selected_text(&self, _edit: &Edit) -> Option<String> {
318        None
319    }
320
321    /// The field's **whole** value, if this widget is a text field — to give the
322    /// IME its input context (suggestions). `None` otherwise.
323    fn text_value(&self) -> Option<&str> {
324        None
325    }
326
327    /// The message that puts `value` in this field: the one typing would have produced,
328    /// for a value the **framework** restores rather than the user typing it.
329    ///
330    /// Undo needs it and nothing else does. The value is the application's — a field owns
331    /// its caret and not its text — so an undo cannot reach in and set what is on screen;
332    /// it has to go back through a message like any other edit, or the next frame would
333    /// paint the value the application still holds.
334    fn replace_value(&self, _value: String) -> Option<Msg> {
335        None
336    }
337
338    /// Range `(start, end)` of the word around the given index (for double-click).
339    fn word_at(&self, _index: usize) -> Option<(usize, usize)> {
340        None
341    }
342
343    /// The two handles of the selection in `edit`, start then end, for a field `width`
344    /// wide whose content is scrolled down by `scroll_y` — where they are painted, and
345    /// so where a finger takes them. `None` when there is no selection, or this is not
346    /// a text field.
347    fn selection_handles(
348        &self,
349        _width: f32,
350        _edit: &Edit,
351        _scroll_y: f32,
352    ) -> Option<[crate::SelectionHandle; 2]> {
353        None
354    }
355
356    /// Keystrokes this subtree binds to **intents** — see [`crate::Shortcuts`].
357    fn shortcut_bindings(&self) -> &[(crate::shortcuts::KeyStroke, crate::shortcuts::Intent)] {
358        &[]
359    }
360
361    /// Keystrokes this subtree binds **straight to messages** — see
362    /// [`crate::CallbackShortcuts`].
363    fn shortcut_callbacks(&self) -> &[(crate::shortcuts::KeyStroke, Msg)] {
364        &[]
365    }
366
367    /// Intents this subtree **answers** — see [`crate::Actions`].
368    fn action_bindings(&self) -> &[(crate::shortcuts::Intent, Msg)] {
369        &[]
370    }
371
372    /// Intents this subtree **watches** without answering — see
373    /// [`crate::ActionListener`].
374    fn action_listeners(&self) -> &[(crate::shortcuts::Intent, Msg)] {
375        &[]
376    }
377
378    /// Every keystroke reaching this subtree, handed to a closure — see
379    /// [`crate::KeyboardListener`]. `None` (the default) is not a listener.
380    #[allow(clippy::type_complexity)]
381    fn on_keystroke(
382        &self,
383    ) -> Option<std::rc::Rc<dyn Fn(crate::shortcuts::KeyStroke) -> Option<Msg>>> {
384        None
385    }
386
387    /// If `true`, the widget can take keyboard focus (click or Tab).
388    fn focusable(&self) -> bool {
389        false
390    }
391
392    /// If `false`, **nothing inside this subtree** can take focus — the reference's
393    /// `ExcludeFocus`. A dimmed panel behind a sheet is still drawn and still measured;
394    /// it simply stops being somewhere Tab can land.
395    fn descendants_focusable(&self) -> bool {
396        true
397    }
398
399    /// If `true`, this subtree's focus stops are **skipped by Tab** while remaining
400    /// focusable by a click — the reference's `ExcludeFocusTraversal`. The two are
401    /// separate questions: a toolbar button may be reachable with the pointer and still
402    /// not belong in the keyboard's order.
403    fn focus_skip_traversal(&self) -> bool {
404        false
405    }
406
407    /// A **traversal order** for this subtree's focus stops, smallest first — the
408    /// reference's `NumericFocusOrder`. `None` leaves them in tree order, which is where
409    /// everything sits until someone says otherwise.
410    fn focus_order(&self) -> Option<f32> {
411        None
412    }
413
414    /// If `true`, this subtree is a **traversal group**: an order set inside it is
415    /// resolved among its own members and nowhere else, so a reordered dialog does not
416    /// reshuffle the page behind it.
417    fn focus_group(&self) -> bool {
418        false
419    }
420
421    /// What this field is **for**, so the platform can fill it in — see
422    /// [`AutofillHint`](crate::AutofillHint). Empty (the default) is a field that takes
423    /// no part in autofill at all.
424    ///
425    /// A list, because a field can legitimately be more than one thing: a sign-in box
426    /// taking an email address is the username *and* the email.
427    fn autofill_hints(&self) -> &[crate::AutofillHint] {
428        &[]
429    }
430
431    /// If `true`, this subtree's fields are **one form** — the reference's
432    /// `AutofillGroup`. A service shown a password with no username beside it has
433    /// nothing to save the pair under.
434    fn autofill_group(&self) -> bool {
435        false
436    }
437
438    /// If `true`, the widget draws its focus indicator **itself** (the driver then
439    /// does not stroke the generic ring). E.g. `TextField`.
440    fn draws_own_focus(&self) -> bool {
441        false
442    }
443
444    /// If `true`, the widget responds to pointer dragging (sliders, handles).
445    fn draggable(&self) -> bool {
446        false
447    }
448
449    /// Message produced while dragging, `fraction` being the relative horizontal
450    /// position (`0.0..=1.0`) within the widget's bounds.
451    fn on_drag(&self, _fraction: f32) -> Option<Msg> {
452        None
453    }
454
455    /// Message produced when a value drag **begins** — on the press, before the
456    /// first [`on_drag`](Self::on_drag).
457    ///
458    /// With [`on_drag_end`](Self::on_drag_end) it brackets the stream: `on_drag` fires
459    /// on every pixel of the movement, and an application that saves to disk, seeks a
460    /// video or asks the network on each of those does it sixty times a second. The
461    /// bracket is what lets it do the cheap thing while the finger is down and the
462    /// expensive one when it lifts — and without an end there is no moment at which
463    /// to do it at all.
464    ///
465    /// Not to be confused with [`on_dropped`](Self::on_dropped), which belongs to
466    /// drag-and-**drop**: that one moves a thing, this one changes a number.
467    fn on_drag_start(&self, _fraction: f32) -> Option<Msg> {
468        None
469    }
470
471    /// Message produced when a value drag **ends** — on the release, with the
472    /// fraction the pointer finished on.
473    ///
474    /// See [`on_drag_start`](Self::on_drag_start).
475    fn on_drag_end(&self, _fraction: f32) -> Option<Msg> {
476        None
477    }
478
479    /// Message produced by a horizontal drag expressed as a **delta**: `dx` is the
480    /// movement (logical px) since the last event. For handles that **accumulate**
481    /// (column resizing), unlike [`on_drag`](Self::on_drag) (an absolute fraction,
482    /// e.g. a slider). The shell tries it **before** `on_drag`; a widget implements
483    /// only one of the two.
484    fn on_drag_delta(&self, _dx: f32) -> Option<Msg> {
485        None
486    }
487
488    /// If this widget is a **shared element**, its tag. Two heroes with the same tag on
489    /// the two sides of a route transition are one thing in two places.
490    /// See [`crate::Hero`].
491    fn hero_tag(&self) -> Option<u64> {
492        None
493    }
494
495    /// If this widget can be **picked up** and dropped elsewhere, what it carries.
496    /// See [`crate::Draggable`].
497    fn drag_payload(&self) -> Option<u64> {
498        None
499    }
500
501    /// Does this item lift on a **long press** rather than on the first movement?
502    /// The answer inside a scrollable, where a plain drag belongs to the scroll.
503    ///
504    /// It is asked of both kinds of lift — a [`crate::Draggable`] carrying a payload, and a
505    /// [`crate::ReorderableList`] row carrying itself — because the question is the same
506    /// one: a list that stops scrolling is a worse bug than an item that does not move.
507    fn drag_needs_long_press(&self) -> bool {
508        false
509    }
510
511    /// How solid the item left behind looks while a copy of it is being dragged.
512    fn drag_ghost_opacity(&self) -> f32 {
513        1.0
514    }
515
516    /// Message sent when a drag of this item ends, `true` if a target took it.
517    fn on_dropped(&self, _accepted: bool) -> Option<Msg> {
518        None
519    }
520
521    /// Is this widget a **drop target**? See [`crate::DragTarget`].
522    fn drop_zone(&self) -> bool {
523        false
524    }
525
526    /// Would this target take `payload`? Only asked of a drop target.
527    fn accepts_drag(&self, _payload: u64) -> bool {
528        true
529    }
530
531    /// Message sent when an accepted item is dropped on this target.
532    fn on_drop(&self, _payload: u64) -> Option<Msg> {
533        None
534    }
535
536    /// If this widget is a **reorderable header**, its column index. The shell uses
537    /// it to identify the **source** column (on press) and the **target** column
538    /// (under the pointer on release) of a reordering drag.
539    fn reorder_index(&self) -> Option<usize> {
540        None
541    }
542
543    /// Message emitted when this header (the source) is **dropped** on column `to`.
544    /// The widget knows its own index and the `on_reorder(from, to)` callback.
545    fn on_reorder(&self, _to: usize) -> Option<Msg> {
546        None
547    }
548
549    /// Movement **axis** of this reorderable (default [`ReorderAxis::Horizontal`]): the shell
550    /// orients the drag preview (ghost + insertion indicator) accordingly. `Kanban` cards
551    /// return [`ReorderAxis::Vertical`].
552    fn reorder_axis(&self) -> ReorderAxis {
553        ReorderAxis::Horizontal
554    }
555
556    /// Is a **horizontal** reorderable dropped *between* its neighbours, like a list's row,
557    /// rather than *into the place* of the one under the pointer, like a table's column?
558    /// `false` by default, which is the table.
559    ///
560    /// The two are different gestures, not one gesture on two axes. A column follows the
561    /// pointer with a continuous slide and takes the index of the column it lands on. A row
562    /// is inserted before or after the slot it is over — whichever half the pointer is in —
563    /// with an insertion line, a gap that opens there, and the nearest slot of its own list
564    /// when the pointer is over none. A widget that answers `true` gets the second.
565    ///
566    /// Only asked of a horizontal reorderable: every vertical one is inserted between its
567    /// neighbours already, and answering here changes nothing for it.
568    fn reorder_inserts(&self) -> bool {
569        false
570    }
571
572    /// Can this reorderable be **picked up** as a drag source? `true` by default for every
573    /// reorderable. A **target-only** slot — the drop zone at the end of a Kanban column —
574    /// returns `false`: a card can be **dropped** there, not **lifted** from it (otherwise the
575    /// drag would raise an empty ghost that moves nothing).
576    fn reorder_draggable(&self) -> bool {
577        true
578    }
579
580    /// Can this reorderable be **dropped onto**? `true` by default, and the mirror image of
581    /// [`reorder_draggable`](Self::reorder_draggable): a **source-only** grip — a list row's
582    /// drag handle — returns `false`.
583    ///
584    /// A handle is a small box inside a much larger row, and the drop is aimed at whatever
585    /// is topmost under the pointer. Without this, carrying a row over another row's handle
586    /// would aim at the handle: the insertion line would be drawn across the grip instead of
587    /// across the row, which is a promise about where the row is going that is not true.
588    fn reorder_droppable(&self) -> bool {
589        true
590    }
591
592    /// What to **say** to a screen reader once this reorderable has been moved to `to` — the
593    /// spoken counterpart of the ghost, for someone who cannot see it land.
594    ///
595    /// `None` leaves the shell its own wording, which can only speak of the axis: the index
596    /// a `Kanban` card is dropped at is a flat `column × stride + position` that means
597    /// nothing read out loud. A widget whose index **is** a position says so itself.
598    fn reorder_announcement(&self, _to: usize) -> Option<String> {
599        None
600    }
601
602    /// Text to **announce** to the screen reader when this widget is **activated** (mouse
603    /// click or Enter/Space) — a live region reads it out loud. Describes the effect the
604    /// activation **produced** ("Sorted by Name ascending", "All rows selected"), for the
605    /// blind user who cannot perceive the visual change. `None` = nothing to announce
606    /// (the default).
607    fn announce(&self) -> Option<String> {
608        None
609    }
610
611    /// If `true`, the widget is a **stack**: its children are superimposed layers
612    /// (the same box), rendered in order (the last one on top).
613    fn stack(&self) -> bool {
614        false
615    }
616
617    /// If `true`, the widget animates **continuously** (driven by time, not by a
618    /// target): the framework keeps redrawing. E.g. `CircularProgressIndicator`.
619    fn continuous(&self) -> bool {
620        false
621    }
622
623    /// If `true`, this widget is a **repaint boundary**: its subtree is cached
624    /// (primitives + interaction maps) and **reused as is** as long as its geometry
625    /// and the interaction state of its descendants do not change — a widget
626    /// animating elsewhere no longer forces it to repaint.
627    /// See [`crate::Container::repaint_boundary`] and `paintcache.rs`.
628    fn repaint_boundary(&self) -> bool {
629        false
630    }
631
632    /// If the widget is a scrollable container, returns its content.
633    fn scroll_content(&self) -> Option<&dyn Widget<Msg>> {
634        None
635    }
636
637    /// If the widget is a **virtualised list**, returns its description (item count,
638    /// height, factory). Only the visible items are built.
639    fn virtual_list(
640        &self,
641        _viewport: frus_core::Size,
642    ) -> Option<crate::list::VirtualList<'_, Msg>> {
643        None
644    }
645
646    /// If the widget is a **paged view**, returns its description (page count,
647    /// axis, factory). Like a virtualised list, only the visible pages are built.
648    fn page_view(&self) -> Option<crate::pageview::PagedView<'_, Msg>> {
649        None
650    }
651
652    /// Message sent by a paged view when the page on screen changes.
653    fn on_page_changed(&self, _page: usize) -> Option<Msg> {
654        None
655    }
656
657    /// Message sent by a **scroll region** when its offset changes — the reading half
658    /// of [`crate::ScrollPosition`].
659    ///
660    /// Silent by default, and that is the answer to what it costs: a region nobody is
661    /// listening to reports nothing, so a fling over an ordinary list is exactly as
662    /// cheap as it was. A region somebody *is* listening to sends a message per frame
663    /// while it moves, because a bar that fades in as the page goes down needs every
664    /// frame of it — and a region that only wants to know when the end is near says so
665    /// through [`Widget::scroll_grain`] rather than by being reported less honestly.
666    fn on_scroll(&self, _position: crate::scrollposition::ScrollPosition) -> Option<Msg> {
667        None
668    }
669
670    /// How far this region must move before it says so again, in pixels; `0` — the
671    /// default — reports **every** change.
672    ///
673    /// A grain suppresses the reports in between, never the last one: a region that
674    /// comes to rest anywhere other than where it was last reported reports that,
675    /// whatever the grain. Otherwise a coarse grain would leave the application
676    /// believing a list was at 1 200 when it settled at 1 247, which is a worse answer
677    /// than a slower one.
678    fn scroll_grain(&self) -> f32 {
679        0.0
680    }
681
682    /// If the widget takes one axis from its content's **preferred** size, returns
683    /// that axis and the step its measurement is rounded up to. See
684    /// [`crate::Intrinsic`].
685    fn intrinsic(&self) -> Option<(crate::constraints::IntrinsicAxis, Option<f32>)> {
686        None
687    }
688
689    /// If the widget lays its child out to constraints of **its own**, which the
690    /// child may exceed, returns them. See [`crate::OverflowBox`].
691    fn overflow_box(&self) -> Option<crate::constraints::Overflow> {
692        None
693    }
694
695    /// The box this widget **gives its child** as a function of the box it was offered,
696    /// with the child laid out in it separately and the box then sized to what came
697    /// back. `None` — the default — means the child shares this node's layout, as
698    /// everything ordinary does. See [`crate::ConstraintsTransformBox`].
699    fn constraints_transform(&self) -> Option<crate::constraints::ConstraintsTransform> {
700        None
701    }
702
703    /// If the widget builds its content **from its actual box**, returns the
704    /// `size → widget` factory. The content is built on the fly: no retained state
705    /// and no overlay (like a virtualised list item).
706    fn layout_builder(&self) -> Option<&dyn Fn(Size) -> Box<dyn Widget<Msg>>> {
707        None
708    }
709
710    /// If the widget draws something **over its scroll region**, returns the
711    /// `offset → overlay` factory. See [`crate::ScrollOverlay`].
712    ///
713    /// The region is this widget's first child, so the offset the walk hands over is its
714    /// own child's and nothing has to be named. Like a `layout_builder`'s content, the
715    /// overlay is built on the fly and has no retained state.
716    fn scroll_overlay(&self) -> Option<&crate::scrolloverlay::OverlayBuilder<Msg>> {
717        None
718    }
719
720    /// SingleChildScrollView axis (or axes), for a scrollable container.
721    fn scroll_axis(&self) -> crate::scroll::Axis {
722        crate::scroll::Axis::Vertical
723    }
724
725    /// The edge and fling behaviour of a scrollable container, when this widget
726    /// wants one in particular. `None` — the usual answer — leaves the choice to
727    /// the application, which defaults to what the platform does.
728    fn scroll_physics(&self) -> Option<crate::physics::ScrollPhysics> {
729        None
730    }
731
732    /// **Whether this area draws a scrollbar**, when it wants its own answer rather than
733    /// the application's. `None` — the default — follows the application, which follows
734    /// the platform. See [`crate::Scrollbars`].
735    fn scrollbars(&self) -> Option<crate::physics::Scrollbars> {
736        None
737    }
738
739    /// **Keep this area's scrollbar on screen**, instead of letting it fade away when
740    /// the area stops moving (`scrollbar.dart:214`).
741    ///
742    /// `None` — the default — lets it fade, which is what a bar over content should do.
743    /// `Some(true)` pins it: for an area whose content is not obviously scrollable, or
744    /// one a reader is meant to be able to aim at without scrolling first.
745    fn thumb_visibility(&self) -> Option<bool> {
746        None
747    }
748
749    /// What the **software keyboard** should be, when this widget is the focused
750    /// editable one.
751    ///
752    /// Only ever asked of the field that has focus — the platform layer finds it the
753    /// same way it finds the caret — so a widget that is not editable never has to
754    /// answer, and the default is the ordinary text keyboard with a *Done* key.
755    ///
756    /// See [`crate::ime`] for what the two halves mean and why the mapping to the
757    /// platform's numbers is tested rather than trusted.
758    fn ime(&self) -> crate::ime::Ime {
759        crate::ime::Ime::default()
760    }
761
762    /// If the widget is a portal, returns its floating content and its placement.
763    fn overlay(&self) -> Option<(&dyn Widget<Msg>, Placement)> {
764        None
765    }
766
767    /// Message emitted when the scrim of a modal is clicked (dismissal), if any.
768    fn overlay_dismiss(&self) -> Option<Msg> {
769        None
770    }
771
772    /// The colour of the scrim behind this widget's **modal** overlay, when it wants one
773    /// in particular. `None` — the usual answer — leaves it to the scheme's `scrim`
774    /// role at the framework's own opacity.
775    ///
776    /// The alpha is the caller's: a scrim is the one colour whose *transparency* is the
777    /// whole point, so a fully opaque value here means an opaque scrim, and
778    /// [`Color::TRANSPARENT`](frus_core::Color::TRANSPARENT) means none at all — an
779    /// overlay that darkens nothing, which the reference reaches by the same route.
780    fn overlay_scrim(&self, _theme: &crate::theme::Theme) -> Option<frus_core::Color> {
781        None
782    }
783
784    /// If `true`, this widget's **anchored** overlay (a menu…) **traps focus**: Tab and the
785    /// arrow keys cycle within its focusables while it is open (the keyboard pattern of menus).
786    /// Modal (scrimmed) overlays already trap by default; a tooltip or an autocomplete list
787    /// (focus stays on the field) do **not**. Default: `false`.
788    fn overlay_traps_focus(&self) -> bool {
789        false
790    }
791
792    /// Target of the widget's own animated value (e.g. `1.0` for a switch that is on,
793    /// `0.0` for off). The runtime drives the retained value towards this target and
794    /// hands it back through `Status::value`. `None` = no animated value.
795    fn anim_target(&self) -> Option<f32> {
796        None
797    }
798
799    /// **Target transform** of an animated one (`Transform::animated`): the runtime
800    /// tweens the scales and the turn through `anim_duration`/`anim_curve` and hands the
801    /// interpolated value back through `Runtime::anim_transform`, which the paint walk
802    /// reads in place of the static `transform_scale`/`transform_rotate`. `None` = the
803    /// transform does not move.
804    ///
805    /// The **pivot** is not part of it: see
806    /// [`TransformValues`](crate::runtime::TransformValues).
807    fn anim_transform(&self) -> Option<crate::runtime::TransformValues> {
808        None
809    }
810
811    /// Duration (seconds) of the animated value's transition (`anim_target`).
812    /// Default: the framework's standard duration.
813    fn anim_duration(&self) -> f32 {
814        crate::runtime::ANIM_DURATION
815    }
816
817    /// Easing curve of the animated value's transition (`anim_target`).
818    /// Default: linear.
819    fn anim_curve(&self) -> frus_core::Curve {
820        frus_core::Curve::Linear
821    }
822
823    /// If the widget is an **opacity group**, returns the (target) opacity `[0,1]`
824    /// applied to its whole subtree **as one**: the paint walk wraps its primitives
825    /// in a composited layer at that opacity — no double-blending where they
826    /// overlap. `None` = not a group. Combined with `anim_target`, the opacity
827    /// **animates** (a group fade).
828    fn opacity_group(&self) -> Option<f32> {
829        None
830    }
831
832    /// **Target** background colour of an animated background
833    /// (`Container::animated_color`): the runtime tweens it (through
834    /// `anim_duration`/`anim_curve`) and hands the interpolated value back in
835    /// `Status::anim_color`. `None` = no animated colour.
836    fn anim_color(&self) -> Option<frus_core::Color> {
837        None
838    }
839
840    /// **Target** size of an animated size (`Container::animated_size`): the runtime
841    /// tweens it (through `anim_duration`/`anim_curve`) and the interpolated size is
842    /// injected **at layout** (see `effective_style`). `None` = fixed size.
843    fn anim_size(&self) -> Option<Size> {
844        None
845    }
846
847    /// **Target** corner radius of an animated radius (`Container::animated_radius`):
848    /// the runtime tweens it and hands the interpolated value back in
849    /// `Status::anim_radius`. `None` = fixed radius.
850    fn anim_radius(&self) -> Option<frus_core::BorderRadius> {
851        None
852    }
853
854    /// **Target** padding of an animated padding (`Container::animated_padding`):
855    /// the runtime tweens it and the interpolated padding is injected **at layout**
856    /// (see `effective_style`). `None` = fixed padding.
857    fn anim_padding(&self) -> Option<frus_core::Insets> {
858        None
859    }
860
861    /// The pair of fractions this node's **offset rule** is made of, animated: an
862    /// alignment's two fractions, or a slide's. `None` — the default — leaves the rule
863    /// reading the widget's own numbers.
864    ///
865    /// One quantity serves both rules because a node has one of them. See
866    /// [`crate::AnimatedAlign`] and [`crate::AnimatedSlide`], each of which gives the
867    /// rule it animates a node of its own.
868    fn anim_offset(&self) -> Option<(f32, f32)> {
869        None
870    }
871
872    /// **Target pins** of an animated stack layer ([`crate::AnimatedPositioned`]): the
873    /// runtime tweens them and the interpolated pins are read where the stack lays its
874    /// layers out. `None` — the default — leaves [`Widget::positioned`] alone.
875    ///
876    /// A pin that is **unset does not animate**: `None` on an edge is not nought there,
877    /// it is a box not pinned on that side at all, and moving between the two would be
878    /// interpolating between two arrangements rather than two values.
879    fn anim_pins(&self) -> Option<crate::positioned::Positioning> {
880        None
881    }
882
883    /// **Target fractions** of an animated share of the parent
884    /// (`FractionallySizedBox::animated`), as `(width factor, height factor)`: the
885    /// runtime tweens them and the interpolated pair is injected **at layout** (see
886    /// `effective_style`), like the size and the padding. `None` = fixed factors.
887    ///
888    /// An axis whose factor is unset follows its content, and the same rule applies:
889    /// it does not travel to or from a factor, it changes what the axis is doing.
890    fn anim_fractions(&self) -> Option<(Option<f32>, Option<f32>)> {
891        None
892    }
893
894    /// **Target text style** an animated subtree is heading for
895    /// (`AnimatedDefaultTextStyle`). `None` = the subtree inherits whatever it inherits.
896    ///
897    /// The odd one out of the animated family: what the runtime tweens here is not this
898    /// node's box or its paint but **the theme everything below it reads**, so the value
899    /// is consumed by the theme swap rather than by the node. That swap happens at four
900    /// points of the walk — the layout pass, the relayout fingerprint, the paint, and
901    /// [`crate::build_deferred`] — and they all go through `crate::ui::scoped_theme`
902    /// so that they cannot answer differently.
903    fn anim_text_style(&self) -> Option<frus_core::TextStyle> {
904        None
905    }
906
907    /// **Alignment** of the single child within the box: the walk offsets the child
908    /// through the free space according to the alignment's fractions, resolved
909    /// against the reading direction (physical or directional — see
910    /// [`frus_core::AlignmentGeometry`]). Being continuous, a `Tween<Alignment>`
911    /// read in `view()` slides the child. `None` = default flex placement.
912    fn alignment_geometry(&self) -> Option<frus_core::AlignmentGeometry> {
913        None
914    }
915
916    /// **Paint offset** `(dx, dy)` applied to the widget's whole subtree: the render
917    /// and the hit-test are offset **without touching layout** (siblings do not move,
918    /// the child may overflow its box). Continuous → a `Tween` read in `view()` slides
919    /// the subtree. `None` = no offset. See [`crate::Transform`].
920    fn transform_translate(&self) -> Option<(f32, f32)> {
921        None
922    }
923
924    /// **Paint offset as a fraction of the child's own size** `(fx, fy)`: `(0.5, 0.0)`
925    /// slides the subtree half its own width to the right. Added to
926    /// [`Widget::transform_translate`], and offsetting the render and the hit-test the
927    /// same way, without touching layout. `None` = no offset.
928    ///
929    /// A fraction rather than a number because the number is not known where the widget
930    /// is written: the child's size is decided by the layout, and something that has to
931    /// slide exactly clear of itself — a panel off the edge, a badge half outside its
932    /// anchor — would otherwise have to be told a width it was never given. See
933    /// [`crate::FractionalTranslation`].
934    fn translate_fraction(&self) -> Option<(f32, f32)> {
935        None
936    }
937
938    /// **Paint scaling** `(sx, sy, pivot)` of the whole subtree: the render and the
939    /// hit-test are scaled — per axis — around the `pivot` (a
940    /// [`frus_core::Alignment`] within the box), **without touching layout**. Stays
941    /// axis-aligned (a scaled rect is still a rect). `None` = no scaling.
942    /// See [`crate::Transform`].
943    fn transform_scale(&self) -> Option<(f32, f32, frus_core::Alignment)> {
944        None
945    }
946
947    /// **Paint rotation** `(angle, pivot)` of the whole subtree: the subtree is
948    /// painted rotated by `angle` radians (clockwise) around the `pivot` (a
949    /// [`frus_core::Alignment`] within the box), **without touching layout**. The
950    /// render goes through a rotated composited layer; the hit-test counter-rotates
951    /// the point. `None` = no rotation. See [`crate::Transform`].
952    fn transform_rotate(&self) -> Option<(f32, frus_core::Alignment)> {
953        None
954    }
955
956    /// **Shape clip** of the whole subtree: the paint walk wraps its primitives in a
957    /// composited layer whose [`frus_core::ClipShape`] (rounded corners, ellipse)
958    /// modulates the alpha — whatever falls outside the shape is erased, edges
959    /// antialiased. `None` = no shape clip. See [`crate::ClipRRect`],
960    /// [`crate::ClipOval`].
961    fn clip_shape(&self) -> Option<frus_core::ClipShape> {
962        None
963    }
964
965    /// The widget's style **once the theme has had its say** — the layout half of the
966    /// `caller ?? theme ?? framework` chain.
967    ///
968    /// Defaults to [`Widget::style`], which is what almost every widget wants: only the
969    /// ones whose *size or spacing* a theme can set need to override this. It exists
970    /// because `style` has no theme and cannot be given one without touching every
971    /// implementation; a theme that could only reach `paint` would be able to recolour a
972    /// divider but not make one thin, which is the setting an application actually asks
973    /// for (milestone 309).
974    ///
975    /// A **transparent wrapper must forward this** alongside `style`, or its child's
976    /// themed size is silently dropped for the unthemed one.
977    fn style_themed(&self, _theme: &Theme) -> Style {
978        self.style()
979    }
980
981    /// The theme this widget imposes on **itself and its subtree**, given the one it
982    /// inherits. `None` — the default — means "whatever came down from above", which is
983    /// what every widget but [`crate::Themed`] answers.
984    ///
985    /// This is the third and last thing a theme needed to be usable: milestone 309 gave
986    /// it per-widget defaults, and this makes those defaults *scoped*. A dark panel on a
987    /// light page is one theme swapped for a subtree, not a colour written out by hand at
988    /// every call site inside it.
989    ///
990    /// It is honoured by **layout as well as paint** — the walk and the layout pass swap
991    /// the ambient theme on the way down and restore it on the way out — so a subtree
992    /// theme can change a divider's height, not only its colour. A deferred overlay
993    /// (a dialog, a drawer, a tooltip) is painted long after the walk has left the node
994    /// that declared it, so it **carries the theme it was declared under** rather than
995    /// the root's.
996    ///
997    /// Boxed because a `Theme` is a page and a half of tokens and this is asked of
998    /// **every node, every frame**: an `Option<Box<_>>` costs a word on the stack of a
999    /// recursion as deep as the tree, and the allocation happens only where a subtree
1000    /// actually claims a theme.
1001    fn theme_override(&self, _inherited: &Theme) -> Option<Box<Theme>> {
1002        None
1003    }
1004
1005    /// The **surface** this widget imposes on itself and its subtree, given the one it
1006    /// inherits. `None` — the default — means "whatever came down from above", which is
1007    /// what every widget but [`MediaScope`](crate::MediaScope) answers.
1008    ///
1009    /// The counterpart of [`Self::theme_override`], and it exists for the same reason one
1010    /// milestone later: a surface could until now only be narrowed **where a widget is
1011    /// constructed** (`SafeArea::build`), and the widget that knows what to narrow is often
1012    /// not the one doing the constructing. A shell hands its app bar's slot the description
1013    /// that slot should believe in; the bar then decides for itself whether to consume the
1014    /// status bar, which is how the reference splits that job across two widgets.
1015    ///
1016    /// Applied by the layout walk on the way down and held for the subtree, so anything
1017    /// reading [`MediaQuery::of`](crate::MediaQuery::of) below this node sees it — including
1018    /// a subtree deferred until [`Self::build_themed`], which runs after the swap.
1019    /// [`crate::build_deferred`], the relayout fingerprint and the paint walk make the same
1020    /// swap; the four staying in step is what keeps the cache and the picture honest.
1021    fn media_override(&self, _inherited: crate::MediaQuery) -> Option<crate::MediaQuery> {
1022        None
1023    }
1024
1025    /// The **shell** this widget imposes on its subtree: what a
1026    /// [`Scaffold`](crate::Scaffold) knows about itself and its slots do not.
1027    ///
1028    /// The third of the inherited things, after the theme and the surface, and it exists
1029    /// for the same reason as the second: a slot is handed to a shell **already built**, so
1030    /// the widget that knows there is a drawer is never the one that has to draw the button
1031    /// for it. The reference reads it from the context (`Scaffold.of`), which is how a bar
1032    /// with no `leading` grows a menu button on a screen that has a menu and stays empty on
1033    /// one that does not (`app_bar.dart:1010`).
1034    ///
1035    /// `None` — the default — means "whatever came down from above", which is what every
1036    /// widget but [`ScaffoldScope`](crate::ScaffoldScope) answers. Applied by the same four
1037    /// walks as [`Self::media_override`], and for the same reason: an
1038    /// [`AppBar`](crate::AppBar) is composed in [`Self::build_themed`], which runs after the
1039    /// swap, and the relayout fingerprint has to see what the composition saw.
1040    fn scaffold_override(&self) -> Option<crate::ScaffoldInfo> {
1041        None
1042    }
1043
1044    /// Builds this widget's subtree **from the ambient theme**, for the widgets that
1045    /// defer that decision — see [`ThemeBuilder`](crate::ThemeBuilder). Does nothing by
1046    /// default, which is what all but a handful of widgets want.
1047    ///
1048    /// [`Self::style_themed`] and [`Self::paint`] let a theme decide how a widget
1049    /// **looks**. This is for the questions a theme answers *earlier* than that: whether
1050    /// an application bar centres its title decides which children exist and in what
1051    /// order, and by the time anything is being painted the composition has already been
1052    /// made. A widget assembled by a builder — `AppBar::new().build()` — never sees a
1053    /// theme at all.
1054    ///
1055    /// Called by the layout pass on the way down, **before** [`Self::children`] is read,
1056    /// under the theme of the subtree the node sits in. It takes `&self` like every other
1057    /// hook, so an implementor needs interior mutability; that is safe here because a
1058    /// widget tree is rebuilt from `view` rather than mutated, so "once per instance" and
1059    /// "once per frame" are the same thing.
1060    fn build_themed(&self, _theme: &Theme) {}
1061
1062    /// [`Self::build_themed`], for the few widgets that also need **who they are** and
1063    /// **what the frame remembers** to compose their subtree. An
1064    /// [`AnimatedSwitcher`](crate::AnimatedSwitcher) keeps what it is letting go of in the
1065    /// runtime, under its own identity, and that is reachable nowhere else before its
1066    /// children are read.
1067    ///
1068    /// The walks call this one, and its default is `build_themed`, so a deferred widget that
1069    /// needs neither keeps implementing only that. A **transparent** wrapper must forward it
1070    /// with the identity untouched — it has none of its own — or the widget inside is built
1071    /// through `build_themed` and never learns where it is.
1072    fn build_in(
1073        &self,
1074        _id: crate::interaction::WidgetId,
1075        _runtime: &crate::runtime::Runtime,
1076        theme: &Theme,
1077    ) {
1078        self.build_themed(theme)
1079    }
1080
1081    /// **Builds what this node stands for**, before anything else is asked of it.
1082    ///
1083    /// A [`Component`](crate::Component) is a widget that is built into another, and what it
1084    /// is built into decides everything the walk asks next — its theme scope, its surface,
1085    /// its children. So the walks call this first, on the way down, before those questions
1086    /// and before [`Self::build_in`]; by the time they are asked, the node answers as what it
1087    /// built. Called under the theme of the enclosing scope, since the scope a node introduces
1088    /// is not known until it is built.
1089    ///
1090    /// Idempotent, and the default does nothing. A **transparent** wrapper must forward it
1091    /// with the identity untouched, for the same reason as `build_in`.
1092    fn expand(
1093        &self,
1094        _id: crate::interaction::WidgetId,
1095        _runtime: &crate::runtime::Runtime,
1096        _theme: &Theme,
1097    ) {
1098    }
1099
1100    /// Whether this node is an [`AnimatedSwitcher`](crate::AnimatedSwitcher). An identity
1101    /// is a position, so a switcher and the widget that comes to stand where it stood have
1102    /// the same one: this is how the runtime tells the switcher still being there from its
1103    /// having gone, and forgets what it kept for it.
1104    fn switches(&self) -> bool {
1105        false
1106    }
1107
1108    /// What the system bars over this widget should look like — see
1109    /// [`AnnotatedRegion`](crate::AnnotatedRegion). `None` for every widget but that one; a
1110    /// transparent wrapper forwards it, or a keyed region would say nothing.
1111    fn system_ui_style(&self) -> Option<crate::SystemUiOverlayStyle> {
1112        None
1113    }
1114
1115    /// If the widget takes **ink** — the splash a tap leaves on a material surface —
1116    /// the shape and colour to splash in. `None` = no ink, which is the default: a
1117    /// widget has to ask.
1118    ///
1119    /// The walk paints the ripples the runtime holds for this widget directly over
1120    /// this widget's own `paint` and **under its children**, which is where a material
1121    /// surface puts them. A widget that draws its own content (a [`crate::Button`]
1122    /// paints its label itself) therefore gets the ink *over* that content — at the
1123    /// splash's alpha, a tint rather than a veil. See [`crate::InkWell`].
1124    fn ink(&self, _theme: &Theme) -> Option<crate::ink::InkStyle> {
1125        None
1126    }
1127
1128    /// A decoration painted **over this widget's children** rather than behind them:
1129    /// the reference's `foregroundDecoration`.
1130    ///
1131    /// It is the one place in the walk where a widget paints after its own subtree,
1132    /// and it exists because there is no other way to say it. A border over a
1133    /// photograph, a wash across a tile that is disabled, a sheen over a card — every
1134    /// one of them is a decoration whose whole point is that the content does not
1135    /// cover it, and behind the content is exactly where [`Widget::paint`] puts one.
1136    ///
1137    /// The box is this widget's own, the same one `paint` is given. Inside any layer
1138    /// this widget asks for: an opacity group fades it with everything else, a
1139    /// transform carries it, and a shape clip holds it to the shape — which for a
1140    /// decoration wearing that same radius changes nothing.
1141    ///
1142    /// `None` is the default, and costs the walk one `Option` check per node.
1143    fn foreground(&self, _theme: &Theme) -> Option<frus_core::BoxDecoration> {
1144        None
1145    }
1146
1147    /// The **pixel effects** this widget applies to its whole subtree: a blur, a
1148    /// colour transform, a mask, or a filter over what is painted underneath. The
1149    /// paint walk drains the subtree into a composited layer and hands the filter to
1150    /// the renderer, exactly as it does for an opacity group or a shape clip.
1151    ///
1152    /// The [`FilterContext`] carries what only the walk knows — where the box ended
1153    /// up, and which backdrop group encloses it. A widget that needs neither ignores
1154    /// it.
1155    ///
1156    /// `None` — the default — means no layer and no cost. See [`crate::ColorFiltered`],
1157    /// [`crate::ImageFiltered`], [`crate::ShaderMask`], [`crate::BackdropFilter`].
1158    fn layer_filter(&self, _cx: FilterContext) -> Option<frus_core::LayerFilter> {
1159        None
1160    }
1161
1162    /// `true` when this widget is a **backdrop group**: the backdrops below it that
1163    /// ask to be shared are filtered once between them. See [`crate::BackdropGroup`].
1164    fn backdrop_group(&self) -> bool {
1165        false
1166    }
1167
1168    /// The widget's own **text baseline**: the distance from the top of its box down
1169    /// to the line its letters sit on. `None` — the default — means this widget has no
1170    /// text of its own, and whatever is inside it answers instead.
1171    ///
1172    /// It is what makes a price and its currency, or a heading and the note beside it,
1173    /// sit on one line rather than merely in one row. See [`crate::Baseline`] and
1174    /// `Align::Baseline`.
1175    fn text_baseline(&self, _theme: &Theme) -> Option<f32> {
1176        None
1177    }
1178
1179    /// `true` when this subtree should be **left out** of a parent's baseline
1180    /// alignment: it has a baseline, and the parent is to pretend it does not. An icon
1181    /// beside a label, where the label is what the row should line up on. See
1182    /// [`crate::IgnoreBaseline`].
1183    fn ignores_baseline(&self) -> bool {
1184        false
1185    }
1186
1187    /// The **axes this widget asks to fill**: on each, it takes the room the parent
1188    /// leaves it rather than shrink-wrapping its children. [`FillAxes::NONE`] means
1189    /// shrink-wrap on both.
1190    ///
1191    /// `MainAxisSize::Max` on a [`crate::Row`] or a [`crate::Column`] is the reason it
1192    /// exists, and there the axis is the widget's own main one; a [`crate::TabBar`] asks
1193    /// for the horizontal one, which is its cross axis; a full-screen shell asks for
1194    /// [`FillAxes::BOTH`].
1195    ///
1196    /// It is a question about the *parent*, which is why it is asked rather than written
1197    /// into the style: filling means growing when the parent runs the same way and
1198    /// stretching when it runs across, and a widget cannot know what it was put inside.
1199    /// The layout walk resolves it, where both are in view. **Declaring `width: 100%`
1200    /// instead does not work** and cannot be made to — see [`FillAxes`].
1201    ///
1202    /// The theme is here for the same reason it is on [`Widget::measure`]: a text asks to
1203    /// fill because it was told to align inside its box, and a subtree can hand that
1204    /// alignment down. A hook blind to the theme would leave the one setting that arrives
1205    /// by inheritance silently doing nothing.
1206    fn fill_axes(&self, _theme: &Theme) -> FillAxes {
1207        FillAxes::NONE
1208    }
1209
1210    /// The width below which this widget must not be squeezed **when its parent runs
1211    /// horizontally** — a line of text that would rather run past the end of a row than
1212    /// be folded into a column of single words. `None` means squeeze freely.
1213    ///
1214    /// It is asked rather than written into the style because the same number means two
1215    /// different things on the two axes. Down a column a box is *handed* a width and a
1216    /// floor would refuse it; along a row a box is *asked* how wide it wants to be, and
1217    /// this is the answer it will not go below. The reference draws the same line: a flex
1218    /// leaves its inflexible children an unbounded main axis and never squeezes them,
1219    /// while across it they take the width they are given.
1220    ///
1221    /// It is handed the theme for the same reason [`Widget::style_themed`] is: the floor
1222    /// is a *measurement*, and a text whose size comes from an inherited style measures
1223    /// differently. A hook that decided a size without seeing the theme would answer for
1224    /// a font nobody is drawing.
1225    fn main_axis_floor(&self, _theme: &Theme) -> Option<f32> {
1226        None
1227    }
1228
1229    /// If this container gives all of its children the **shape of a tile**, the
1230    /// `width / height` ratio to impose on each of them. `None` = each child keeps
1231    /// its own shape.
1232    ///
1233    /// A grid's tiles are the same shape in the reference, and it is the grid that
1234    /// says so — the tile does not know how wide its column came out. Imposed during
1235    /// the walk, like the fill request and the shrink grant, because it needs the
1236    /// children's layout nodes rather than their styles.
1237    fn tile_shape(&self) -> Option<f32> {
1238        None
1239    }
1240
1241    /// If this is a layer **pinned** against its [`crate::Stack`]'s edges
1242    /// ([`crate::Positioned`]), what it pins. `None` = an ordinary layer, sized and
1243    /// placed by the stack's own fit and alignment.
1244    ///
1245    /// Read by the stack rather than written into a style: an offset from an edge is not
1246    /// something the layout engine's box model has a field for, and the number it
1247    /// resolves to depends on how big the stack came out.
1248    fn positioned(&self) -> Option<crate::positioned::Positioning> {
1249        None
1250    }
1251
1252    /// Whether this stack sizes its unpinned layers **loosely** — asking each what it
1253    /// would like to be — rather than handing each of them the whole box.
1254    /// See [`crate::StackFit`]. Meaningless unless [`Widget::stack`] is true.
1255    fn stack_loose(&self) -> bool {
1256        false
1257    }
1258
1259    /// Which layer of this stack is **shown**: the one at that index paints and takes
1260    /// input, and every other one is laid out and then silenced — not drawn, not
1261    /// clickable, not read out. `None`, the default, shows all of them.
1262    ///
1263    /// This is [`crate::IndexedStack`], and it is a question for the walk rather than for
1264    /// the widget: a layer that wrapped itself in something to stay quiet would no longer
1265    /// be laid out the way a bare layer is, which is the one thing an indexed stack
1266    /// promises. Meaningless unless [`Widget::stack`] is true.
1267    fn stack_visible(&self) -> Option<usize> {
1268        None
1269    }
1270
1271    /// The box this widget asks the scroll region around it to **keep in view**, in its
1272    /// own coordinates, with a key naming which box it is.
1273    ///
1274    /// A tab bar wider than its window is what this is for: the eighth tab is off the
1275    /// side, and nothing about selecting it would otherwise bring it back. The reference
1276    /// scrolls its bar to the selected tab, and so does this.
1277    ///
1278    /// The **key** is what makes the region act on a change rather than on every frame.
1279    /// The box moves as the region scrolls, so a region that chased it would pin the
1280    /// content in place and no finger could move it; the key changes only when the widget
1281    /// means a different box.
1282    ///
1283    /// `centre` asks for the box in the middle of the window rather than merely inside
1284    /// it — what a tab bar wants, since a selected tab flush against the edge looks like
1285    /// the end of the row. Clamped either way, so the first tab stays at the start.
1286    fn keep_visible(&self, _size: Size, _theme: &Theme) -> Option<crate::ui::KeepVisible> {
1287        None
1288    }
1289
1290    /// Whether this scrollable runs **from the far end** ([`crate::SingleChildScrollView::reverse`]):
1291    /// the content is anchored to the end of the viewport and offsets are counted from
1292    /// there. Meaningless unless [`Widget::scroll_content`] is `Some`.
1293    fn scroll_reverse(&self) -> bool {
1294        false
1295    }
1296
1297    /// The insets a scrollable area puts **around its content**, inside the viewport.
1298    ///
1299    /// The padding scrolls with the content rather than shrinking the window onto it,
1300    /// which is the reference's `SliverPadding` and the only reading that is any use:
1301    /// room at the end of a list is reachable by scrolling to it, room taken out of the
1302    /// viewport is not. Read by both the scroll branch and the virtualised list.
1303    fn scroll_padding(&self) -> frus_core::Insets {
1304        frus_core::Insets::ZERO
1305    }
1306
1307    /// If the widget positions its child **by the child's baseline** ([`crate::Baseline`]),
1308    /// the distance from the top of this box at which that baseline should land.
1309    /// `None` = not a baseline box.
1310    fn baseline_target(&self) -> Option<f32> {
1311        None
1312    }
1313
1314    /// If the widget clips its child to an **arbitrary path** (`ClipPath`), returns the
1315    /// path in **local coordinates** (origin at the box's top-left corner). The walk
1316    /// offsets it to the screen and wraps it in a layer whose mask (the path) erases
1317    /// the outside. Takes priority over [`Widget::clip_shape`]. `None` = no path clip.
1318    /// See [`crate::ClipPath`].
1319    fn clip_path(&self) -> Option<&frus_core::Path> {
1320        None
1321    }
1322
1323    /// If the widget is a **dismissible item** ([`crate::Dismissible`]), its
1324    /// configuration for this frame. The shell gives a mostly-sideways drag on it to
1325    /// the dismissal and a mostly-up-and-down one to the enclosing scrollable. `None` =
1326    /// not dismissible.
1327    fn dismissible(&self) -> Option<crate::dismiss::DismissSpec> {
1328        None
1329    }
1330
1331    /// The message a dismissed item dispatches, once it has flown out **and** its gap
1332    /// has closed. `None` = the swipe is shown but removes nothing.
1333    fn on_dismissed(&self, _direction: crate::dismiss::DismissDirection) -> Option<Msg> {
1334        None
1335    }
1336
1337    /// If the widget is the moving panel of a [`crate::DraggableScrollableSheet`], its
1338    /// configuration for this frame. The layout makes it as tall as the retained height,
1339    /// and the shell shares a finger on it between the sheet and the scroll areas inside.
1340    /// `None` = not a sheet.
1341    fn sheet(&self) -> Option<&crate::sheet::SheetSpec> {
1342        None
1343    }
1344
1345    /// The message a sheet dispatches once it has been lowered to nothing. `None` = it
1346    /// cannot be dismissed, or says nothing when it is.
1347    fn on_sheet_dismissed(&self) -> Option<Msg> {
1348        None
1349    }
1350
1351    /// If the widget is a **refresh area** ([`crate::RefreshIndicator`]), its configuration for
1352    /// this frame. Any scrollable inside it routes the movement its physics refuses at
1353    /// the top edge into the pull, instead of into the overscroll glow. `None` = not a
1354    /// refresh area.
1355    fn refresh(&self) -> Option<crate::refresh::RefreshSpec> {
1356        None
1357    }
1358
1359    /// The message a refresh area dispatches when an armed pull is released. `None` =
1360    /// the pull is shown but asks for nothing, which is what an area still waiting for
1361    /// its `on_refresh` looks like.
1362    fn on_refresh(&self) -> Option<Msg> {
1363        None
1364    }
1365
1366    /// What the widget **withholds** from the frame on behalf of its whole subtree:
1367    /// input targets, primitives, accessibility nodes. The walk visits the subtree
1368    /// normally and then discards whatever it added to the selected registries, so a
1369    /// target registered deep inside is caught just as surely as one at the top.
1370    /// `None` = nothing withheld (the default). See [`crate::ModalBarrier`],
1371    /// [`crate::IgnorePointer`], [`crate::AbsorbPointer`], [`crate::Visibility`],
1372    /// [`crate::ExcludeSemantics`].
1373    fn barrier(&self) -> Option<crate::barrier::ModalBarrier> {
1374        None
1375    }
1376
1377    /// If the widget is an **interactive viewport** (`InteractiveViewer`), returns its
1378    /// scale bounds `(min, max)`. The paint walk renders its child in a transformed
1379    /// layer (retained scale + translation, clipped to the viewport); the shell routes
1380    /// drag → pan and wheel/pinch → zoom. `None` = not an interactive viewport.
1381    /// See [`crate::InteractiveViewer`].
1382    fn interactive(&self) -> Option<(f32, f32)> {
1383        None
1384    }
1385
1386    /// If the widget **fits** its child to its box (`FittedBox`), returns the
1387    /// [`frus_core::BoxFit`]: the walk measures the child at its natural size, scales
1388    /// it according to the fit and centres it (composited layer, hit-test through
1389    /// `M⁻¹`). `None` = not a fitter. See [`crate::FittedBox`].
1390    fn fitted(&self) -> Option<frus_core::BoxFit> {
1391        None
1392    }
1393
1394    /// If the widget **rotates** its child by quarter turns (`RotatedBox`), returns
1395    /// the number of quarters. Unlike `Transform`, this **affects layout**: the box
1396    /// swaps its dimensions for an odd number. `None` = not a `RotatedBox`.
1397    /// See [`crate::RotatedBox`].
1398    fn rotated_quarter_turns(&self) -> Option<i32> {
1399        None
1400    }
1401
1402    /// If the widget is a screen navigator, returns `(progress, push?)`. Its children
1403    /// (`[screen]` or `[outgoing, incoming]`) are rendered full-window with a sliding
1404    /// transition.
1405    fn navigator(&self) -> Option<(f32, bool)> {
1406        None
1407    }
1408
1409    /// Whether a [`navigator`](Self::navigator) **clips its pages to its own box**.
1410    /// `true`, which is the reference's default (`Clip.hardEdge`) and the only sane one:
1411    /// a screen sliding in comes from outside the box and has to stop at its edge.
1412    ///
1413    /// Consulted only inside the navigator branch of the walk, so it costs nothing for
1414    /// every other widget.
1415    fn navigator_clips(&self) -> bool {
1416        true
1417    }
1418
1419    /// How many of a navigator's first children are **kept but not shown**: the pages under
1420    /// the one on show. They are built, so what their components hold survives, and they are
1421    /// not laid out, drawn or given input. `0`, the default, is a navigator that shows every
1422    /// page it holds.
1423    fn navigator_retained(&self) -> usize {
1424        0
1425    }
1426
1427    /// Message emitted by a **long press** (a press held ~500 ms without movement).
1428    /// The long press *pre-empts* the click: the release that follows does not emit
1429    /// `on_click`.
1430    fn on_long_press(&self) -> Option<Msg> {
1431        None
1432    }
1433
1434    /// Key received while **bubbling leaf→root**: the focused widget gets it first,
1435    /// then each ancestor as long as the response is `Ignored`. (E.g. an `OverlayPortal`
1436    /// consumes `Escape` to close itself.)
1437    fn on_key(&self, _key: &crate::interaction::Key) -> crate::interaction::KeyResponse<Msg> {
1438        crate::interaction::KeyResponse::Ignored
1439    }
1440
1441    /// **Measure under constraints**: for a widget whose size depends on the space
1442    /// offered (a paragraph that wraps…), returns the closure wired into taffy.
1443    /// `None` = size fixed by `style()`. Contract: must be `Some` **if and only if**
1444    /// [`Widget::measure_key`] is.
1445    ///
1446    /// The theme comes in because the measurement has to agree with the paint. A text
1447    /// that takes its size from an inherited style must be *measured* at that size too;
1448    /// measured at one size and drawn at another, every box on the screen is the wrong
1449    /// height at once, and nothing in the picture says which of the two numbers is wrong.
1450    fn measure(&self, _theme: &Theme) -> Option<frus_layout::MeasureFn<'_>> {
1451        None
1452    }
1453
1454    /// Fingerprint of the **content** [`Widget::measure`] depends on (text, style…),
1455    /// mixed into the relayout fingerprint: without it, two different contents with
1456    /// the same style would be conflated by the cache and would keep a stale
1457    /// geometry. Contract: `Some` if and only if `measure()` is.
1458    ///
1459    /// Whatever the theme contributes to the measurement belongs in here as well — a
1460    /// cache key that ignores half of its inputs is a stale layout waiting for the
1461    /// subtree's style to change.
1462    fn measure_key(&self, _theme: &Theme) -> Option<u64> {
1463        None
1464    }
1465}
1466
1467/// **Short** type name: without module path or generic parameters
1468/// (`frus_widgets::text::Text` → `Text`, `Container<Msg>` → `Container`).
1469pub(crate) fn short_type_name<T: ?Sized>() -> &'static str {
1470    let full = std::any::type_name::<T>();
1471    let no_generics = full.split('<').next().unwrap_or(full);
1472    no_generics.rsplit("::").next().unwrap_or(no_generics)
1473}
1474
1475/// Lets an **already boxed** widget be composed where an `impl Widget` is expected
1476/// (e.g. `Flex::child`). Delegates everything to the contained widget.
1477impl<Msg> Widget<Msg> for Box<dyn Widget<Msg>> {
1478    fn style(&self) -> Style {
1479        (**self).style()
1480    }
1481    fn style_themed(&self, theme: &Theme) -> Style {
1482        (**self).style_themed(theme)
1483    }
1484    fn theme_override(&self, inherited: &Theme) -> Option<Box<Theme>> {
1485        (**self).theme_override(inherited)
1486    }
1487    fn media_override(&self, inherited: crate::MediaQuery) -> Option<crate::MediaQuery> {
1488        (**self).media_override(inherited)
1489    }
1490    fn scaffold_override(&self) -> Option<crate::ScaffoldInfo> {
1491        (**self).scaffold_override()
1492    }
1493    fn build_themed(&self, theme: &Theme) {
1494        (**self).build_themed(theme)
1495    }
1496    fn build_in(
1497        &self,
1498        id: crate::interaction::WidgetId,
1499        runtime: &crate::runtime::Runtime,
1500        theme: &Theme,
1501    ) {
1502        (**self).build_in(id, runtime, theme)
1503    }
1504    fn expand(
1505        &self,
1506        id: crate::interaction::WidgetId,
1507        runtime: &crate::runtime::Runtime,
1508        theme: &Theme,
1509    ) {
1510        (**self).expand(id, runtime, theme)
1511    }
1512    fn switches(&self) -> bool {
1513        (**self).switches()
1514    }
1515    fn system_ui_style(&self) -> Option<crate::SystemUiOverlayStyle> {
1516        (**self).system_ui_style()
1517    }
1518    fn repaint_boundary(&self) -> bool {
1519        (**self).repaint_boundary()
1520    }
1521    fn debug_name(&self) -> &'static str {
1522        (**self).debug_name()
1523    }
1524    fn semantics(&self) -> Option<SemanticsProperties> {
1525        (**self).semantics()
1526    }
1527    fn describes(&self) -> Option<crate::semantics::Description> {
1528        (**self).describes()
1529    }
1530    fn children(&self) -> &[Box<dyn Widget<Msg>>] {
1531        (**self).children()
1532    }
1533    fn paint(&self, bounds: Rect, status: Status, theme: &Theme, scene: &mut Scene) {
1534        (**self).paint(bounds, status, theme, scene)
1535    }
1536    fn on_click(&self) -> Option<Msg> {
1537        (**self).on_click()
1538    }
1539    fn opaque(&self) -> bool {
1540        (**self).opaque()
1541    }
1542    fn positional_click(&self, local_x: f32, local_y: f32, width: f32, height: f32) -> Option<Msg> {
1543        (**self).positional_click(local_x, local_y, width, height)
1544    }
1545    fn cursor_icon(&self, local_x: f32, local_y: f32, width: f32, height: f32) -> Option<Cursor> {
1546        (**self).cursor_icon(local_x, local_y, width, height)
1547    }
1548    fn key(&self) -> Option<u64> {
1549        (**self).key()
1550    }
1551    fn on_edit(&self, edit: &mut Edit, key: &Key) -> Option<Msg> {
1552        (**self).on_edit(edit, key)
1553    }
1554    fn cursor_at(
1555        &self,
1556        local_x: f32,
1557        local_y: f32,
1558        width: f32,
1559        scroll_cursor: usize,
1560    ) -> Option<usize> {
1561        (**self).cursor_at(local_x, local_y, width, scroll_cursor)
1562    }
1563    fn text_metrics(&self, width: f32, cursor: usize) -> Option<(f32, f32, f32, f32)> {
1564        (**self).text_metrics(width, cursor)
1565    }
1566    fn text_viewport(&self, rect: crate::Rect) -> Option<crate::Rect> {
1567        (**self).text_viewport(rect)
1568    }
1569    fn caret_vertical(
1570        &self,
1571        width: f32,
1572        cursor: usize,
1573        down: bool,
1574        page: bool,
1575        goal_x: Option<f32>,
1576    ) -> Option<(usize, f32)> {
1577        (**self).caret_vertical(width, cursor, down, page, goal_x)
1578    }
1579    fn selected_text(&self, edit: &Edit) -> Option<String> {
1580        (**self).selected_text(edit)
1581    }
1582    fn text_value(&self) -> Option<&str> {
1583        (**self).text_value()
1584    }
1585    fn replace_value(&self, value: String) -> Option<Msg> {
1586        (**self).replace_value(value)
1587    }
1588    fn word_at(&self, index: usize) -> Option<(usize, usize)> {
1589        (**self).word_at(index)
1590    }
1591    fn selection_handles(
1592        &self,
1593        width: f32,
1594        edit: &Edit,
1595        scroll_y: f32,
1596    ) -> Option<[crate::SelectionHandle; 2]> {
1597        (**self).selection_handles(width, edit, scroll_y)
1598    }
1599    fn focusable(&self) -> bool {
1600        (**self).focusable()
1601    }
1602
1603    fn shortcut_bindings(&self) -> &[(crate::shortcuts::KeyStroke, crate::shortcuts::Intent)] {
1604        (**self).shortcut_bindings()
1605    }
1606
1607    fn shortcut_callbacks(&self) -> &[(crate::shortcuts::KeyStroke, Msg)] {
1608        (**self).shortcut_callbacks()
1609    }
1610
1611    fn action_bindings(&self) -> &[(crate::shortcuts::Intent, Msg)] {
1612        (**self).action_bindings()
1613    }
1614
1615    fn action_listeners(&self) -> &[(crate::shortcuts::Intent, Msg)] {
1616        (**self).action_listeners()
1617    }
1618
1619    fn on_keystroke(
1620        &self,
1621    ) -> Option<std::rc::Rc<dyn Fn(crate::shortcuts::KeyStroke) -> Option<Msg>>> {
1622        (**self).on_keystroke()
1623    }
1624
1625    fn descendants_focusable(&self) -> bool {
1626        (**self).descendants_focusable()
1627    }
1628
1629    fn focus_skip_traversal(&self) -> bool {
1630        (**self).focus_skip_traversal()
1631    }
1632
1633    fn focus_order(&self) -> Option<f32> {
1634        (**self).focus_order()
1635    }
1636
1637    fn focus_group(&self) -> bool {
1638        (**self).focus_group()
1639    }
1640    fn autofill_hints(&self) -> &[crate::AutofillHint] {
1641        (**self).autofill_hints()
1642    }
1643    fn autofill_group(&self) -> bool {
1644        (**self).autofill_group()
1645    }
1646    fn draws_own_focus(&self) -> bool {
1647        (**self).draws_own_focus()
1648    }
1649    fn draggable(&self) -> bool {
1650        (**self).draggable()
1651    }
1652    fn on_drag(&self, fraction: f32) -> Option<Msg> {
1653        (**self).on_drag(fraction)
1654    }
1655    fn on_drag_start(&self, fraction: f32) -> Option<Msg> {
1656        (**self).on_drag_start(fraction)
1657    }
1658    fn on_drag_end(&self, fraction: f32) -> Option<Msg> {
1659        (**self).on_drag_end(fraction)
1660    }
1661    fn on_drag_delta(&self, dx: f32) -> Option<Msg> {
1662        (**self).on_drag_delta(dx)
1663    }
1664    fn reorder_index(&self) -> Option<usize> {
1665        (**self).reorder_index()
1666    }
1667    fn on_reorder(&self, to: usize) -> Option<Msg> {
1668        (**self).on_reorder(to)
1669    }
1670    fn reorder_draggable(&self) -> bool {
1671        (**self).reorder_draggable()
1672    }
1673    fn reorder_droppable(&self) -> bool {
1674        (**self).reorder_droppable()
1675    }
1676    fn reorder_announcement(&self, to: usize) -> Option<String> {
1677        (**self).reorder_announcement(to)
1678    }
1679    fn reorder_axis(&self) -> ReorderAxis {
1680        (**self).reorder_axis()
1681    }
1682    fn reorder_inserts(&self) -> bool {
1683        (**self).reorder_inserts()
1684    }
1685    fn announce(&self) -> Option<String> {
1686        (**self).announce()
1687    }
1688    fn stack(&self) -> bool {
1689        (**self).stack()
1690    }
1691    fn continuous(&self) -> bool {
1692        (**self).continuous()
1693    }
1694    fn scroll_content(&self) -> Option<&dyn Widget<Msg>> {
1695        (**self).scroll_content()
1696    }
1697    fn virtual_list(&self, viewport: frus_core::Size) -> Option<crate::list::VirtualList<'_, Msg>> {
1698        (**self).virtual_list(viewport)
1699    }
1700    fn page_view(&self) -> Option<crate::pageview::PagedView<'_, Msg>> {
1701        (**self).page_view()
1702    }
1703    fn intrinsic(&self) -> Option<(crate::constraints::IntrinsicAxis, Option<f32>)> {
1704        (**self).intrinsic()
1705    }
1706    fn overflow_box(&self) -> Option<crate::constraints::Overflow> {
1707        (**self).overflow_box()
1708    }
1709    fn constraints_transform(&self) -> Option<crate::constraints::ConstraintsTransform> {
1710        (**self).constraints_transform()
1711    }
1712    fn hero_tag(&self) -> Option<u64> {
1713        (**self).hero_tag()
1714    }
1715    fn drag_payload(&self) -> Option<u64> {
1716        (**self).drag_payload()
1717    }
1718    fn drag_needs_long_press(&self) -> bool {
1719        (**self).drag_needs_long_press()
1720    }
1721    fn drag_ghost_opacity(&self) -> f32 {
1722        (**self).drag_ghost_opacity()
1723    }
1724    fn on_dropped(&self, accepted: bool) -> Option<Msg> {
1725        (**self).on_dropped(accepted)
1726    }
1727    fn drop_zone(&self) -> bool {
1728        (**self).drop_zone()
1729    }
1730    fn accepts_drag(&self, payload: u64) -> bool {
1731        (**self).accepts_drag(payload)
1732    }
1733    fn on_drop(&self, payload: u64) -> Option<Msg> {
1734        (**self).on_drop(payload)
1735    }
1736    fn on_page_changed(&self, page: usize) -> Option<Msg> {
1737        (**self).on_page_changed(page)
1738    }
1739    fn on_scroll(&self, position: crate::scrollposition::ScrollPosition) -> Option<Msg> {
1740        (**self).on_scroll(position)
1741    }
1742    fn scroll_grain(&self) -> f32 {
1743        (**self).scroll_grain()
1744    }
1745    fn layout_builder(&self) -> Option<&dyn Fn(Size) -> Box<dyn Widget<Msg>>> {
1746        (**self).layout_builder()
1747    }
1748    fn scroll_overlay(&self) -> Option<&crate::scrolloverlay::OverlayBuilder<Msg>> {
1749        (**self).scroll_overlay()
1750    }
1751    fn scroll_axis(&self) -> Axis {
1752        (**self).scroll_axis()
1753    }
1754    fn scroll_physics(&self) -> Option<crate::physics::ScrollPhysics> {
1755        (**self).scroll_physics()
1756    }
1757    fn scrollbars(&self) -> Option<crate::physics::Scrollbars> {
1758        (**self).scrollbars()
1759    }
1760    fn thumb_visibility(&self) -> Option<bool> {
1761        (**self).thumb_visibility()
1762    }
1763    fn ime(&self) -> crate::ime::Ime {
1764        (**self).ime()
1765    }
1766    fn overlay(&self) -> Option<(&dyn Widget<Msg>, Placement)> {
1767        (**self).overlay()
1768    }
1769    fn overlay_dismiss(&self) -> Option<Msg> {
1770        (**self).overlay_dismiss()
1771    }
1772    fn overlay_scrim(&self, theme: &crate::theme::Theme) -> Option<frus_core::Color> {
1773        (**self).overlay_scrim(theme)
1774    }
1775    fn overlay_traps_focus(&self) -> bool {
1776        (**self).overlay_traps_focus()
1777    }
1778    fn anim_target(&self) -> Option<f32> {
1779        (**self).anim_target()
1780    }
1781    fn anim_transform(&self) -> Option<crate::runtime::TransformValues> {
1782        (**self).anim_transform()
1783    }
1784    fn anim_duration(&self) -> f32 {
1785        (**self).anim_duration()
1786    }
1787    fn anim_curve(&self) -> frus_core::Curve {
1788        (**self).anim_curve()
1789    }
1790    fn opacity_group(&self) -> Option<f32> {
1791        (**self).opacity_group()
1792    }
1793    fn anim_color(&self) -> Option<frus_core::Color> {
1794        (**self).anim_color()
1795    }
1796    fn anim_size(&self) -> Option<Size> {
1797        (**self).anim_size()
1798    }
1799    fn anim_radius(&self) -> Option<frus_core::BorderRadius> {
1800        (**self).anim_radius()
1801    }
1802    fn anim_padding(&self) -> Option<frus_core::Insets> {
1803        (**self).anim_padding()
1804    }
1805    fn anim_offset(&self) -> Option<(f32, f32)> {
1806        (**self).anim_offset()
1807    }
1808    fn anim_pins(&self) -> Option<crate::positioned::Positioning> {
1809        (**self).anim_pins()
1810    }
1811    fn anim_fractions(&self) -> Option<(Option<f32>, Option<f32>)> {
1812        (**self).anim_fractions()
1813    }
1814    fn anim_text_style(&self) -> Option<frus_core::TextStyle> {
1815        (**self).anim_text_style()
1816    }
1817    fn alignment_geometry(&self) -> Option<frus_core::AlignmentGeometry> {
1818        (**self).alignment_geometry()
1819    }
1820    fn transform_translate(&self) -> Option<(f32, f32)> {
1821        (**self).transform_translate()
1822    }
1823    fn translate_fraction(&self) -> Option<(f32, f32)> {
1824        (**self).translate_fraction()
1825    }
1826    fn transform_scale(&self) -> Option<(f32, f32, frus_core::Alignment)> {
1827        (**self).transform_scale()
1828    }
1829    fn transform_rotate(&self) -> Option<(f32, frus_core::Alignment)> {
1830        (**self).transform_rotate()
1831    }
1832    fn clip_shape(&self) -> Option<frus_core::ClipShape> {
1833        (**self).clip_shape()
1834    }
1835    fn clip_path(&self) -> Option<&frus_core::Path> {
1836        (**self).clip_path()
1837    }
1838    fn layer_filter(&self, cx: FilterContext) -> Option<frus_core::LayerFilter> {
1839        (**self).layer_filter(cx)
1840    }
1841    fn text_baseline(&self, theme: &Theme) -> Option<f32> {
1842        (**self).text_baseline(theme)
1843    }
1844    fn ignores_baseline(&self) -> bool {
1845        (**self).ignores_baseline()
1846    }
1847    fn baseline_target(&self) -> Option<f32> {
1848        (**self).baseline_target()
1849    }
1850    fn fill_axes(&self, theme: &Theme) -> FillAxes {
1851        (**self).fill_axes(theme)
1852    }
1853    fn main_axis_floor(&self, theme: &Theme) -> Option<f32> {
1854        (**self).main_axis_floor(theme)
1855    }
1856    fn tile_shape(&self) -> Option<f32> {
1857        (**self).tile_shape()
1858    }
1859    fn positioned(&self) -> Option<crate::positioned::Positioning> {
1860        (**self).positioned()
1861    }
1862    fn stack_loose(&self) -> bool {
1863        (**self).stack_loose()
1864    }
1865    fn stack_visible(&self) -> Option<usize> {
1866        (**self).stack_visible()
1867    }
1868    fn scroll_reverse(&self) -> bool {
1869        (**self).scroll_reverse()
1870    }
1871
1872    fn keep_visible(&self, size: Size, theme: &Theme) -> Option<crate::ui::KeepVisible> {
1873        (**self).keep_visible(size, theme)
1874    }
1875    fn scroll_padding(&self) -> frus_core::Insets {
1876        (**self).scroll_padding()
1877    }
1878    fn backdrop_group(&self) -> bool {
1879        (**self).backdrop_group()
1880    }
1881    fn ink(&self, theme: &Theme) -> Option<crate::ink::InkStyle> {
1882        (**self).ink(theme)
1883    }
1884    fn foreground(&self, theme: &Theme) -> Option<frus_core::BoxDecoration> {
1885        (**self).foreground(theme)
1886    }
1887    fn barrier(&self) -> Option<crate::barrier::ModalBarrier> {
1888        (**self).barrier()
1889    }
1890    fn dismissible(&self) -> Option<crate::dismiss::DismissSpec> {
1891        (**self).dismissible()
1892    }
1893    fn on_dismissed(&self, direction: crate::dismiss::DismissDirection) -> Option<Msg> {
1894        (**self).on_dismissed(direction)
1895    }
1896    fn sheet(&self) -> Option<&crate::sheet::SheetSpec> {
1897        (**self).sheet()
1898    }
1899    fn on_sheet_dismissed(&self) -> Option<Msg> {
1900        (**self).on_sheet_dismissed()
1901    }
1902    fn refresh(&self) -> Option<crate::refresh::RefreshSpec> {
1903        (**self).refresh()
1904    }
1905    fn on_refresh(&self) -> Option<Msg> {
1906        (**self).on_refresh()
1907    }
1908    fn interactive(&self) -> Option<(f32, f32)> {
1909        (**self).interactive()
1910    }
1911    fn fitted(&self) -> Option<frus_core::BoxFit> {
1912        (**self).fitted()
1913    }
1914    fn rotated_quarter_turns(&self) -> Option<i32> {
1915        (**self).rotated_quarter_turns()
1916    }
1917    fn navigator(&self) -> Option<(f32, bool)> {
1918        (**self).navigator()
1919    }
1920    fn navigator_clips(&self) -> bool {
1921        (**self).navigator_clips()
1922    }
1923    fn navigator_retained(&self) -> usize {
1924        (**self).navigator_retained()
1925    }
1926    fn measure(&self, theme: &Theme) -> Option<frus_layout::MeasureFn<'_>> {
1927        (**self).measure(theme)
1928    }
1929    fn measure_key(&self, theme: &Theme) -> Option<u64> {
1930        (**self).measure_key(theme)
1931    }
1932    fn on_long_press(&self) -> Option<Msg> {
1933        (**self).on_long_press()
1934    }
1935    fn on_key(&self, key: &crate::interaction::Key) -> crate::interaction::KeyResponse<Msg> {
1936        (**self).on_key(key)
1937    }
1938}