Skip to main content

Module runtime

Module runtime 

Source
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§

ActionId
An opaque handle to a registered tap handler, stamped onto the element that owns it and resolved against the Cx tap table on dispatch.
ContextId
An opaque handle to an element with a registered secondary-click (context) handler, resolved against the Cx context 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 (from hit_test / focus_at) to its handler and invokes it against the app state.
LayoutNode
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 layout and consumed by paint, hit_test, and the focus queries.
OverlaySpec
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 its Anchor and paints it last (topmost). Its content’s handlers register through the same Cx, so taps/keys inside it work normally.
ScrollId
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.
TextPosId
An opaque handle to an editable text element with a registered text-pointer handler (click-to-position / drag-to-select).
ViewportId
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 OverlaySpec is 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.
NodeContent
Paintable leaf content carried by a LayoutNode beyond its decoration.
ViewportEvent
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 FocusId in 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 ContextId of the top-most node with a secondary-click handler containing point (mirrors hit_test, for right-clicks).
drag_at
Find the top-most draggable node containing point, returning its DragId and 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 LayoutNode at or under node, in tree order. Used to position the caret and selection highlight inside a focused text field (read its content text/size plus bounds/caret/selection).
focus_at
Find the FocusId of the top-most focusable node containing point (used for click-to-focus).
hit_test
Find the ActionId of the top-most tappable node containing point.
scroll_at
Find the ScrollId of the top-most scroll container containing point (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 its TextPosId and 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 its ViewportId and bounds (so the app can forward the event with viewport-local coordinates). Children are tested first, mirroring paint order.