Skip to main content

Crate repose_ui

Crate repose_ui 

Source
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 a View.
  • Incremental layout + paint via a persistent engine: composition produces a new View tree each frame; LayoutEngine reconciles it into a persistent ViewTree (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 by repose-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:

  1. Reconciles root into the persistent ViewTree (stable NodeIds, content + subtree hashes, dirty set, generation GC).
  2. Syncs dual Taffy trees (root + per-scope! ScopeLayoutTrees).
  3. Computes layout (measure callbacks, constraint equality skip for scopes).
  4. Walks the tree to emit SceneNodes, HitRegions, and SemNodes, with paint-cache hits on repaint_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 provides ListDetailPaneScaffold: 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 Text views.
subcompose
SubcomposeLayout and BoxWithConstraints.
textfield
TextField model
windowing

Structs§

Interactions

Traits§

ImageExt
IntoChildren
TextStyle
Method styling
ViewExt
Extension trait for child building

Functions§

AnnotatedText
Create a text view with rich text spans (AnnotatedString).
Box
Center
Align self-center shorthand.
Column
DragValue
A drag-to-change numeric value field (like egui’s DragValue).
Expander
FlowColumn
A vertically-oriented flow layout that wraps children to new columns when they exceed the available height. Equivalent to Column with flex_wrap(Wrap).
FlowRow
A horizontally-oriented flow layout that wraps children to new rows when they exceed the available width. Equivalent to Row with flex_wrap(Wrap).
Grid
Image
OverlayHost
Row
ScrollDeprecated
Space
Spacer
StackDeprecated
Flipped container (identical to Column). Deprecated: use Column directly.
Text
TreeRow
A single row in a tree view.
ZStack
layout_and_paint
Reconcile root into the thread-local LayoutEngine and run incremental layout + paint for this frame.