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’sday_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 failscargo teston the host instead of silently mis-decoding events on a device). AppKit/UIKit/GTK/Qt emitEventvalues 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
PieceKindseam. - 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§
- A11y
Props - A11y
Snapshot - A widget’s ACTUAL native accessibility properties, read back by
Toolkit::read_a11ysoa11y_audit(§14.2) can diff the native tree against Day’s expectation.roleis the native role mapped back to Day’sRole(best-effort);found = falsemeans the backend can’t read the native tree (audit skips the node). - Affine
- A 2-D affine transform (CoreGraphics row-vector convention): a point
pmaps 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. - Anim
Spec - 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 samplescurveviaCurve::fraction. Threaded throughToolkit::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_gesturesmodifier (docs/cover.md). Mirrors SwiftUI’sEdge.Set: on iOS these map toUIRectEdgeforpreferredScreenEdgesDeferringSystemGestures; on Android any non-empty set enters swipe-to-reveal immersive mode (the closest platform analogue). - Font
Spec - The full font descriptor a label carries: a semantic (or custom)
Fontstyle plus an optional weight override and italic flag. Backends resolve this to one native font. - Insets
- Logical insets:
leading/trailingresolve against the layout direction at place time (§7.8). - KeyEvent
- Linear
Gradient - A linear gradient (docs/shapes.md §3.2 / §7): color stops along the line from
starttoend, both in the unit space of the filled shape’s bounding box. Stops are(offset 0..=1, color), ascending. - List
Reorder - The synchronous drag-to-reorder half of
ListSource(docs/list.md). Both closures followbind_row’s discipline: called on the UI thread from inside native drag callbacks, outside any day-core borrow, and they run to completion synchronously. - List
Source - The synchronous row-pull seam for recycling lists (docs/list.md, §10). day-core injects one
per
LISThost viaToolkit::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 — unlikeEventSink— these run to completion synchronously (bind_roweven 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
- Pointer
Event - Proposal
- The layout proposal:
None= unconstrained on that axis (§7.2). - Radial
Gradient - A radial gradient (docs/shapes.md §3.2 / §7): color stops from
centeroutward. 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). Aradiusof0.5from the default center touches the edge midpoints of the bounds. - Rect
- Registry
- Renderer
- A third-party piece’s per-toolkit implementation.
makereceives 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.
primaryis the platform’s command modifier — ⌘ on Apple, Ctrl on GTK/Qt/XAML — so one declaration reads correctly everywhere.keyis a single character ("s",".") or a named key ("Return","Delete","Left","F1"). - Size
- Toolbar
Item - 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.0within the node’s bounds; default center). Distinct from the layout frame — animating aTransformnever 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/…). - Unit
Point - 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).
- Window
Options
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 theRegistryby its stringPieceKind. - Cap
- Curve
- The timing curve of an animation (§8.4). Native backends map each variant onto their own
easing (
CAMediaTimingFunction,QEasingCurve, ArkUIARKUI_CURVE_*, spring animators); the canvas/self-driven path samples it viaCurve::fraction.Springmatches SwiftUI’s.spring(response:dampingFraction:). - Drag
Phase - 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*TextBlockStyleresources 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. - Font
Weight - Font weight, matching
UIFont.Weight/ SwiftUIFont.Weight(lightest → heaviest). Ordered by heaviness, so backends can e.g. map>= Semiboldto a synthesized bold face. - Gesture
Kind - 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 fromresource/imagesfor something only this app has. - Layout
Direction - 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_universalmarks the ones every backend delivers, andToolkit::supports_lifecyclereports per-backend truth. - Menu
BarRole - 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.
- Menu
Item - One entry in a menu (recursive — a
Submenunests). - Menu
Role - 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 existingfill(shape, color)call site compiling unchanged. - Role
- Shape
- Support
- Surface
Role - 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.
- Text
Anchor - How canvas text hangs on its
atpoint (style rule: no bare bools in public APIs). - Toolbar
Item Kind - 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.
- Toolbar
Patch - 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).
- Toolbar
Value - A value a toolbar item produced.
- Window
Kind - What a secondary window IS, so backends can apply platform conventions (docs/windows.md).
- Window
Open Reply - 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 (
tin0.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§
- Event
Sink - 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).
- Measure
Fn - Optional custom measure for a third-party piece (§8.2).
- Piece
Kind - Interned piece-kind key, e.g.
"day.label"or"acme.combobox". - RawHandle
- Raw foreign native handle for polyglot adoption (§15.3).