Skip to main content

Module prelude

Module prelude 

Source

Re-exports§

pub use crate::DocumentTabs;
pub use crate::TabActions;
pub use crate::TabSet;
pub use crate::document_tabs;
pub use crate::TextStyle;
pub use crate::ToolbarEntry;
pub use crate::A11yBuilder;
pub use crate::Alert;
pub use crate::BackRequest;
pub use crate::BackResponse;
pub use crate::ButtonBuilder;
pub use crate::ColumnBuilder;
pub use crate::Command;
pub use crate::Confirm;
pub use crate::ContentList;
pub use crate::Corner;
pub use crate::Cover;
pub use crate::Decorate;
pub use crate::Decorated;
pub use crate::Delete;
pub use crate::Drag;
pub use crate::Draw;
pub use crate::FileAccess;
pub use crate::FileUrl;
pub use crate::Form;
pub use crate::FormSection;
pub use crate::Grid;
pub use crate::GridRow;
pub use crate::HAlign;
pub use crate::Inspector;
pub use crate::IntoFocusBinding;
pub use crate::IntoFraction;
pub use crate::IntoImageSource;
pub use crate::IntoReactive;
pub use crate::IntoText;
pub use crate::ItemSlot;
pub use crate::LabelBuilder;
pub use crate::Labeled;
pub use crate::List;
pub use crate::ListItem;
pub use crate::ListItemBuilder;
pub use crate::Loaded;
pub use crate::MenuContent;
pub use crate::MenuEntry;
pub use crate::Modifier;
pub use crate::Move;
pub use crate::NativeRef;
pub use crate::Nav;
pub use crate::NavContent;
pub use crate::NavItem;
pub use crate::NavStack;
pub use crate::NavStyle;
pub use crate::OpenFile;
pub use crate::Pan;
pub use crate::PathBuilder;
pub use crate::Pinch;
pub use crate::Prompt;
pub use crate::Reactive;
pub use crate::Reorder;
pub use crate::ReorderVerdict;
pub use crate::Route;
pub use crate::RoutePath;
pub use crate::RowBuilder;
pub use crate::RowFit;
pub use crate::SaveFile;
pub use crate::Search;
pub use crate::SearchReveal;
pub use crate::Sections;
pub use crate::ShapeKind;
pub use crate::ShapePiece;
pub use crate::StatusItem;
pub use crate::SwipeAction;
pub use crate::TextBuilder;
pub use crate::VAlign;
pub use crate::VectorWeight;
pub use crate::When;
pub use crate::ZStack;
pub use crate::adaptive;
pub use crate::alert;
pub use crate::app_menu;
pub use crate::arc;
pub use crate::button;
pub use crate::canvas;
pub use crate::canvas;
pub use crate::capsule;
pub use crate::circle;
pub use crate::column;
pub use crate::confirm;
pub use crate::cover;
pub use crate::current_route;
pub use crate::divider;
pub use crate::dock_menu;
pub use crate::each;
pub use crate::ellipse;
pub use crate::form;
pub use crate::frame_clock;
pub use crate::grid;
pub use crate::grid_row;
pub use crate::image;
pub use crate::image;
pub use crate::inspector;
pub use crate::inspector;
pub use crate::item;
pub use crate::items;
pub use crate::keyed;
pub use crate::label;
pub use crate::labeled;
pub use crate::line;
pub use crate::list;
pub use crate::list_item;
pub use crate::load;
pub use crate::menu_item;
pub use crate::menu_role;
pub use crate::menu_separator;
pub use crate::nav;
pub use crate::nav;
pub use crate::nav_back;
pub use crate::nav_items;
pub use crate::nav_stack;
pub use crate::navigate;
pub use crate::navigate_to;
pub use crate::open_file;
pub use crate::picker;
pub use crate::picker_optional;
pub use crate::polygon;
pub use crate::progress;
pub use crate::prompt;
pub use crate::rectangle;
pub use crate::rounded_rectangle;
pub use crate::route;
pub use crate::route_param;
pub use crate::route_params;
pub use crate::row;
pub use crate::save_file;
pub use crate::scroll;
pub use crate::section;
pub use crate::secure_field;
pub use crate::segment;
pub use crate::shape;
pub use crate::shape_group;
pub use crate::shape_group_fn;
pub use crate::slider;
pub use crate::spacer;
pub use crate::spinner;
pub use crate::split;
pub use crate::split;
pub use crate::status_item;
pub use crate::sub_menu;
pub use crate::swipe_action;
pub use crate::switch;
pub use crate::text_area;
pub use crate::text_field;
pub use crate::toggle;
pub use crate::toolbar_button;
pub use crate::toolbar_label;
pub use crate::toolbar_menu;
pub use crate::toolbar_segmented;
pub use crate::toolbar_separator;
pub use crate::toolbar_toggle;
pub use crate::vector;
pub use crate::when;
pub use crate::zstack;
pub use crate::Space;
pub use crate::TextPreset;
pub use crate::Drawing;
pub use crate::PdfDocument;
pub use crate::Branches;
pub use crate::NodeSource;
pub use crate::TreeBuilder;
pub use crate::TreeConn;
pub use crate::TreePiece;
pub use crate::branches;
pub use crate::tree;
pub use crate::AdaptiveBuilder;
pub use crate::CoverBuilder;
pub use crate::DividerBuilder;
pub use crate::FormSectionBuilder;
pub use crate::GridBuilder;
pub use crate::GridRowBuilder;
pub use crate::ImageBuilder;
pub use crate::InspectorBuilder;
pub use crate::LinkBuilder;
pub use crate::ListBuilder;
pub use crate::NavBuilder;
pub use crate::NavStackBuilder;
pub use crate::PickerBuilder;
pub use crate::ScrollBuilder;
pub use crate::ShapePieceBuilder;
pub use crate::SliderBuilder;
pub use crate::SplitBuilder;
pub use crate::TextAreaBuilder;
pub use crate::TextFieldBuilder;
pub use crate::ToggleBuilder;
pub use crate::VectorBuilder;
pub use crate::WhenBuilder;
pub use crate::ZStackBuilder;
pub use crate::Picker;
pub use crate::TextArea;

Macros§

id
Declare an ID at its piece, including a link-time catalog entry.
routes
Define a plain routes enum and its Route impl in one shot:

Structs§

Affine
A 2-D affine transform (CoreGraphics row-vector convention): a point p maps to (a·p.x + c·p.y + tx, b·p.x + d·p.y + ty). Used by canvas transform ops for shape rotate/scale/offset; every native 2-D context concatenates it onto its CTM identically.
AnimSpec
Animation intent (§8.4). Native-widget backends map it onto their own animator (Core Animation, ViewPropertyAnimator, XAML Composition, OH_ArkUI_AnimateTo, …); the canvas/self-driven path samples curve via Curve::fraction. Threaded through Toolkit::update/set_frame/ set_opacity/set_transform.
Animation
Animation intent (§8.4). Native-widget backends map it onto their own animator (Core Animation, ViewPropertyAnimator, XAML Composition, OH_ArkUI_AnimateTo, …); the canvas/self-driven path samples curve via Curve::fraction. Threaded through Toolkit::update/set_frame/ set_opacity/set_transform.
AnyBinding
A type-erased Binding: what a piece stores when its builder takes impl Binding<T> (docs/api-style.md “Three input spellings”), so the piece itself needs no type parameter per bound value.
AnyPiece
Type-erased piece for heterogeneous branches and dynamic construction.
AssetName
The bundled-data name that resource resolves by: the file’s path relative to resource/assets/, /-separated (a top-level file is just its file name, extension included).
BuildCx
CanvasExports
What this toolkit can export a canvas drawing to (Cap::CanvasBitmap, Cap::CanvasPdf). Read it to enable or hide export commands, the way image_encode_formats decides which formats to offer.
CanvasFont
What canvas text is drawn with beyond its size (docs/canvas.md “Text”): a family, a weight and a slant. The default is the platform’s own UI face, regular, upright, which is what every backend drew before the field existed, so a default font encodes to nothing on the wire.
Color
sRGB color, 0.0–1.0 components. Semantic theme tokens (§6.3) resolve to these in the backend.
Duration
A Duration type to represent a span of time, typically used for system timeouts.
Edges
A set of screen edges, for the defers_system_gestures modifier (docs/cover.md). Mirrors SwiftUI’s Edge.Set: on iOS these map to UIRectEdge for preferredScreenEdgesDeferringSystemGestures; on Android any non-empty set enters swipe-to-reveal immersive mode (the closest platform analogue).
Effect
A reaction that re-runs when its tracked reads change. Runs once at creation.
ElementId
An application-owned element identity, declared with crate::id!.
FontFace
One face a font family ships (docs/fonts.md): its display name (“Bold Italic”), weight and slant. What FontFamilyInfo::faces lists and what a font menu’s style picker offers.
FontFamily
The family name of a bundled custom font, feeding Font::custom. Holds a &'static str (so Font stays Copy); generated res::fonts::… constants supply it. The untyped Font::Custom(&'static str, f64) variant remains the escape hatch for a family known another way.
FontFamilyInfo
A platform (or bundled) font family and the faces it can draw canvas text in (Toolkit::font_families, docs/fonts.md).
FontSpec
The full font descriptor a label carries: a semantic (or custom) Font style plus an optional weight override, an italic flag, and the tabular-figures request. Backends resolve this to one native font.
ImageName
The bundled-image name that resource() callers resolve by (the file stem).
Insets
Logical insets: leading/trailing resolve against the layout direction at place time (§7.8).
LinearGradient
A linear gradient (docs/shapes.md §3.2 / §7): color stops along the line from start to end, both in the unit space of the filled shape’s bounding box. Stops are (offset 0..=1, color), ascending.
Memo
Cached, equality-diffed derived value (§4.2).
ParagraphRun
One styled paragraph.
ParagraphStyle
A ParagraphRun’s attributes with no range attached.
PieceFn
A closure kept as a concrete piece: the deferral primitive (§5.2).
Point
RNode
Realized-node key. NodeId (the spec-boundary id) is its FFI encoding.
RadialGradient
A radial gradient (docs/shapes.md §3.2 / §7): color stops from center outward. Both the center and the radius live in the unit space of the filled shape’s bounding box, so the gradient stretches into an ellipse when the bounds aren’t square (the XAML relative-brush behavior; the other backends reproduce it with a local matrix on a circular gradient). A radius of 0.5 from the default center touches the edge midpoints of the bounds.
Rect
RunStyle
A TextRun’s attributes with no range attached: what a toolbar toggles, what an editor applies to a selection, and what it styles the next typed character with.
Scope
Ownership scope for signals/effects (§4.3). Copy handle; not Send.
Setter
Send write-only handle to a signal; delivery hops to the UI thread via the main poster. Writes after disposal are silent no-ops (§4.3).
Shortcut
A keyboard shortcut for a menu item. primary is the platform’s command modifier (⌘ on Apple, Ctrl on GTK/Qt/XAML) so one declaration reads correctly everywhere. key is a single character ("s", ".") or a named key ("Return", "Delete", "Left", "F1").
Signal
A Copy, !Send reactive value handle (§4.2).
Size
StyledText
A styled document: plain text, the character runs over it, and the paragraph attributes over the same offsets.
TextAnchor
How canvas text hangs on its at point: one placement per axis (docs/canvas.md “Text”).
TextMetrics
Single-line text measurement in canvas points (Toolkit::measure_text, docs/fonts.md).
TextRun
One styled span of a label’s text (docs/text-runs.md).
ToolbarItem
One item in a window’s toolbar (docs/toolbars.md).
Transform
A cheap per-node visual transform (§8.4 animation): translation, uniform/non-uniform scale, and rotation about a unit anchor (0.0..1.0 within the node’s bounds; default center). Distinct from the layout frame: animating a Transform never triggers relayout, so it is the vehicle for movement/scaling animation. Each backend composes it onto the node’s laid-out frame via its native transform channel (CALayer/GskTransform/RenderTransform/NODE_TRANSFORM/…).
Trigger
Data-less invalidation source.
UnitPoint
A point in the unit space of a shape’s bounding box: (0,0) = top-leading, (1,1) = bottom-trailing. Gradient geometry is expressed in unit points so one paint value works for any shape size (docs/shapes.md §3.2).

Enums§

Alignment
Two-axis placement of a child within a container’s bounds (SwiftUI’s Alignment). Used by the z-layering primitives (OverlayLayout): zstack, overlay/overlay_aligned.
Curve
The timing curve of an animation (§8.4). Native backends map each variant onto their own easing (CAMediaTimingFunction, QEasingCurve, ArkUI ARKUI_CURVE_*, spring animators); the canvas/self-driven path samples it via Curve::fraction. Spring matches SwiftUI’s .spring(response:dampingFraction:).
DragPhase
The phase of a drag gesture (docs/shapes.md).
DrawOp
Either
A build-time branch between two piece TYPES, without erasing either (§5.1).
ExportError
Why a canvas export could not answer (docs/canvas.md “Exporting”).
Font
A semantic (logical) text style. Each maps to the platform’s native text style where the toolkit has one: UIFont/NSFont.preferredFont(forTextStyle:) on Apple (Dynamic Type), the *TextBlockStyle resources on XAML. A Day app thus matches the OS’s own typography and inherits its accessibility text scaling with no extra work. Backends without semantic styles (GTK/Qt/Android) approximate with sizes that still track the platform’s text-scale / font-scale accessibility setting.
FontWeight
Font weight, matching UIFont.Weight / SwiftUI Font.Weight (lightest → heaviest). Ordered by heaviness, so backends can e.g. map >= Semibold to a synthesized bold face.
GestureKind
A gesture a node wants delivered. Backends attach the matching native recognizer when day-core calls Toolkit::enable_gesture; the default is no gesture (recognizers cost, so opt-in).
InputPurpose
What a text field collects (text_field(..).input_purpose(_), docs/textfield.md).
LabelStyle
Which halves of an item’s label a platform draws, where it can draw more than one.
ListStyle
A paragraph’s list decoration, if it is a list item.
MenuBarRole
A standard menu-bar slot (macOS’s File/Edit/View/Window/Help, and their counterparts elsewhere). A backend that has a house style for the menu bar fills every slot an app did not claim with its own stock menu, so an app never has to restate the platform’s furniture, and can still replace any of it by tagging its own submenu with the matching role.
MenuItem
One entry in a menu (recursive: a Submenu nests).
MenuRole
A standard/system command. The backend supplies the native item, a selector on AppKit/UIKit (cut:/copy:/paste:…) or a stock action on GTK/Qt/XAML, so it targets the focused control, gets the platform’s default label + shortcut, and enables/disables itself automatically. This is how default items (Edit ▸ Cut/Copy/Paste, the app’s Quit/About) are accommodated without the app re-implementing them.
MoveVerdict
A tree move guard’s verdict (docs/tree.md). No Retarget yet: the drop vocabulary is already positional, so a guard that wants a different target denies and the user drops where it is allowed.
NavPresentation
How a navigation host lays its panes out (docs/navigation.md).
Paint
A fill source: a solid color, or a linear/radial gradient (docs/shapes.md §3.2; angular and semantic tokens are later phases). From<Color> keeps every existing fill(shape, color) call site compiling unchanged.
PaneEdge
Which side an inspector pane occupies (docs/inspector.md).
ParagraphAlign
How a paragraph’s lines sit in the width they are given.
PickerStyle
SwiftUI’s pickerStyle analogue (kinds::PICKER). Each maps to a distinct native control per toolkit (docs/picker.md).
Role
RowHeight
How a recycling list sizes its rows (docs/list.md).
ScrollTarget
A programmatic scroll destination (§7.6, docs/scroll.md). Edges are axis extremes (Top/Bottom vertical, Leading/Trailing horizontal, i.e. start/end in layout direction); Offset pins the viewport origin to a content-space point (clamped by the platform); Id reveals the element with that dayscript id inside its nearest enclosing scroll.
Shape
SplitAxis
How a kinds::SPLIT lays its two panes (docs/split.md): beside each other, the divider standing, or stacked, the divider lying. Named by where the panes go, since that is what an app’s “layout” toggle means; the divider runs the other way.
SubmitLabel
The on-screen keyboard’s action key (text_field(..).submit_label(_), docs/textfield.md).
Symbol
A standard icon, named by what it means rather than by how it looks, so each backend can draw the platform’s own glyph for it: an SF Symbol on macOS, a freedesktop icon name on GTK and Qt, a Fluent glyph on Windows. This is the only way an icon looks native on every desktop at once; a bundled PNG cannot, because it is one artist’s take on all four.
TextAlign
How a wrapped label’s lines sit within its width (LabelProps::align).
TextVAlign
Where at sits vertically. Top, Middle and Bottom are edges of the line box (ascent + descent at the font’s size, the box Toolkit::measure_text reports); Baseline is the typographic baseline itself.
ToolbarItemKind
What a toolbar item is. The variants are the vocabulary every desktop toolbar shares; each backend realizes one with its native control, never with a drawn imitation.
ToolbarPlacement
Where an item sits on the chrome that carries it (docs/toolbars.md).
ToolbarValue
A value a toolbar item produced.
Underline
A line under a run.

Traits§

Ambient
State an ancestor provides once and any descendant reads back by type: SwiftUI’s @EnvironmentObject, and Day’s answer to “where does app state live?” (docs/state.md).
Animatable
Linear interpolation of animatable values (t in 0.0..1.0). This drives the canvas / self-driven animation path (docs/shapes.md §5) and Qt’s sampled spring; native-widget animation does not use it; the toolkit interpolates on its own compositor.
Binding
A readable-writable value a control can bind to two-way: a Signal, or any projection that knows how to read and write its own slot (day-model’s Field is the other implementor).
IntoElementKey
Explicit, stable canonical text for an instance key. No blanket Display conversion. Integer 42 and text “42” intentionally denote the same key. Composite keys must define an unambiguous app-owned encoding before the framework percent-escapes it.
Piece
A UI description consumed once (§5.2). Returns the root realized node it created.
PieceSeq
Children of a container (§5.1): a tuple of pieces (the floem ViewTuple pattern), a Vec or array of one piece type, or an Option of a piece. Implemented for exactly those shapes, never via a blanket, to stay coherent. All of them are build-time children: evaluated once when the parent builds, with no keyed identity or reconciliation. A child that must come and go at runtime is a when, a keyed, or an each.

Functions§

announce
Speak text through the screen reader without moving its focus (docs/accessibility.md): the outcome of an action the user cannot otherwise learn about (“Saved”, “3 results”). The sentence waits for whatever is being read to finish; announce_urgent interrupts it. Nothing happens when no screen reader is running, and nothing happens on a toolkit that answers Cap::Announce with Unsupported.
announce_urgent
announce, interrupting what the screen reader is saying: an error, or a change that cannot wait.
app_environment
The app-wide T: created on the reactive root scope the first time it is asked for, and returned unchanged by every later call (docs/state.md).
batch
bind
The binding primitive (§4.2): compute (tracked) + apply (untracked), equality-gated. Structural priority: bindings drain before plain effects. apply receives the new value by reference so V needs only PartialEq (no Clone).
canvas_exports
What this toolkit can export a canvas drawing to.
environment
Read the nearest ambient T provided by an enclosing with_environment, or None if none is in scope. Call it while constructing or building a piece within that subtree.
focused_environment
The ambient T of the window that currently has focus (docs/state.md): SwiftUI’s @FocusedValue.
invalidate_size
Tell layout that a node’s intrinsic size may have changed. For tweaks (docs/tweaks.md): after a native call that alters a widget’s preferred size (fonts, tick marks, bezel styles), the measure cache along the node’s path must be invalidated, since Day can’t see native mutations it didn’t make. Relayout runs at the next turn boundary as usual. No-op on a disposed node.
open_url
Open url in the platform’s default handler (system browser for http(s), mail client for mailto:, …). The function behind the link piece; call it directly from a tap handler for a custom affordance. Fire and forget: no result, unopenable URLs are ignored by the backend.
piece_fn
A piece from a closure, built when the tree reaches it.
untrack
Run f without tracking reads.
watch
Derive-state without effect-write loops (§4.2): source is tracked; cb runs untracked with (new, old). Does not fire for the initial value: a “load whatever is selected” reaction has to run once by hand first, or use bind, which applies the initial value and then every change.
with_animation
Explicitly animate every state change made in f, Day’s equivalent of SwiftUI’s withAnimation. The mutation runs inside a day_reactive::batch; that batch’s synchronous fixpoint drain (bindings → patch, plus the turn-end layout → set_frame) executes while spec is ambient, so the resulting native updates carry the animation intent and the toolkit animates them on its own compositor. Nesting overrides; the previous ambient restores after.
with_environment
Provide an ambient value T to content and its entire descendant subtree (the SwiftUI @Environment/.environment(_) analog, layered over day-reactive’s scope context). content, and any piece built within it, reads it back with environment. A thin, non-reactive wrapper: T is a snapshot captured here; for a value that must react, provide a Signal<T> (or a Memo<T>) and read it reactively inside the subtree.
Day API ↩ Guides· daybrite.dev