Expand description
Widget trait, tree traversal, and the top-level App struct.
§Coordinate system
Widget bounds are expressed in parent-local first-quadrant (Y-up)
coordinates. A widget at bounds.x = 10, bounds.y = 20 is drawn 10 units
right and 20 units up from its parent’s bottom-left corner.
OS/browser mouse events arrive in Y-down screen coordinates. The single
conversion y_up = viewport_height - y_down happens inside
App::on_mouse_move / App::on_mouse_down / App::on_mouse_up.
All widget code sees Y-up coordinates only.
§Tree traversal
Paint: root → leaves (children painted on top of parents). Hit test: root → leaves (deepest child under cursor wins). Event dispatch: leaf → root (events bubble up; any widget can consume).
Structs§
- App
- Owns the widget tree, handles focus, and converts OS events to Y-up coords.
- Backbuffer
Cache - A CPU bitmap owned by a widget that opts into backbuffer caching.
- Inspector
Node - Flat snapshot of one widget for the inspector panel.
Enums§
- Backbuffer
Mode - How a widget’s backbuffer stores pixels.
Traits§
- Widget
- Every visible element in the UI is a widget.
Functions§
- collect_
inspector_ nodes - Walk the subtree rooted at
widgetand collect anInspectorNodeper widget in DFS paint order (root first). - dispatch_
event - Dispatch
eventthrough a path (list of child indices from the root). The event bubbles leaf → root; returnsConsumedif any widget consumed it. - hit_
test_ subtree - Walk the subtree rooted at
widgetand return the path (list of child indices) to the deepest widget that passeshit_testatlocal_pos. - paint_
subtree - Paint
widgetand all its descendants. The caller must ensurectxis already translated so that (0,0) maps towidget’s bottom-left corner.