Views, Modifiers, and Layout
Repose UI is built around three core ideas:
View: an immutable description of a UI node.Modifier: layout, styling, and interaction hints attached to aView.- Layout + paint: a separate pass (
layout_and_paint) that turns theViewtree into aScene+ hit regions using the Taffy layout engine.
Views
A View is a lightweight value that describes what to show, not how it is
rendered. It is cheap to create and you are expected to rebuild the entire
view tree on each frame:
use *;
use *;
Internally, a View has:
id: ViewId— assigned during composition/layout.kind: ViewKind— which widget it is (Text, Button, ScrollV, etc.).modifier: Modifier— layout/styling/interaction metadata.children: Vec<View>— owned child views.
Views are pure data: they do not hold state or references into platform
APIs. State lives in signals / remember_* and platform integration happens
in the runner (repose-platform).
Modifiers
Modifier describes how a view participates in layout and hit‑testing:
- Size hints:
size,width,height,min_size,max_size,fill_max_size,fill_max_width,fill_max_height. - Box model:
padding,padding_values. - Visuals:
background,background_brush,border,clip_rounded,alpha,transform. - Flex / grid:
flex_grow,flex_shrink,flex_basis,align_self,justify_content,align_items,grid,grid_span. - Positioning:
absolute(),offset(..)for overlay / Stack / FABs. - Interaction:
clickable(), pointer callbacks,on_scroll,semantics. - Custom paint:
painter(used byrepose-canvas).
Example:
use *;
use *;
Modifiers are merged into a Taffy Style inside layout_and_paint. Most
values are specified in density‑independent pixels (dp) and converted to
physical pixels (px) using the current Density local.
Layout
Layout is a pure function:
;
It:
- Clones the root
Viewand assigns stableViewIds. - Builds a parallel Taffy tree and computes layout for the given window size.
- Walks the tree to:
- Emit
SceneNodes for visuals (rects, text, images, scrollbars, etc.). - Build
HitRegions for input routing (clicks, pointer events, scroll). - Build
SemNodes for accessibility / semantics.
- Emit
Row, Column, Stack, Grid, ScrollV and ScrollXY are all special
ViewKinds that map into Taffy styles and additional paint/hit logic.
Because layout + paint are separate from the platform runner, you can reuse the same UI code on desktop, Android, and other platforms.