Expand description
§Views, Modifiers, and Layout
Repose UI is built around three core ideas:
View: an immutable description of a UI node (cheap to rebuild every frame).Modifier: layout, styling, and interaction hints attached to aView.- Incremental layout + paint via a persistent engine:
composition produces a new
Viewtree each frame;LayoutEnginereconciles it into a persistentViewTree(repose-tree) and runs incremental Taffy layout + paint (with scopes, dirty sets, and paint caches).
§Views
A View is a lightweight value that describes what to show, not how it is
rendered. It is cheap to create; you rebuild the description each frame
(Compose-style). Identity and layout state live in the persistent tree, not
in the View values themselves.
use repose_core::*;
use repose_ui::*;
fn Counter(count: i32, on_inc: impl Fn() + 'static) -> View {
Column(Modifier::new().padding(16.0)).child((
Text(format!("Count = {count}")),
Button("Increment".into_children(), on_inc),
))
}Internally, a View has:
id: ViewId- assigned during composition / layout.kind: ViewKind- which widget it is (Text, Button, etc.).modifier: Modifier- layout/styling/interaction metadata.children: Vec<View>- owned child views.
Views are pure data: they do not hold state or platform handles.
State lives in signals / remember_*; platform integration is in
repose-platform / repose-app.
§Modifiers
Modifier describes how a view participates in layout and hit-testing:
- Size:
size,width,height,min_*,max_*,fill_max_* - Box model:
padding,padding_values, margins - Visuals:
background,border,clip_rounded,alpha,transform, layers - Flex / grid:
flex_*,align_*,justify_*,grid,grid_span - Positioning:
absolute(),offset(..) - Scroll:
vertical_scroll/horizontal_scroll/scrollable,nested_scroll_connection - Interaction:
clickable(), pointer callbacks,semantics - Custom paint:
painter(used byrepose-canvas) - Incremental helpers:
key,repaint_boundary,scope!(core)
Modifiers are mapped to Taffy Style inside LayoutEngine. Values are in
density-independent pixels (dp) and converted to physical px via Density.
§Layout + paint
Public entry:
pub fn layout_and_paint(
root: &View,
size_px: (u32, u32),
textfield_states: &HashMap<u64, Rc<RefCell<TextFieldState>>>,
interactions: &Interactions,
focused: Option<u64>,
) -> (Scene, Vec<HitRegion>, Vec<SemNode>);This is a thin thread-local wrapper around LayoutEngine::layout_frame, which:
- Reconciles
rootinto the persistentViewTree(stableNodeIds, content + subtree hashes, dirty set, generation GC). - Syncs dual Taffy trees (root + per-
scope!ScopeLayoutTrees). - Computes layout (measure callbacks, constraint equality skip for scopes).
- Walks the tree to emit
SceneNodes,HitRegions, andSemNodes, with paint-cache hits onrepaint_boundary/ scopes, culling, nested scroll, etc.
Prefer scope!, stable keys, and repaint_boundary on expensive subtrees so
the incremental engine can skip work.
Re-exports§
pub use layout::IntrinsicSizeMode;pub use lazy::LazyColumn;pub use lazy::LazyHorizontalGrid;pub use lazy::LazyRow;pub use lazy::LazyVerticalGrid;pub use lazy::LazyVerticalStaggeredGrid;pub use lazy::SimpleList;pub use lazy_states::ItemHeight;pub use lazy_states::LazyColumnConfig;pub use lazy_states::LazyColumnState;pub use lazy_states::LazyGridConfig;pub use lazy_states::LazyGridState;pub use lazy_states::LazyRowConfig;pub use lazy_states::LazyRowState;pub use lazy_states::LazyVerticalStaggeredGridConfig;pub use lazy_states::LazyVerticalStaggeredGridState;pub use subcompose::BoxWithConstraints;pub use subcompose::SubcomposeLayout;pub use subcompose::box_with_constraints_with_key;pub use subcompose::subcompose_hash_key;pub use subcompose::subcompose_layout_with_slots;pub use subcompose::subcompose_with_key;pub use subcompose::subcompose_with_key_slots;pub use selection::SelectableText;pub use selection::SelectableTextExt;pub use textfield::BasicSecureTextField;pub use textfield::BasicTextField;pub use textfield::KeyboardOptions;pub use textfield::TextFieldConfig;pub use textfield::TextFieldState;
Modules§
- adaptive
- Adaptive layouts that respond to the current
WindowSizeClass. Currently providesListDetailPaneScaffold: the list and the detail render side-by-side on Medium/Expanded widths, and only the selected pane renders on Compact. - anim
- anim_
ext - color_
picker - gestures
- layout
- lazy
- lazy_
states - overlay
- pager
- scroll
- Scroll model
- selection
- Selectable text as a fluent modifier on
Textviews. - subcompose
- SubcomposeLayout and BoxWithConstraints.
- textfield
- TextField model
- windowing
Structs§
Traits§
- Image
Ext - Into
Children - Text
Style - Method styling
- ViewExt
- Extension trait for child building
Functions§
- Annotated
Text - Create a text view with rich text spans (AnnotatedString).
- Box
- Center
- Align self-center shorthand.
- Column
- Drag
Value - A drag-to-change numeric value field (like egui’s
DragValue). - Expander
- Flow
Column - A vertically-oriented flow layout that wraps children to new columns when
they exceed the available height. Equivalent to
Columnwithflex_wrap(Wrap). - FlowRow
- A horizontally-oriented flow layout that wraps children to new rows when
they exceed the available width. Equivalent to
Rowwithflex_wrap(Wrap). - Grid
- Image
- Overlay
Host - Row
- Scroll
Deprecated - Space
- Spacer
- Stack
Deprecated - Flipped container (identical to
Column). Deprecated: useColumndirectly. - Text
- TreeRow
- A single row in a tree view.
- ZStack
- layout_
and_ paint - Reconcile
rootinto the thread-localLayoutEngineand run incremental layout + paint for this frame.