Skip to main content

Crate day_spec

Crate day_spec 

Source
Expand description

day-spec — the toolkit specification (DESIGN.md §8).

Backends depend ONLY on this crate (never on day-core). One backend is linked per binary; day-core is monomorphized over the concrete Toolkit.

Re-exports§

pub use resource::AssetName;
pub use resource::FontFamily;
pub use resource::ImageName;
pub use resource::Resource;
pub use resource::ResourceOpener;
pub use resource::VectorName;
pub use resource::resolve_image_file;
pub use resource::resource;
pub use resource::set_resource_opener;
pub use day_fonts as fonts;

Modules§

bridge
The wire table for backends whose native side reaches Rust through ONE numeric-kind trampoline (Android’s JNI nativeOnEvent, ArkUI’s day_arkui_on_event). This enum is the single source of truth for those kind numbers; the Java and C++ sides carry mirrored constants that parity tests check against these discriminants (so a collision or drift fails cargo test on the host instead of silently mis-decoding events on a device). AppKit/UIKit/GTK/Qt emit Event values directly and never use these numbers; XAML uses per-event callbacks with its own small local codes.
kinds
The built-in piece keys as plain strings, for the registry and the PieceKind seam.
placeholder
Placeholder leaves: the one hole in Day’s rendering that is invisible to a screenshot.
present
props
resource
Bundled-resource random-access API + the per-backend opener seam (§18.3). Bundled resources — efficient random read-only access to app-declared data, backed by each toolkit’s native resource mechanism (DESIGN §18.3).

Structs§

A11yProps
A11ySnapshot
A widget’s ACTUAL native accessibility properties, read back by Toolkit::read_a11y so a11y_audit (§14.2) can diff the native tree against Day’s expectation. role is the native role mapped back to Day’s Role (best-effort); found = false means the backend can’t read the native tree (audit skips the node).
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.
Color
sRGB color, 0.0–1.0 components. Semantic theme tokens (§6.3) resolve to these in the backend.
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).
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.
Insets
Logical insets: leading/trailing resolve against the layout direction at place time (§7.8).
KeyEvent
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.
ListReorder
The synchronous drag-to-reorder half of ListSource (docs/list.md). Both closures follow bind_row’s discipline: called on the UI thread from inside native drag callbacks, outside any day-core borrow, and they run to completion synchronously.
ListSource
The synchronous row-pull seam for recycling lists (docs/list.md, §10). day-core injects one per LIST host via Toolkit::attach_list; a recycling backend stores it and calls it from its native data-source (on the UI thread, outside any day-core borrow). Each closure re-enters day-core, so — unlike EventSink — these run to completion synchronously (bind_row even flushes + lays out the row before returning, so the host can measure the cell immediately).
NodeId
Realized-node identity as seen by backends (day-core’s slotmap key, FFI-encoded).
Point
PointerEvent
Proposal
The layout proposal: None = unconstrained on that axis (§7.2).
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
Registry
Renderer
A third-party piece’s per-toolkit implementation. make receives the concrete backend (public helper surface) and returns a native handle the backend then owns like any built-in.
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").
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/…).
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).
WindowOptions

Enums§

Builtin
Every piece kind Day itself defines (§5.3). Backends match on this exhaustively in realize; anything outside it is an extension piece resolved through the Registry by its string PieceKind.
Cap
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
Event
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).
Icon
A toolbar item’s picture: a standard Symbol (drawn with the platform’s own icon set) or a bundled image from resource/images for something only this app has.
LayoutDirection
Lifecycle
An app-lifecycle phase (docs/lifecycle.md). Each backend maps these onto its OS’s native app / activity delegate. Some phases only exist on some platforms — a mobile app truly enters the background and can be low on memory, a desktop app essentially cannot — so Lifecycle::is_universal marks the ones every backend delivers, and Toolkit::supports_lifecycle reports per-backend truth.
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.
Role
Shape
Support
SurfaceRole
Default navigation sidebar width (split presentation) until the pane reports its size. Semantic container surfaces (see ContainerProps::role): each backend maps a role to its own theme-adaptive material so the fill tracks light/dark mode without app code.
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.
ToolbarPatch
A targeted update to one live toolbar item — the path that keeps a bound signal in sync without rebuilding the bar (which would drop the search field’s focus mid-keystroke).
ToolbarValue
A value a toolbar item produced.
WindowKind
What a secondary window IS, so backends can apply platform conventions (docs/windows.md).
WindowOpenReply
A backend’s answer to Toolkit::open_window (docs/windows.md).

Constants§

NAV_SIDEBAR_WIDTH
WINDOW_NODE
Reserved id for window-level events (resize, lifecycle): day-core routes it to the root.

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.
Platform
A platform backend: owns the native main loop and exactly one window in v1 (§8.1).
Toolkit

Functions§

encode_ops
Flat numeric encoding of a display list for shim/JNI boundaries (§11, §15.3): per op 9 numbers [kind, a, b, c, d, e, f, g, rgba-bits]; text payloads ride separately in order. Kinds: 0 fill-rect, 1 stroke-rect(g=w), 2 fill-rrect(e=r), 3 fill-ellipse, 4 stroke-ellipse(g=w), 5 stroke-arc(e=start°, f=sweep°, g=w), 6 line(a,b→c,d, g=w), 7 text(a,b=pos, e=size, f=anchor: 0 leading / 1 centered), 8 save, 9 restore, 10 concat(a..f=affine), 11 fill-polygon / 12 stroke-polygon(g=w) — polygon points ride the texts channel as “x,y x,y …” (closed automatically), 13 stroke-rrect(e=r, g=w), 14 set-gradient(f=type: 0 linear with a,b=start / c,d=end unit points; 1 radial with a,b=center unit point, c=unit radius; e=stop count) — the stops ride the texts channel as “offset,aarrggbb offset,aarrggbb …”; the gradient applies to the NEXT fill-shape record (whose color slot is then unused) and is cleared after it. Unit geometry resolves against the filled shape’s bounding box, so a radial stretches elliptically in non-square bounds.

Type Aliases§

EventSink
The event sink: enqueue-only — may be invoked re-entrantly from inside any Toolkit method; day-core drains queued events at safe points, each as a fresh batch (§3.3).
MeasureFn
Optional custom measure for a third-party piece (§8.2).
PieceKind
Interned piece-kind key, e.g. "day.label" or "acme.combobox".
RawHandle
Raw foreign native handle for polyglot adoption (§15.3).
Day API ↩ Guides· daybrite.dev