Skip to main content

Crate telar_ui_core

Crate telar_ui_core 

Source

Re-exports§

pub use dismiss::dismiss_depth;
pub use dismiss::dismiss_top;
pub use dismiss::use_dismiss_depth;
pub use overlay::Overlay;
pub use overlay::Placement;
pub use overlay::anchor_rect;
pub use scroll_region::visible_rect;

Modules§

accessibility
What a screen reader is told about the window right now.
dismiss
The dismiss stack: which open overlay a Back gesture or an Escape key closes next.
focus
Keyboard focus: which widget receives key events. A base primitive with no styling of its own — a focusable widget (e.g. crate::Input) requests focus on tap and consults it in on_event/view.
overlay
scroll_region
Where a node actually is on screen, once the scroll viewports around it are accounted for.

Macros§

impl_leaf_widget
Implements LeafWidget for a struct that has a leaf: LayoutLeaf field.

Structs§

Canvas
Children
A component’s markup children, not yet built.
ClippedItem
Wraps a child so its rendered output is clipped to the child’s own layout rect. When the child collapses to a zero rect (e.g. a section hidden via display:none), the clip is empty, so nothing inside draws — even a widget left with a stale rect or one that paints at fixed coordinates. Layout is unchanged: layout_node passes through to the wrapped child.
ComponentList
Container
DragStart
What armed a drag: the button pressed, and what was held down at that moment.
Holding
Wraps a widget so that dropping the widget drops a set of Effects with it.
Image
Input
A single-line editable text field bound to a RwSignal<String>. A base primitive: unstyled (no border or background — wrap it in a box for the look) and keyboard-driven. It requests focus on tap and, while focused, edits the bound signal from key events, drawing a caret at the insertion point. Selection, clipboard, and IME composition are not yet supported (a single-caret MVP).
LayoutScrollArea
Lazy
A subtree that is not built until the first time it would be shown — lazy when:$cond { … } in .rsx.
Line
Line is designed for use inside Canvas closures where you control absolute coordinates. It does not implement LayoutItem because its p1/p2 points are absolute, not relative to a layout rect. To use Line in a layout context, embed it in a Canvas widget.
LineGutter
A line-number gutter for a code editor: the column “1\n2\n3…” drawn top-aligned with the same line height a TextArea uses, so line n here sits exactly on line n of the editor. Place it beside the editor inside the same scroll (so they scroll together) and give both the same font_size. It measures its own width from the widest number and its height from the line count, re-measuring reactively as the count changes. Toggle it by collapsing its node (set_display) inside a ClippedItem so a hidden gutter both takes no width and draws nothing.
NodeVec
Path
Path is designed for use inside Canvas closures where you control absolute coordinates. It does not implement LayoutItem because its path data uses absolute points, not relative to a layout rect. To use Path in a layout context, embed it in a Canvas widget.
PointerButtons
Which pointer buttons are held right now.
ReactiveList
A reactive list: for item in $items key id (or, keyless, for item in $items) in .rsx. Re-runs its source reactively and reconciles the item widgets — reused keys/positions keep their node/widget, new ones are built, gone ones are disposed, and the layout children are reordered — instead of rebuilding the whole block on every change. new/with_gap reconcile by key (identity-stable); positional/ positional_with_gap reconcile by index (no key clause needed, cheap append/truncate).
Rectangle
RichText
A paragraph of mixed-style text: a sequence of TextRuns (bold, italic, coloured links) shaped and wrapped as one, the multi-style counterpart of Text. The shared paragraph metrics — font size, line height, wrapping, max_lines — come from a base TextStyle; each run overrides only weight, slant, and colour.
ScrollPage
A window-sized root holding a LayoutScrollArea whose viewport is recomputed on resize, so content scrolls against the current window dimensions.
ScrollViewport
A handle to the enclosing scroll area’s live viewport, handed to the content builder by LayoutScrollArea::new_with. Because a scroll area lays its content out as its OWN layout root, every descendant’s tracked rect is already in the same content-local space the scroll offset indexes into — so visible is a plain rect overlap, no scroll-transform math.
ScrollbarStyle
Slots
The children a component receives from its call site, grouped by slot. A bare child lands in the default slot (None); a child written with slot:"name" lands in that named slot. Inside the component, the children placeholder drains the default slot and children name:"x" drains the "x" slot — each in call-site order. Draining is one-shot: a slot placeholder consumes its children, so referencing the same slot twice yields an empty list the second time.
StyledContainer
Surface
The complete per-surface world plus its reactive SurfaceHandle. Build one per window/layer-surface with Surface::new; activate it with Surface::enter.
SurfaceGuard
Restores the previously-active surface world when dropped. The per-world guards each restore their own (independent) thread-local; _prev_surface restores the reactive current-surface.
SurfaceRoot
SurfaceScaffold
A full-viewport scaffold that positions a panel against a screen edge, optionally dims the area behind it, and dismisses on a press outside the panel. It is the reusable body of a drawer/modal: a shell mounts it as the root of a full-screen layer-shell surface, and a windowed app can mount it in-tree as an in-window portal — both get the same positioning and dismiss behaviour.
SurfaceTransition
The one progress value a surface’s arrival and departure share: 0 is off its edge and transparent, 1 is settled. Opening runs it to 1; leave runs it back to 0, so the exit is the entrance reversed rather than a second animation that has to be kept in step with the first.
Text
TextArea
A multi-line editable text area bound to a RwSignal<String> — the multi-line sibling of Input. A base primitive: unstyled (wrap it in a box for a border/background), keyboard-driven, no soft-wrap (only \n breaks lines, so long lines overflow horizontally). It requests focus on tap, positions the caret at the click, edits the bound signal from key events (typing, Enter for a newline, Backspace/Delete joining lines, arrows in all four directions, Home/End, Tab), and draws a caret. Its measured height grows with the line count, so wrapping it in a LayoutScrollArea gives a scrolling editor. Selection, clipboard, and IME are not yet supported (a single-caret MVP, like Input).
VirtualList
A keyed list that builds only the rows currently on screen.

Enums§

ChildSlot
One child position in a container: a fixed widget, or a reactive fragment (built lazily once the host node exists). Produced by ChildSlot::stat / fragment / fragment_positional.
ClipAxis
Which of a ClippedItem’s own edges do the cutting.
Edge
Which side of the viewport a SurfaceScaffold pins its panel to, and the direction it slides in from.
EventResult
RenderNode

Constants§

DEFAULT_SCRIM
The default scrim wash: ~35 % black over the content behind a drawer/modal. Rendered as a fill (not an opacity layer) so the panel above it stays fully opaque. Kept as the value a caller reaches for rather than being folded into the scaffold, because SurfaceScaffold now takes the colour itself.

Traits§

Component
Imperative-state components re-render only when on_event returns EventResult::Handled; reactive-state components re-render automatically on signal change.
LayoutItem

Functions§

absolute_rect
The node’s WINDOW-absolute rect (top-left from the top-level walk, size from its layout), or None if it has not been laid out under a window root yet. Unlike track_layout, this is correct even for a node in a sub-root computed separately (whose rect signal is root-local) — use it to anchor a portaled overlay to a trigger, since the portal hoists out of ancestor transforms and needs absolute coordinates.
box_item
box_transform
Builds the affine matrix for a box’s declarative rotate/scale/translate attributes, pivoting rotation and scale on the box centre. Returns None when every component is identity, so an untransformed box skips the extra transform node entirely.
close_overlay
Closes the overlay named id. Note this is not the same as a dismissal: it closes exactly this overlay, where dismiss_top closes whichever is frontmost.
compute_layout
Lays out root against the given space and reflects the result into each node’s rect signal. Collects the (signal, rect) updates while holding the runtime borrow, then applies them in a batch after releasing it — a rect .set() can flush effects, and one of those may itself touch the layout runtime (a reactive list), which would re-enter the borrow.
current_direction
Non-reactive read of the active direction, for the layout pass and event handlers.
dispatch_overlays
Routes an event to the overlay layer before the widget tree sees it.
drag_start
What armed the drag whose callback is running, or None outside one.
drag_travel
How far the drag whose callback is running has been from its press point, at its furthest.
end_keyboard_frame
Forgets the presses that belong to the frame just finished. The runner calls this once per frame, after dispatch, so key_pressed answers for exactly one frame.
fragment
A keyed reactive region — for item in $items key <expr> (identity-stable reconciliation). gap is laid out as a main-axis leading margin between consecutive items (see [reconcile_slot]), so the region still flows transparently in the host’s direction (horizontal in a row) instead of becoming a boxed list; pass 0.0 for none.
fragment_positional
A keyless reactive region — for item in $items (reconciles by position). gap as in fragment.
interactive_rects
The current laid-out rects of every interactive widget on the active surface, dropping any not yet laid out (zero-sized). Read without subscribing (peek), so the platform’s frame loop can call it outside a reactive scope without accidentally tracking the layout signals.
kept
The value this surface keeps under key, built by init the first time it is asked for and handed back unchanged on every build after that.
key_held
Whether key is down right now, however long it has been down.
key_pressed
Whether key went down during this frame. False for a key the OS is repeating, which is what makes it the one to drive a once-per-press action while key_held drives a continuous one.
logical_border_radius
Corner radii where start/end, when given, round the two corners on that edge.
logical_border_widths
Per-side border widths where start/end, when given, land on left or right according to the writing direction.
mark_dirty
modifiers
The modifier keys held right now.
new_container
new_leaf
observe_keyboard
Records what event says about the keyboard. The runner calls this for every event before dispatch.
observe_pointer
Records what event says about the buttons. The runner calls this for every event before dispatch, so a handler running on this very event already sees the state it establishes.
open_overlay
Opens the overlay named id.
overlay_state
The open-state signal for the overlay named id, minted on first use.
overlay_viewport
Pins the overlay host to node — the app’s window-spanning root — so overlays always fill the viewport even when the app computes several independent layout roots (e.g. a shell with a separate sidebar root computed after the main one, which the auto-detection would otherwise pick as the host). Call it each relayout with the current main root (it survives hot-reload rebuilds, which mint a new root node). Once pinned, auto-detection no longer overrides the host. The area an overlay may occupy: the laid-out rect of the host its content is attached to, which is the window (or the surface) it will be composed into.
pointer_buttons
The pointer buttons held right now.
relayout_if_dirty
Re-lays out every root that has been computed at least once, picking up any nodes a reactive change dirtied since the last frame. Each compute_layout early-returns when its root is clean and the space is unchanged, so this is cheap on a still frame. The runtime calls it once per redraw (after flushing reactive effects, before rendering) so a data change deep in the tree — e.g. a reactive list adding an item — is reflected in layout without the app shell knowing about it. Node dirtiness propagates up to the root through taffy, so a dirtied list container makes its root recompute.
remove_node
Detaches and frees node (a former list item) from the runtime: removes it from the layout tree and drops its rect signal and bookkeeping. The caller must have removed it from its parent’s child list (via set_children) first.
reset_keyboard
Drops all keyboard state; parallels the other per-tree resets on teardown and hot reload.
reset_layout_runtime
Resets the active surface’s layout runtime to a fresh, empty tree. The single-window app/preview harness calls this at construction; a multi-surface runner instead gives each surface its own LayoutContext.
reset_pointer
Drops the button state; parallels the other per-tree resets on teardown and hot reload.
set_children
Replaces parent’s children with children, in order, marking parent dirty. Operates on the thread-local runtime; parent must be a container already registered in the runtime.
set_direction
Sets the writing direction every surface lays out against, taking effect on the next layout pass.
set_display
Shows or hides a node in layout flow. A hidden node takes no space (and lays out none of its subtree); mark an ancestor dirty and recompute for the change to take effect. Used for responsive layouts (e.g. collapsing a sidebar on narrow windows).
set_min_height
Sets node’s minimum height to px after the initial layout (dirtying it, which propagates up), so a content-measured leaf grows to at least px even when its content is shorter. A scrolling editor uses it to fill its viewport so a click anywhere in the empty area — not just over the text — lands on the leaf.
set_overlay_host
style_follows
Re-resolves node’s layout style whenever the reactive state style reads changes, and once now.
track_layout
transform_pointer
Applies the full affine inverse of matrix to all pointer-coordinate events. Returns None for non-pointer events or when matrix is degenerate (det ≈ 0), so callers fall back to the original.
use_context
The nearest enclosing value of type T that a parent provided, or None outside any such parent.
use_direction
Reactive read of the active direction — subscribes the caller, for the rare widget that has to mirror something layout cannot flip on its own (a chevron glyph, a directional icon).
visible_window
Which slice of a long list is worth building, given where the viewport currently is.

Type Aliases§

NodeId