Skip to main content

Crate telar

Crate telar 

Source

Re-exports§

pub use config::RendererBackend;
pub use app_config::AppConfig;
pub use app_context::AppCtx;
pub use app_context::RedrawWaker;
pub use prefs::UserPrefs;
pub use window_signals::WindowSignals;
pub use app::App;
pub use tree::Frame;
pub use tree::HotTree;
pub use tree::LocalTree;
pub use tree::UiTree;
pub use surface::SurfaceContent;
pub use surface::SurfaceControl;
pub use surface::SurfaceHost;
pub use surface::SurfaceToken;
pub use surface::has_surface_host;
pub use surface::open_surface;
pub use surface::set_surface_host;
pub use runner::build_surface_handler;
pub use runner::run_multi_with_platform;
pub use runner::run_with_platform;
pub use runner::set_default_font_family;
pub use runner::open_window;
pub use runner::run_app_windowed;
pub use runner::run_app_with_name;
pub use runner::run_multi_app_with_name;
pub use motion_core as motion;
pub use i18n_core as i18n;

Modules§

app
app_config
app_context
config
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.
named_overlay
Named overlays: opening a dialog or drawer by name, instead of threading its signal(bool) to everything that might open it.
prefs
runner
surface
Backend-agnostic secondary-surface runtime: routes open_surface requests to an installed host; placement/scaffold widgets live in ui-core.
tree
The mounted UI as the runner sees it — and the seam that lets the app’s own runtime own it.
window
Window-management calls for UI code. A custom title bar’s buttons call these directly — including from .rsx on_press handlers (on_press(|| telar::window::close())). Each enqueues a platform_core::WindowCommand that the runner applies to the OS window right after the current event is dispatched. On backends without a movable top-level window (layer-shell, headless) they are inert no-ops.
window_signals

Macros§

app
children
rsx_modules
Transpile every .rsx file under src/ and declare the module tree — what app! does, minus the winit runner. Use this in a crate that drives rsx through a custom Platform (e.g. a Wayland layer-shell backend) instead of the built-in desktop runner: invoke telar::rsx_modules!() at the crate root, then build your own App from the transpiled components and run it via telar::run_with_platform / telar::run_multi_with_platform. Pass a theme type — rsx_modules!(MyTheme) — if your .rsx calls use_theme; otherwise rsx_modules!().
static_rc_str
Caches an Arc<str> per call site in thread-local storage so a string literal allocates at most once per thread instead of once per frame.
t
Translates a catalog key to a String, substituting named arguments: t!("battery.remaining", time = t).

Structs§

AlignItems
Used to control how child nodes are aligned. For Flexbox it controls alignment in the cross axis. For Grid it controls alignment in the block axis.
BorderRadius
Canvas
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.
Color
ComponentList
Container
DesktopPathsProvider
Effect
A live subscription. Dropping it deregisters the effect, so the closure runs once and never again — which looks exactly like a working binding until the value it derives is expected to move. Bind it to something that lives as long as the work should: a struct field, a returned value, or a let the reader captures.
Gradient
GradientStop
GradientStops
Up to 8 gradient color stops. Fixed-size array preserves the Copy bound.
Image
ImageData
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
LayoutStyle
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.
Memo
ModifiersState
NodeVec
Overlay
A portal layer: its content is laid out out-of-flow, filling the viewport, and hoisted to the top at compose time — drawn above everything and free of any ancestor clip/transform. A base primitive: unstyled; wrap content in a box for a scrim/panel, and position it with normal flex (align/justify).
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.
PathData
PathStyle
PlatformError
Point
PreviewEntry
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).
ReadSignal
Rect
RectStyle
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.
RwSignal
Scope
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
SegmentNodeInfo
A node emitted by Segment::walk: one mounted component, with its pre-order id, widget name, nesting depth, and the bounding rect of its own draw commands unioned with all descendants’.
Shadow
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.
Stroke
Stroke style for drawing primitives. Includes join to control how corners are rendered in paths and rects; for line segments join is unused and defaults to Miter.
StyledContainer
SurfaceFrameStyle
SurfaceId
Identifies one surface within a MultiSurfacePlatform run. Assigned by the platform (e.g. one per monitor for a desktop shell). Opaque and cheap to copy.
SurfacePlacement
A backend-agnostic description of a secondary surface: where it sits, how big it is, and how it behaves (scrim, outside-dismiss, auto-timeout). The intent lives here; a backend derives its own surface config from it. Reusable by a windowed app (as an in-window portal) and by a shell (as a real layer-shell surface) alike.
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.
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).
TextRun
One inline run of a rich-text paragraph: a slice of text with its own weight, slant, and colour. Paragraph metrics (font size, line height, wrapping, alignment) live on the DrawCommand::RichText base style, so a run overrides only what varies inline (bold, italic, a link’s colour).
TextStyle
Transform
A 2D affine transform stored as a 2×3 matrix [a, b, c, d, e, f], mapping a point (x, y) to (a*x + c*y + e, b*x + d*y + f). This is the same [f32; 6] layout consumed by RenderNode::transform_with, so to_array() plugs in directly. Compose with Transform::then instead of multiplying matrices by hand.
VirtualList
A keyed list that builds only the rows currently on screen.
WindowConfig

Enums§

AvailableSpace
The amount of space available to a node in a given axis https://www.w3.org/TR/css-sizing-3/#available
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.
DevAction
Direction
The writing direction the layout resolves logical edges against.
DrawCommand
Event
EventResult
FillRule
FullscreenMode
GradientKind
ImageFilter
Key
KeyboardMode
How much of the keyboard a surface needs.
LayoutError
LineCap
LineJoin
NamedKey
ObjectFit
How a sized piece of content (an image or SVG) is scaled into its layout box, mirroring CSS object-fit.
Paint
PathVerb
PointerButton
PointerSource
RawDisplayHandle
A display server handle for a particular windowing system.
RawWindowHandle
A window handle for a particular windowing system.
RenderNode
RendererError
ScrollDelta
SizeDimension
SurfaceAlign
Cross-axis alignment along the anchored edge (e.g. left/centre/right for a top-anchored surface).
SurfaceAnchor
The screen edge (or centre) a surface hugs. The cross axis is aligned by SurfaceAlign.
SurfaceRole
What kind of secondary surface a placement describes. A backend maps the role to its own surface primitives (a layer-shell backend picks a layer + namespace; a windowed backend a child window or an in-window portal). Roles carry no behaviour of their own — the explicit SurfacePlacement fields do.
SurfaceSize
A surface’s size: a fixed logical pixel box, or derived from its content.
TemplateTrack
TextAlign
Horizontal alignment of text within its box. Start is the writing-direction start (left in LTR).
WindowCommand
A window-management action requested by UI code (a custom title bar’s buttons) and applied by the runner to the OS window after event dispatch. Enqueued via push_window_command and drained via take_window_commands; kept as data (rather than direct Window calls) because widget closures run deep in the tree walk with no access to the platform window.
WindowPosition

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.

Traits§

AppPathsProvider
Component
Imperative-state components re-render only when on_event returns EventResult::Handled; reactive-state components re-render automatically on signal change.
DevPlugin
EventHandler
LayoutItem
MultiSurfacePlatform
A platform that drives N independent surfaces from a single run, each with its own EventHandler — the seam a multi-window app or a desktop shell (a bar/OSD/notification per monitor) needs. It is separate from Platform so the single-surface contract and every existing single-window entry point stay exactly as they are.
Platform
Scale
ShapeStyle
Theme
ThemeTokens
Window

Functions§

anchor_rect
The world-vs-local anchor fallback shared by the anchored menu/select/tooltip panels.
batch
begin_batch
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
current_direction
Non-reactive read of the active direction, for the layout pass and event handlers.
current_locale
Non-reactive read of the active locale, for the hot-reload snapshot bridge and event handlers.
detect_system_locale
The language subtag of the OS locale, from $LC_ALL / $LC_MESSAGES / $LANG (in POSIX precedence), lowercased and stripped of any territory/encoding suffix — e.g. es_ES.UTF-8"es". None when unset or the C/POSIX locale. An app can seed the initial language with init_locale(detect_system_locale()?).
dismiss_depth
Non-subscribing read of how many dismissible overlays are open.
dismiss_top
Dismisses the topmost open overlay, reporting whether there was one.
dispatch_overlays
effect
end_batch
follow_locale_direction
Makes the writing direction follow the active locale, so switching to Arabic or Hebrew mirrors the layout and switching back restores it — no rebuild, the existing nodes are re-resolved on the next layout pass.
follow_system
Drives the active mode from the OS light/dark preference — light → light, dark → dark — updating live as the OS scheme changes. Installs a reactive effect (kept alive internally) and designates the pair so is_dark/toggle_dark stay consistent. Re-calling replaces the effect (hot reload re-runs setup). A manual set_mode still wins until the next OS change re-drives it.
fragment
A keyed reactive region — for item in $items key <expr> (identity-stable reconciliation).
fragment_gap
A keyed reactive region with per-item spacing — for item in $items key <expr> gap:N. The 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 a boxed list.
fragment_positional
A keyless reactive region — for item in $items (reconciles by position).
fragment_positional_gap
A keyless reactive region with per-item spacing — for item in $items gap:N (reconciles by position).
hot_signal
Without dev there is no dylib swap to survive, so the key is inert and this degrades to a plain signal. The bounds match the dev build’s so a type that compiles here cannot fail once hot-reload is on — letting hand-written app state (a navigation stack, an active locale) be declared once instead of behind a cfg.
init_locale
Sets default only when no locale is active yet. Called at app start (and after a hot reload) so a selection restored across a dylib swap is not clobbered by the default.
init_mode
Selects default only when no mode is active yet. Called at app start and after a hot reload so a selection restored by the rsx hot-reload bridge is not clobbered by the default.
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.
is_dark
Reactive: true when the active mode is the designated dark mode. false when it is the light mode, no pair has been set, or a third (unpaired) mode is active. Read this for a sun/moon toggle’s on/off state.
mark_dirty
memo
new_container
new_leaf
open_overlay
Opens the overlay named id.
overlay_open
Non-subscribing read, for use inside an event handler.
overlay_state
The open-state signal for the overlay named id, minted on first use.
provide
push_window_command
Enqueue a window-management command from UI code (e.g. a title-bar button’s on_press). The runner drains the queue after event dispatch and applies each command to the OS window. Lives in a thread-local so it works from any widget closure without threading a window handle through the tree; each surface owns its own queue (activated via WindowCommandContext), so commands never cross windows.
register_mode
Registers a named mode. apply installs the concrete theme when the mode is selected. Re-registering an id replaces its closure, which is expected: hot reload re-runs the app’s setup and re-registers every mode.
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_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_runtime
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_dark
Selects the designated dark (on = true) or light (on = false) mode. No-op if no pair has been set.
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_light_dark
Designates which two registered modes form the light/dark pair. A thin, optional convention over the open mode registry: it does not replace named modes (a third mode like "pastel" stays valid) — it only tells is_dark/set_dark/toggle_dark which ids to flip between. Both ids should also be registered via register_mode. Does not itself change the active mode.
set_locale
Sets the active locale (a BCP-47 tag such as "en" or "es"), re-rendering every translated string that reads it. The tag should be one of the baked catalog’s locales; an unknown tag simply falls back to the catalog’s default locale at lookup time.
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_mode
Selects a mode: runs its registered apply closure (if one is registered) and publishes the id to the reactive active-mode signal. Setting an unregistered id still updates the signal, so an app may drive the theme from its own effect on use_mode instead of registering closures.
set_overlay_host
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.
set_system_dark
Reports the OS light/dark preference into the reactive graph. Called by the runner at window creation and whenever the OS scheme changes; drives follow_system.
set_theme
signal
surface_frame
take_window_commands
Drain every queued window command. Called by the runner once per event-dispatch cycle.
toggle_dark
Flips between the designated light and dark modes. Reads the current scheme non-reactively so it is safe to call from an event handler.
toggle_overlay
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.
try_inject
try_run_preview
try_run_test
Renders every preview component headlessly (build → layout → flatten) and exits with a non-zero code if any panics or returns a layout error. Backs cargo telar test, entered via the TELAR_TEST env var set on the app binary.
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).
use_dismiss_depth
Reactive read of how many dismissible overlays are open — for styling an affordance on whether a dismissal would do anything.
use_locale
Reactive read of the active locale — subscribes the caller so translated text re-renders on switch. None before any locale is set (callers fall back to the catalog’s default locale).
use_mode
Reactive read of the active mode id — subscribes the caller so a label re-renders on switch. None before any mode is set.
use_overlay_open
Reactive read of whether the overlay named id is open — for a trigger that styles itself as active while its panel is up.
use_theme
use_theme_tokens
visible_window
Which slice of a long list is worth building, given where the viewport currently is.
with_service

Type Aliases§

JustifyContent
Sets the distribution of space between and around content items. For Flexbox it controls alignment in the main axis. For Grid it controls alignment in the inline axis.
NodeId