Expand description
The reactive runtime: interaction context, retained layout tree, and event dispatch.
Turns the static Element IR into an interactive UI. A
Cx is threaded through the view-building closure so widgets can register
on_tap (pointer) and on_key (keyboard/focus) handlers; building yields
an Element tree plus a parallel Handlers table. Laying the tree out
produces a retained LayoutNode tree that hit_test (pointer) and
focus_at / collect_focusables (keyboard focus) query to route events
back to the registered handlers.
Handlers stay out of the Element IR (they live in the Cx tables,
addressed by ActionId / FocusId) so Element stays Clone/Debug
and the IR remains diff-friendly for a future reconciler.
Structs§
- Action
Id - An opaque handle to a registered tap handler, stamped onto the element that
owns it and resolved against the
Cxtap table on dispatch. - Context
Id - An opaque handle to an element with a registered secondary-click (context)
handler, resolved against the
Cxcontext table on a right-click. - Cx
- Build context threaded through a view closure.
- DragId
- An opaque handle to an element with a registered drag handler.
- FocusId
- An opaque handle to a focusable element with a registered key handler.
- Handlers
- The handler tables produced by building a frame. Dispatch resolves an
ActionId/FocusId(fromhit_test/focus_at) to its handler and invokes it against the app state. - Layout
Node - A laid-out, retained node: absolute bounds, paint decoration, optional text
content, the optional tap/focus handles it routes to, and laid-out children.
Produced by
layoutand consumed by paint,hit_test, and the focus queries. - Overlay
Spec - A floating layer drawn above the main tree — a menu, popover, tooltip, or
dialog. Declared during a build via
Cx::overlay; the app lays it out at itsAnchorand paints it last (topmost). Itscontent’s handlers register through the sameCx, so taps/keys inside it work normally. - Scroll
Id - An opaque handle to a scroll container. The app keeps a scroll offset per id (adjusted by wheel events) and re-applies it each frame; the id is stable as long as the view registers scroll containers in the same order.
- Text
PosId - An opaque handle to an editable text element with a registered text-pointer handler (click-to-position / drag-to-select).
- Viewport
Id - A caller-chosen handle to an embedded-content viewport — a rectangle the
app fills with externally-rendered pixels (a browser page, video frame, or a
sandboxed content process’s GPU surface). Unlike the auto-registered handler
ids, the value is chosen by the app so it stays stable across frames and can
be correlated with the content source that feeds it (see
Element::viewport).
Enums§
- Anchor
- Where an
OverlaySpecis positioned within the window. - KeyInput
- A platform-neutral keyboard input, delivered to the focused element. The app/platform layer translates raw key events into these.
- Node
Content - Paintable leaf content carried by a
LayoutNodebeyond its decoration. - Viewport
Event - A platform-neutral input event forwarded to an embedded
viewport’s content — a sandboxed browser/content process that renders into the viewport. Pointer positions are in viewport-local logical pixels (origin at the viewport’s top-left), so the content can route them without knowing where the viewport sits in the window.
Functions§
- collect_
focusables - Collect every focusable
FocusIdin paint/tree order, for Tab traversal. - collect_
viewports - Collect every embedded-content viewport in the tree as
(id, bounds), in paint order, so the app can composite each one’s registered content into its laid-out rect (and route input landing inside it to that content). Bounds are in absolute logical pixels. - context_
at - Find the
ContextIdof the top-most node with a secondary-click handler containingpoint(mirrorshit_test, for right-clicks). - drag_at
- Find the top-most draggable node containing
point, returning itsDragIdand bounds (so the caller can compute the drag fraction). - find_
action - Find the node carrying tap-action
id, if present (for hover highlight). - find_
focus - Find the node carrying focus
id, if present. - find_
scroll - Find the scroll-container node carrying
id, if present. - find_
text_ pos - Find the node carrying text-pointer
id, if present (for continuing a drag-selection after the pointer leaves the element bounds). - first_
text - The first text-bearing
LayoutNodeat or undernode, in tree order. Used to position the caret and selection highlight inside a focused text field (read itscontenttext/size plusbounds/caret/selection). - focus_
at - Find the
FocusIdof the top-most focusable node containingpoint(used for click-to-focus). - hit_
test - Find the
ActionIdof the top-most tappable node containingpoint. - scroll_
at - Find the
ScrollIdof the top-most scroll container containingpoint(the wheel target). Children are tested first so a nested scroll area wins. - text_
pos_ at - Find the top-most text-pointer node containing
point, returning itsTextPosIdand the node (so the caller can resolve a byte index from the node’s text and bounds). - viewport_
at - Find the top-most embedded-content viewport containing
point, returning itsViewportIdand bounds (so the app can forward the event with viewport-local coordinates). Children are tested first, mirroring paint order.