Skip to main content

Module prelude

Module prelude 

Source

Re-exports§

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::ButtonStyle;
pub use crate::Confirm;
pub use crate::Corner;
pub use crate::Cover;
pub use crate::Decorate;
pub use crate::Drag;
pub use crate::Draw;
pub use crate::FileUrl;
pub use crate::FilledButtonStyle;
pub use crate::FormSection;
pub use crate::Grid;
pub use crate::GridRow;
pub use crate::HAlign;
pub use crate::IntoFocusBinding;
pub use crate::IntoFraction;
pub use crate::IntoReactive;
pub use crate::IntoText;
pub use crate::ItemSlot;
pub use crate::List;
pub use crate::MenuEntry;
pub use crate::Modifier;
pub use crate::NativeRef;
pub use crate::NavItem;
pub use crate::OpenFile;
pub use crate::Prompt;
pub use crate::Reactive;
pub use crate::Reorder;
pub use crate::Route;
pub use crate::RoutePath;
pub use crate::SaveFile;
pub use crate::Selector;
pub use crate::SelectorStyle;
pub use crate::ShapeKind;
pub use crate::ShapePiece;
pub use crate::SignalRw;
pub use crate::Stack;
pub use crate::VAlign;
pub use crate::VectorWeight;
pub use crate::ZStack;
pub use crate::alert;
pub use crate::app_menu;
pub use crate::app_menu_reactive;
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::each;
pub use crate::ellipse;
pub use crate::environment;
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::item;
pub use crate::label;
pub use crate::labeled;
pub use crate::line;
pub use crate::list;
pub use crate::menu_item;
pub use crate::menu_role;
pub use crate::menu_separator;
pub use crate::nav_back;
pub use crate::navigate;
pub use crate::navigate_to;
pub use crate::open_file;
pub use crate::picker;
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::selector;
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::stack;
pub use crate::sub_menu;
pub use crate::text_area;
pub use crate::text_field;
pub use crate::toggle;
pub use crate::toolbar;
pub use crate::toolbar;
pub use crate::toolbar_button;
pub use crate::toolbar_flexible_space;
pub use crate::toolbar_label;
pub use crate::toolbar_menu;
pub use crate::toolbar_reactive;
pub use crate::toolbar_separator;
pub use crate::toolbar_space;
pub use crate::toolbar_toggle;
pub use crate::vector;
pub use crate::when;
pub use crate::with_environment;
pub use crate::zstack;
pub use crate::Picker;
pub use crate::TextArea;

Macros§

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.
AnyPiece
Type-erased piece for heterogeneous branches and dynamic construction.
AssetName
The bundled-data name that resource resolves by (the full file name, extension included).
BuildCx
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.
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.
FontSpec
The full font descriptor a label carries: a semantic (or custom) Font style plus an optional weight override and italic flag. Backends resolve this to one native font.
ImageName
The bundled-image name that image 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).
PieceVec
Runtime-heterogeneous children (column_vec-style call sites).
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
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
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
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 — so a Day app matches the OS’s own typography and inherits its accessibility text scaling for free. 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).
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 — selector on AppKit/UIKit (cut:/copy:/paste:…), 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.
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.
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 — 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
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.
TextAnchor
How canvas text hangs on its at point (style rule: no bare bools in public APIs).
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.
ToolbarValue
A value a toolbar item produced.

Traits§

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.
Piece
A UI description consumed once (§5.2). Returns the root realized node it created.
PieceSeq
Children of a container: a tuple of pieces (the floem ViewTuple pattern — implemented ONLY for tuples, (), and PieceVec, never via a blanket, to stay coherent).

Functions§

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).
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 — 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 seam 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.
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.
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.
Day API ↩ Guides· daybrite.dev