Skip to main content

Module render_tree

Module render_tree 

Source
Expand description

Persistent render tree — the single owner of per-node retained state (D091).

Every widget position gets a node. During paint a widget declares its interactive regions and attachments onto its node; the frame pipeline then derives hit-test order, scroll routing, the overlay stack, focus order, and transform layers from the tree. Nothing is re-emitted per frame through side channels, so state survives cache-hit frames by construction.

§Identity

A node’s identity is its position within its parent’s paint order. This is safe because widget paint recursion always descends fully once entered — only the element walker may skip a subtree (picture cache hit), and it consumes the child slot without resetting it, keeping siblings aligned and the skipped subtree’s state intact.

The one place positional identity is NOT safe: ScreenTransitionView (screen_transition_view.rs), where the exact same tree position holds a completely different, unrelated screen’s subtree every time navigation changes. Positional reuse there silently aliased one screen’s scroll offset/animation state onto the next screen that happened to land on the same NodeId (2026-08-01, real trackpad + navigation testing). Its child is addressed through RenderTree::keyed_slot instead of the ordinary RenderTree::slot — a small, explicitly-keyed side table scoped to that one call site, not a general per-widget keying system.

Structs§

InspectNode
One node in an RenderTree::inspect snapshot — plain data only.
RenderTree
Arena-allocated persistent render tree. Node 0 is always the root.
ScrollAxes
Which wheel/trackpad axes a scroll region can consume. Routing prefers the innermost region that handles the DOMINANT axis of a delta — an x-only carousel must not swallow a vertical page scroll.
TreeNode
One render-tree node. Declared data is cleared when the node is repainted (begin) and persists untouched otherwise.

Functions§

select_scroll_handler
Shared axis-preference selection (also used for overlay scroll routes): first candidate handling the dominant delta axis, else first handling the other axis.

Type Aliases§

HitHandler
A resolved hit/scroll handler — invoked with the event’s (x, y) in window-space logical pixels.
HitRegion
A click callback with its hit rect in window-space logical pixels.
HitRegionAt
A positional click callback — receives the click point in window-space logical pixels (sliders, color pickers, canvases).
NodeId
ScrollHandler
A nested-scroll chain link (D-NESTED-SCROLL, 2026-08-02) — takes a (dx, dy) DELTA (not an absolute position, unlike HitHandler) and returns whether it actually moved: true if it consumed some or all of the delta, false if it’s already fully exhausted in that exact direction (hard-clamped, or stretched to Bounce’s own overscroll limit) and had NO effect. A gesture starting inside nested scrollable regions (an inner ScrollView/carousel sitting inside an outer one, or a plain-hit Button/ListTile sitting inside any ScrollView) tries the innermost link first each move and only offers the SAME delta to the next link outward once the current one declines — so scrolling naturally “hands off” to an enclosing scrollable ancestor exactly when, and only when, the inner one has nothing left to give.
ScrollRegion
A (delta_x, delta_y) scroll callback with its viewport rect and the axes it handles.
ZoomRegion
A registered pinch-to-zoom region (InteractiveViewer, Phase 32) — the callback receives the gesture’s delta (winit’s PinchGesture::delta: positive = magnify, negative = shrink; NOT a multiplier, an increment — callers typically do zoom *= 1.0 + delta).