API Reference

class Ambient

Ambient layer lifecycle: live, throttled, or frozen.

fields

  • covered: Bool
  • frozen: Bool
  • rate: Float
  • visible: Bool
fn advance(dt: Float): Float

Advance the layer clock. Returns the effective delta.

fn freeze(on: Bool)
fn setCovered(on: Bool)
fn setVisible(on: Bool)
fn state(): String
class Build

init(tree: Tree)

fields

fn animate(on: Bool)

Declare whether this view needs continuous frames. A paused view draws once per input event; a running animation draws every frame. The app reads this after the view returns.

fn animating(): Bool
fn button(s: String, onTap: fn(): Void): Node
fn buttonInert(s: String): Node
fn canvas(s: String, w: Int, h: Int, paint: fn(Canvas): Void): Node
fn checkbox(s: String, on: Bool, onToggle: fn(): Void): Node
fn column(): Node
fn dialog(title: String): Node
fn divider(): Node
fn frameClock(): FrameClock

The clock the app ticks before it runs the view.

fn grid(columns: Int): Node
fn handle(): Tree
fn heading(s: String): Node
fn icon(name: String, size: Int): Node

A square glyph from the built-in set: plus, close, check, chevron.

fn image(png: ByteBuffer, w: Int, h: Int): Node

A bitmap control. Bytes are an encoded image; width and height are logical units.

fn item(label: String, onTap: fn(): Void): Node
fn key(k: String)

Key the next node created by a factory.

fn list(): Node
fn listItem(label: String, onTap: fn(): Void): Node
fn menu(labels: Array<String>, onSelect: fn(Int): Void): Node

A vertical menu of actions.

fn menuBar(labels: Array<String>, onSelect: fn(Int): Void): Node

A menu bar: one action per label, reporting its index.

fn menuItem(s: String, onTap: fn(): Void): Node
fn panel(): Node

A surface with padding, without a heading.

fn popover(width: Int): Node

A floating panel; set its edges with left, top, right, or bottom.

fn progress(v: Float): Node
fn radio(s: String, selected: Bool, onTap: fn(): Void): Node
fn row(): Node
fn scroll(): Node
fn searchField(v: String, onChange: fn(String): Void): Node

A text field with a search placeholder.

fn section(title: String): Node
fn segmented(options: Array<String>, selected: Int, onSelect: fn(Int): Void): Node

A radio group laid out as one row.

fn setClock(c: FrameClock)
fn setTextEngine(e: TextEngine)

Replace the text backend before the view runs.

fn slider(s: String): Node
fn sliderValue(s: String, v: Float, onChange: fn(Float): Void): Node
fn spacer(): Node

Empty space that grows in a row or a column.

fn stack(): Node
fn tab(s: String, selected: Bool, onTap: fn(): Void): Node
fn tabs(labels: Array<String>, selected: Int, onSelect: fn(Int): Void): Node

A horizontal tab strip; the selected tab is underlined.

fn text(s: String): Node
fn textField(v: String, placeholder: String, onChange: fn(String): Void): Node
fn toast(message: String): Node

A transient message pinned to the bottom right of its parent.

fn toggle(s: String): Node
fn toggleWith(s: String, onToggle: fn(): Void): Node
fn virtualList(label: String, k: String, total: Int, rowH: Int, viewport: Int): VirtualRange

A fixed-row list viewport. The scroll offset lives on the keyed list node, so the caller only builds count rows starting at first.

fn wrap(): Node
class Camera

A scene camera. Layout stays logical; the camera transforms presentation.

init(scale: Float, x: Float, y: Float)

fields

  • scaleV: Float
  • xV: Float
  • yV: Float
fn copy(): Camera
fn panBy(dx: Float, dy: Float)
fn scale(): Float
fn screenX(worldX: Float): Float
fn screenY(worldY: Float): Float
fn set(scale: Float, x: Float, y: Float)
fn worldX(screenX: Float): Float
fn worldY(screenY: Float): Float
fn x(): Float
fn y(): Float
fn zoomAt(screenX: Float, screenY: Float, factor: Float)

Zoom around a screen point, which stays fixed.

class Canvas

A drawing surface for one canvas node, in local coordinates.

The painter adds the node's origin, so a paint function works in its own space and never sees screen coordinates. Every call appends to the frame's display list.

init(list: DisplayList, ox: Float, oy: Float, width: Float, height: Float, th: Theme)

fields

fn clip(x: Float, y: Float, w: Float, h: Float)
fn clipRound(x: Float, y: Float, w: Float, h: Float, radius: Float)
fn fill(color: Int)
fn h(): Float
fn image(x: Float, y: Float, w: Float, h: Float, png: ByteBuffer)
fn line(color: Int, x0: Float, y0: Float, x1: Float, y1: Float, thickness: Float)

A thick line, drawn as a quad.

fn linearGradient(g: LinearGradient, x: Float, y: Float, w: Float, h: Float)

Fill a rect with a multi-stop linear gradient.

fn pathFill(path: Path, color: Int, evenOdd: Bool)
fn pathStroke(path: Path, color: Int, width: Float, cap: StrokeCap, join: StrokeJoin)
fn polygon(color: Int, points: Array<Float>)

A filled polygon. points is [x0, y0, x1, y1, ...] in local space.

fn popBlur()
fn popLayer()
fn popMask()
fn popTransform()
fn pushBlur(x: Float, y: Float, w: Float, h: Float, sigma: Float)

Start a blur group covering this canvas.

fn pushLayer(alpha: Float)

Start an opacity group covering this canvas.

fn pushLayerBlend(alpha: Float, blend: BlendMode)

Start a group covering this canvas with opacity and a blend mode.

fn pushMask(x: Float, y: Float, w: Float, h: Float, radius: Float)

Start an alpha mask covering this canvas. Not a clip.

fn pushTransform(a: Float, b: Float, c: Float, d: Float, e: Float, f: Float)
fn radialGradient(g: RadialGradient, x: Float, y: Float, w: Float, h: Float)

Fill a rect with a multi-stop radial gradient.

fn rect(color: Int, x: Float, y: Float, w: Float, h: Float)
fn roundRect(color: Int, x: Float, y: Float, w: Float, h: Float, radius: Float)
fn roundRectShadow(color: Int, x: Float, y: Float, w: Float, h: Float, radius: Float, stdDev: Float)
fn roundRectStroke(color: Int, x: Float, y: Float, w: Float, h: Float, radius: Float, width: Float)
fn text(color: Int, x: Float, y: Float, size: Float, s: String)
fn textStyled(color: Int, x: Float, y: Float, size: Float, s: String, weight: Int, italic: Bool, tracking: Float, family: FontFamily, font: FontFace?)

A text run with an explicit weight, italic face, tracking, family, and named face.

fn theme(): Theme
fn unclip()
fn w(): Float
class Computed

A lazily pulled value. Construction does not run the closure; the first get does, and later reads reuse the cache until a dependency version changes. The dependency list and its version vector are both sorted.

init(rx: Reactive, node: Int, comp: Int, f: fn(): T)

fields

  • comp: Int
  • disposed: Bool
  • f: fn(): T
  • node: Int
  • rx: GenRef<Reactive>
  • value: T
fn dispose()
fn get(): T
fn id(): Int
fn version(): Int
class Curve

A timing curve from 0 to 1. Curves never mutate after construction.

init(kind: CurveKind)

fields

  • cx1: Float
  • cx2: Float
  • cy1: Float
  • cy2: Float
  • kindV: CurveKind
  • stepCountV: Int
  • stepJumpV: StepJump
fn evaluate(t: Float): Float

Evaluate at t in 0..1 and return a value in 0..1.

fn kind(): CurveKind
class Damage

Rectangles a frame touched, in surface space.

fields

  • hs: Array<Int>
  • ws: Array<Int>
  • xs: Array<Int>
  • ys: Array<Int>
fn add(x: Int, y: Int, w: Int, h: Int)
fn clear()
fn count(): Int
fn hAt(i: Int): Int
fn wAt(i: Int): Int
fn xAt(i: Int): Int
fn yAt(i: Int): Int
class Decay

Exponential friction. rate is the velocity retained per millisecond, so the analytic position needs no accumulated substeps.

init(rate: Float, value: Float, velocity: Float)

fields

  • elapsed: Float
  • rateV: Float
  • stopSpeedV: Float
  • v0: Float
  • valueV: Float
  • velocityV: Float
  • x0: Float
fn projection(): Float

Where the motion comes to rest.

fn rate(): Float
fn rebase(value: Float, velocity: Float)

Rebase at a value and velocity; the clock starts over.

fn setStopSpeed(s: Float)
fn settled(): Bool
fn step(dt: Float): Float
fn stopSpeed(): Float

Speed below which the animator may stop calling step.

fn value(): Float
fn velocity(): Float
class Display

Reads a finished display list, for snapshots and the inspector.

class DisplayList

A display list, version 3.

The format is little-endian. The 32-byte header is magic, version, records, recordBytes, blobOffset, blobBytes, width, height, all u32. magic is 0x44584E52 (RNXD in byte order). Every record is 64 bytes: kind, color, a, b as u32, then six little-endian f64 lanes named x, y, w, h, e, f. color is 0xRRGGBBAA.

Kinds: 1 fill, 2 text, 3 clip push, 4 clip pop, 5 rounded rect, 6 image, 7 transform push, 8 transform pop, 9 polygon, 10 gradient, 11 path fill, 12 path stroke, 13 layer push, 14 layer pop, 15 rounded rect stroke, 17 blurred rounded shadow, 18 rounded clip push, 19 alpha mask push, 20 mask pop, 21 group blur push, 22 blur pop, 25 multi-stop gradient rect. Text and image records read a and b as a byte range into the blob table that starts at blobOffset; a text record puts the weight plus 10000 for italic in e and the tracking in f. A polygon reads a as the blob offset and b as the point count; each point is two f64 values. A transform uses all six lanes as [a b c d e f]. A rounded rect puts the radius in e. A path reads a as the blob offset and b as the verb count; the blob is the verb bytes followed by the f64 payload. Path fill puts the rule in e; path stroke puts the width in e and the cap/join bits in f. A layer push puts the opacity in e and the blend id in f. A shadow puts the radius in e and the standard deviation in f. A rounded clip puts the radius in e. A mask push puts the corner radius in e; a blur push puts the standard deviation in e. A gradient rect reads a as the blob offset and b as the stop count; each stop is a u32 color then an f32 offset. Its e lane is the kind (0 vertical linear, 1 horizontal linear, 2 radial) and f is the radial radius, where 0 means half the shorter side.

When a frame uses a named font face, the blob starts with a font table: magic 0x464E5432, tableBytes, count, then per face id, nameBytes, name. tableBytes counts from the blob start. Font bytes never enter the list; the renderers receive them once through register_font. Every record a lane that holds a blob offset is shifted by that length before the frame is encoded. Frames that only use generic families carry no table.

The builder owns a fixed record buffer; a command past the limit increments dropped() instead of growing or aborting mid-frame.

init(limit: Int)

fields

  • blob: Array<Int>
  • count: Int
  • damageRects: Damage
  • droppedCount: Int
  • fontIds: Array<Int>
  • fontNames: Array<String>
  • limit: Int
  • records: ByteBuffer
  • scratch: ByteBuffer
fn aAt(i: Int): Int
fn appendPath(path: Path): Int

Append a path blob: the verb bytes first, then the f64 payload.

fn bAt(i: Int): Int
fn blobLength(): Int

Bytes in the unshifted blob table, before a font table is prepended.

fn colorAt(i: Int): Int
fn damage(): Damage

Conservative damage for this frame. Still names the whole surface.

fn describe(i: Int): String

One line per record, for snapshots and the inspector.

fn dropped(): Int
fn eAt(i: Int): Float
fn fAt(i: Int): Float
fn fillRect(color: Int, x: Float, y: Float, w: Float, h: Float)
fn finish(width: Int, height: Int): ByteBuffer

Encode the header, records, and blob table into one buffer. When the frame uses named faces, a font table is prepended to the blob and every record a lane that holds a blob offset is shifted past it.

fn fontCount(): Int

Faces used by this frame, in first-use order.

fn fontTable(): ByteBuffer

Encode the font table: magic, total length, count, then id/name per face.

fn fontTableLength(): Int

Bytes the font table occupies at the start of the blob. Zero when no named face is used.

fn gradientKindAt(i: Int): Int

Gradient kind lane: 0 vertical linear, 1 horizontal linear, 2 radial.

fn gradientRect(stops: Array<GradientStop>, kind: Int, radialRadius: Float, x: Float, y: Float, w: Float, h: Float)

A rect filled by a multi-stop gradient. Stops are sorted by offset and clamped to 0..1 before they reach the blob. Fewer than two stops or a non-positive rect emits nothing.

fn hAt(i: Int): Float
fn image(x: Float, y: Float, w: Float, h: Float, png: ByteBuffer)

Draw a PNG into the given rectangle.

fn kindAt(i: Int): Int
fn pathFill(path: Path, color: Int, evenOdd: Bool)

Fill a path with the nonzero or even-odd rule.

fn pathStroke(path: Path, color: Int, width: Float, cap: StrokeCap, join: StrokeJoin)

Stroke a path. f packs the cap in bits 0..1 and the join in 2..3.

fn polygon(color: Int, points: Array<Float>)

A filled polygon. points is [x0, y0, x1, y1, ...].

fn polygonAt(color: Int, points: Array<Float>, dx: Float, dy: Float)

A filled polygon shifted by dx, dy. The shift happens while the points are copied into the blob, so a canvas does not allocate a temporary array on every frame.

fn popBlur()
fn popClip()
fn popLayer()
fn popMask()
fn popTransform()
fn pushBlur(x: Float, y: Float, w: Float, h: Float, sigma: Float)

Push a group blur. sigma is the standard deviation. Kind 22 pops it.

fn pushClip(x: Float, y: Float, w: Float, h: Float)
fn pushClipRound(x: Float, y: Float, w: Float, h: Float, radius: Float)

Push a clip with rounded corners. Kind 4 pops it, like a rect clip.

fn pushLayer(x: Float, y: Float, w: Float, h: Float, alpha: Float, blend: Int)

Start an offscreen group with group opacity and an encoded blend id.

fn pushMask(x: Float, y: Float, w: Float, h: Float, radius: Float)

Push an alpha mask over the group. radius rounds the mask rectangle; this is an alpha mask, not a clip. Kind 20 pops it.

fn pushTransform(a: Float, b: Float, c: Float, d: Float, e: Float, f: Float)

Push a 2D affine transform: [a b c d e f].

fn recordCount(): Int
fn roundRect(color: Int, x: Float, y: Float, w: Float, h: Float, radius: Float)
fn roundRectGradient(top: Int, bottom: Int, x: Float, y: Float, w: Float, h: Float, radius: Float)

A rounded rect filled by a vertical gradient from top to bottom.

fn roundRectShadow(color: Int, x: Float, y: Float, w: Float, h: Float, radius: Float, stdDev: Float)

A blurred rounded rect behind a node. e is the radius, f the blur.

fn roundRectStroke(color: Int, x: Float, y: Float, w: Float, h: Float, radius: Float, width: Float)

A rounded rect outline. e is the radius and f the stroke width.

fn stopCountAt(i: Int): Int

Stop count for a gradient rect record.

fn textAt(i: Int): String
fn textRun(color: Int, x: Float, y: Float, size: Float, s: String, weight: Int, italic: Bool, tracking: Float, family: FontFamily, font: FontFace?)

A text run. e carries the font weight plus 10000 when the face is italic and 1000000 per family tag, and f carries extra tracking in logical pixels. A named font packs its registry id (100 and up) in place of the generic family id.

fn toString(): String
fn wAt(i: Int): Float
fn xAt(i: Int): Float
fn yAt(i: Int): Float
class DragData

The arena. Ids are creation order until keyed reconciliation lands.

A typed drag payload. kind selects which drop targets accept it.

init(kind: String, text: String)

fields

  • kind: String
  • text: String
fn accepts(kinds: String): Bool

True when a comma-separated accept list contains this kind or *.

class Effect

A side effect queued by the graph. It never runs during construction or from set; drain runs it once per frame. run only schedules it again.

init(rx: Reactive, comp: Int)

fields

  • comp: Int
  • disposed: Bool
  • rx: GenRef<Reactive>
fn dispose()
fn id(): Int
fn run()
class Elevation

Shadow offset, blur, and alpha for one elevation level.

init(dx: Float, dy: Float, blur: Float, alpha: Float)

fields

  • alpha: Float
  • blur: Float
  • dx: Float
  • dy: Float
class ElevationScale

Six shadow steps. Level 0 is flat, so cards keep their old look by default.

init(level0: Elevation, level1: Elevation, level2: Elevation, level3: Elevation, level4: Elevation, level5: Elevation)

fields

fn at(level: Int): Elevation

Resolve the integer lane stored on a node; 0 is flat.

fn elevation(t: ElevationToken): Elevation
fn replace(t: ElevationToken, e: Elevation): ElevationScale
class FontFace

A named font face. id is the family tag packed into text records; the registry assigns ids from 100 so they cannot collide with FontFamily.

init(id: Int, name: String, data: ByteBuffer)

fields

  • data: ByteBuffer
  • id: Int
  • name: String
class FontRegistry

Named font faces for one app. The registry is bounded: at most 16 faces and 8 MB of font data. Ids are dense from 100 in registration order.

fields

fn at(i: Int): FontFace?
fn bytes(): Int
fn find(name: String): FontFace?
fn len(): Int
fn register(name: String, data: ByteBuffer): FontFace?

Register one face, or return null when the name/data is empty or a cap is hit.

class FrameClock

Frame timing for animation.

tick takes a monotonic nanosecond reading and exposes the time since the last frame plus the total running time. While paused, a tick keeps the baseline current but does not advance time, so animations freeze rather than jump when they resume.

fields

  • deltaNs: Int
  • elapsedNs: Int
  • last: Int
  • pausedFlag: Bool
  • ticks: Int
fn dt(): Float

Seconds since the previous tick, zero while paused.

fn elapsed(): Float

Seconds of animation time since the clock started.

fn frames(): Int
fn paused(): Bool
fn reset()
fn setPaused(p: Bool)
fn tick(nowNs: Int)
class FramePacket

One buffer carrying each live node's layout and semantics.

init(packetWidth: Int, packetHeight: Int, packetScale: Int, packetColor: Int, packetFlags: Int)

fields

  • actionsV: Array<Int>
  • color: Int
  • flags: Int
  • flagsV: Array<Int>
  • height: Int
  • hs: Array<Int>
  • ids: Array<Int>
  • names: Array<String>
  • parents: Array<Int>
  • roles: Array<Int>
  • scale: Int
  • values: Array<String>
  • width: Int
  • ws: Array<Int>
  • xs: Array<Int>
  • ys: Array<Int>
fn at(i: Int): FrameNode
fn count(): Int
fn describe(): String
class GestureArena

One arena per stage. A claim holds until release.

fields

  • active: Int
  • axes: Array<Int>
  • depths: Array<Int>
  • owners: Array<Int>
  • priorities: Array<Int>
  • trace: Array<String>
fn activeNode(): Int
fn add(axis: GestureAxis, priority: Int, depth: Int, node: Int): Int
fn begin(axis: GestureAxis): Int

Resolve a gesture start on an axis. Returns the winning node id.

fn beginAxis(axis: Int): Int
fn clear()
fn lastDecision(): String

Last few decisions, for dev builds and tests.

fn release()
fn size(): Int
class GradientStop

One stop in a multi-stop gradient. offset runs from 0 to 1.

init(offset: Float, color: Int)

fields

  • color: Int
  • offset: Float
class ImageSize

A bitmap's intrinsic dimensions, read from its format header.

init(width: Int, height: Int)

fields

  • height: Int
  • width: Int
class Keyframe

One hold point in a KeyframeTrack: a time, a value, and the curve out.

init(at: Float, value: Float, curve: Curve)

fields

  • at: Float
  • curve: Curve
  • value: Float
class KeyframeTrack

A sorted keyframe track sampled at an absolute elapsed time.

Frames are stored in ascending at order regardless of input order; a negative time is clamped to zero. When two frames share a timestamp the later one in the input wins, so a caller can override a hold point by appending it. Sampling is pure: the track has no clock and no accumulated state, so the same t always yields the same value.

A looping track wraps t beyond duration() back through zero. A non-looping track clamps before the first frame and after the last one. Between frames, the outgoing frame's curve shapes the local progress, and a zero-length segment returns the later value.

init(frames: Array<Keyframe>, loop: Bool)

fields

fn duration(): Float

Time of the last frame, or zero for an empty track.

fn frameCount(): Int
fn loopOn(): Bool
fn setLoop(on: Bool)

Toggle the loop wrap in place.

fn valueAt(t: Float): Float

Sample at an absolute elapsed time in seconds.

fn withLoop(on: Bool): KeyframeTrack

A copy that keeps or drops the loop wrap.

class LinearGradient

A linear gradient, vertical by default.

init(stops: Array<GradientStop>, horizontal: Bool)

fields

class LinkRect

One screen-space link rectangle on a text node.

init(url: String, text: String, x: Int, y: Int, w: Int, h: Int)

fields

  • h: Int
  • text: String
  • url: String
  • w: Int
  • x: Int
  • y: Int
class Match

Interpolate between two rectangles with a spring.

init(fx: Float, fy: Float, fw: Float, fh: Float, tx: Float, ty: Float, tw: Float, th: Float)

fields

  • fromH: Float
  • fromW: Float
  • fromX: Float
  • fromY: Float
  • spring: Spring
  • toH: Float
  • toW: Float
  • toX: Float
  • toY: Float
fn close()
fn done(): Bool
fn h(): Float
fn open()
fn progress(): Float
fn setTargets(tx: Float, ty: Float, tw: Float, th: Float)
fn step(dt: Float): Float
fn w(): Float
fn x(): Float
fn y(): Float
class Motion

One scalar slot driven by a curve, a spring, or a decay.

init(kind: MotionKind, duration: Float, curve: Curve, spring: Spring, decay: Decay)

fields

  • curveV: Curve
  • decayV: Decay
  • doneV: Bool
  • durationV: Float
  • fromV: Float
  • kindV: MotionKind
  • springV: Spring
  • time: Float
  • toV: Float
  • valueV: Float
  • velocityV: Float
fn done(): Bool
fn fling(velocity: Float)

Start a friction fling from the present value. Only decay tracks.

fn kind(): MotionKind
fn setTarget(target: Float)
fn setValue(v: Float)

Place the track at v without animating.

fn step(dt: Float): Float
fn to(target: Float)

Animate from the present value to target. Decay ignores this.

fn value(): Float
fn velocity(): Float
class MotionScale

The motion steps. Fast, normal, and slow carry the same duration and curve pairs Transition shipped with; spring carries the defaults of Spring.

init(fast: MotionSpec, normal: MotionSpec, slow: MotionSpec, spring: MotionSpec)

fields

fn motion(t: MotionToken): MotionSpec
fn replace(t: MotionToken, m: MotionSpec): MotionScale
class MotionSpec

Duration and curve, plus the spring constants for the spring token.

init(duration: Float, curve: Curve, stiffness: Float, damping: Float)

fields

  • curve: Curve
  • damping: Float
  • duration: Float
  • stiffness: Float
fn spring(): Spring
fn transition(): Transition
class Overview

Overview camera: fits a set of window rectangles into the viewport.

init(viewW: Int, viewH: Int, padding: Int)

fields

  • camera: Camera
  • hs: Array<Int>
  • ids: Array<Int>
  • openV: Bool
  • padding: Int
  • saved: Camera
  • titles: Array<String>
  • viewH: Int
  • viewW: Int
  • ws: Array<Int>
  • xs: Array<Int>
  • ys: Array<Int>
fn add(id: Int, x: Int, y: Int, w: Int, h: Int, title: String)
fn card(i: Int): WindowCard
fn count(): Int
fn enter()

Enter the overview, remembering the current camera.

fn exit()

Leave the overview and restore the previous camera in place.

fn fit(): Camera

Fit every card into the viewport with padding and return the camera.

fn fits(i: Int): Bool

True when a card lies inside the viewport after fitting.

fn isOpen(): Bool
fn screenH(i: Int): Float
fn screenW(i: Int): Float
fn screenX(i: Int): Float

Screen rectangle of a card under the overview camera.

fn screenY(i: Int): Float
class Painter
class Path

A path in device coordinates.

The verb bytes and the little-endian f64 payload live in two growable buffers, so a display list appends them as one blob without re-encoding.

init()

fields

  • bytes: Int
  • coordBytes: Int
  • data: ByteBuffer
  • scratch: ByteBuffer
  • verbCount: Int
fn close()
fn cubicTo(c1x: Float, c1y: Float, c2x: Float, c2y: Float, x: Float, y: Float)
fn lineTo(x: Float, y: Float)
fn moveTo(x: Float, y: Float)
fn quadTo(cx: Float, cy: Float, x: Float, y: Float)
fn rect(x: Float, y: Float, w: Float, h: Float)
fn translated(dx: Float, dy: Float): Path

A copy with every point shifted by dx, dy.

class RadialGradient

A radial gradient. A zero radius means half the shorter side.

init(stops: Array<GradientStop>, radius: Float)

fields

class RadiusScale

Corner radii. md is the 6 px control radius, lg the 10 px section and dialog radius, sm the 4 px accent radius. pill returns -1, meaning half the short side; callers that paint pill shapes use that sentinel. list is the 8 px radius the list role already used.

init(none: Float, sm: Float, md: Float, lg: Float, pill: Float, list: Float)

fields

  • lgV: Float
  • listV: Float
  • mdV: Float
  • noneV: Float
  • pillV: Float
  • smV: Float
fn chrome(role: Int): Float

Role mapping shared by paint and component defaults.

fn radius(t: RadiusToken): Float
fn replace(t: RadiusToken, v: Float): RadiusScale
class Reactive

One reactive graph. Signals and computeds are nodes in dense arrays; the computations that read them are tracked on an explicit stack owned by this instance. Nothing here is shared between contexts, so two Reactive values never see each other's dependencies.

init()

fields

  • batchDepth: Int
  • cDepVer: Array<Array<Int>>
  • cDeps: Array<Array<Int>>
  • cDirty: Array<Bool>
  • cKind: Array<Int>
  • cLive: Array<Bool>
  • cNode: Array<Int>
  • cQueued: Array<Bool>
  • cReady: Array<Bool>
  • cRun: Array<fn(): Void>
  • cRunning: Array<Bool>
  • compFace: Array<View>
  • compFrame: Array<Int>
  • compKeys: Array<String>
  • compRuns: Array<Int>
  • compView: Array<View>
  • cycleAt: Int
  • cycled: Bool
  • draining: Bool
  • frame: Int
  • nComputed: Array<Int>
  • nLive: Array<Bool>
  • nSubs: Array<Array<Int>>
  • nVersion: Array<Int>
  • queue: Array<Int>
  • stack: Array<Int>
  • trace: Array<Array<Int>>
fn alive(kind: String, id: Int): Bool

kind is "signal", "computed", or "effect"; id comes from the handle.

fn batch(f: fn(): Void)

Coalesce writes; the outermost batch drains once at the end.

fn beginCompute(comp: Int): Bool

Start a computation when it is new or a dependency changed.

fn beginFrame()

Start a frame so endFrame can prune components that were not used.

fn bump(node: Int)

Bump a node and mark everything downstream.

fn clearCycle()
fn component(key: String, build: fn(): View): View

A keyed subtree boundary. The builder runs inside the component's computation scope, so a signal read in the builder subscribes the component. A clean component returns the same face view and does not run the builder. An empty key mounts the builder directly with no caching.

Component state outlives ordinary view rebuilds because the cached view and dependency set live in this graph. A key the view stops asking for is detached by endFrame; without a frame call it is retained, because the graph has no process-global observer to learn that the key disappeared. A detached slot stays dead so the ids of surviving components remain stable.

fn componentDirty(key: String): Bool
fn componentRebuilds(key: String): Int
fn componentViewAt(comp: Int): View?

The cached view of a component, or null when the id is not live.

fn computed(f: fn(): T): Computed<T>
fn cycleDetected(): Bool

True when a dependency cycle was cut instead of recursing.

fn cycleId(): Int
fn drain(): Int

Run queued effects once in id order. Inside a batch this waits.

fn effect(f: fn(): Void): Effect
fn endCompute(comp: Int, node: Int)

Commit the read set and clear the dirty flag.

fn endFrame()

Detach components that were not asked for during the frame. Ids and dependency arrays are dropped; the slot stays dead so other ids remain stable. Iteration is ascending by id.

fn frameNeeded(): Bool

True when a queued effect or a dirty component wants another frame.

fn freeComputed(node: Int, comp: Int)
fn freeEffect(comp: Int)
fn freeNode(node: Int)
fn nodeAlive(node: Int): Bool
fn scheduleEffect(comp: Int)
fn signal(value: T): Signal<T>
fn trackRead(node: Int)

Record a read edge into the computation on top of the stack.

fn versionOf(node: Int): Int
class RichRows

Rows plus the shaped runs that paint them.

init(rows: Array<TextRow>, runs: Array<TextRun>)

fields

  • rows: Array<TextRow>
  • runs: Array<TextRun>
class Sheet

A detented sheet driven by a spring.

init(detents: Array<Float>)

fields

  • detents: Array<Float>
  • indexV: Int
  • spring: Spring
fn dragBy(dy: Float)

Drag the sheet by dy logical units, clamped to the detent range.

fn go(i: Int)
fn height(): Float
fn index(): Int
fn release(velocity: Float)

Settle to the next detent, or the previous one on a fast fling.

fn settled(): Bool
fn step(dt: Float): Float
class Shortcuts

Named keyboard chords. A chord is normalized to lower case, so Ctrl+S and ctrl+s are the same binding. The last bind for a chord replaces the previous handler; the return value says whether it replaced one.

fields

  • counter: Int
  • current: Int
  • handlers: Array<fn(): Void>
  • keys: Array<String>
  • nextScope: Array<Int>
  • scopes: Array<Int>
fn bind(chord: String, run: fn(): Void): Bool
fn bindScoped(scope: Int, chord: String, run: fn(): Void): Bool
fn clear()
fn len(): Int
fn popScope()
fn pushScope(): Int

Push a scope that shadows global chords until it is popped.

fn run(chord: String): Bool
fn scope(): Int
class Signal

One value in a reactive graph. Reads inside a computation record an edge; writes bump the node and schedule its subscribers. A disposed signal keeps its last value and ignores writes.

init(rx: Reactive, node: Int, tag: Int, value: T)

fields

  • node: Int
  • rx: GenRef<Reactive>
  • tag: Int
  • value: T
fn dispose()
fn get(): T
fn id(): Int
fn set(value: T): Bool
fn update(f: fn(T): T): Bool
fn version(): Int
class SpaceScale

Spacing steps in logical pixels. Standard matches the shipped defaults: 12 is the page gap, 16 the default container inset and card padding, 24 the page padding. Compact scales spacing without touching type.

init(xs: Int, sm: Int, md: Int, lg: Int, xl: Int, xxl: Int)

fields

  • lgV: Int
  • mdV: Int
  • smV: Int
  • xlV: Int
  • xsV: Int
  • xxlV: Int
fn replace(t: SpaceToken, v: Int): SpaceScale
fn space(t: SpaceToken): Int
class Spring

A damped spring solved in closed form. step advances an analytic clock, so the result does not depend on the frame rate. Retargeting keeps the present value and velocity; interrupting holds the present value and stops.

init(stiffness: Float, damping: Float, value: Float)

fields

  • damping: Float
  • elapsed: Float
  • fromV: Float
  • stiffness: Float
  • targetV: Float
  • valueV: Float
  • vel0: Float
  • velocityV: Float
fn interrupt()

Hold the present value with no velocity.

fn retarget(t: Float)
fn setTarget(t: Float)

Move to a new target while keeping value and velocity.

fn setValue(v: Float)

Place the present value and cancel any motion.

fn settled(): Bool
fn step(dt: Float): Float
fn target(): Float
fn value(): Float
fn velocity(): Float
class Stage

A stage: content, overlay, sheet, ambient, and gesture arbitration.

init(tree: Tree, content: Int, overlay: Int, ambient: Ambient, sheet: Sheet)

fields

fn dismiss()

Lower the sheet: restore content, focus, and the ambient rate.

fn isOpen(): Bool
fn occludes(): Bool

The stage occludes the ambient layer while a sheet is up.

fn present(first: Node)

Raise the sheet: inert content, focus into the overlay, ambient throttled.

fn sync()

Re-apply the layer state after a tree rebuild. Node flags reset every frame, so onMount calls this while the stage is open.

class TextEngine

A text measurement and line-breaking backend.

@std/ui is headless, so it never shapes text itself. The app supplies an engine backed by the platform shaper; the default engine measures a fixed advance per character, which keeps tests and headless runs deterministic.

init(m: fn(String, Float): Float, r: fn(String, Float, Float, Bool, Int, Bool): Array<TextRow>, n: fn(String, Int): Int, p: fn(String, Int): Int)

fields

  • measureFn: fn(String, Float): Float
  • nextFn: fn(String, Int): Int
  • prevFn: fn(String, Int): Int
  • richRowsFn: fn(String, Float, Float, Bool, Int, Bool, Array<TextSpan>, Float): RichRows
  • rowsFn: fn(String, Float, Float, Bool, Int, Bool): Array<TextRow>
  • styledMeasureFn: fn(String, Float, Int, Bool, Float): Float
  • styledRowsFn: fn(String, Float, Float, Bool, Int, Bool, Int, Bool, Float, Float): Array<TextRow>
fn measure(s: String, size: Float): Float

Width of one unwrapped line.

fn measureStyled(s: String, size: Float, weight: Int, italic: Bool, tracking: Float): Float

Width of one unwrapped line with an explicit weight, italic, and tracking.

fn nextGrapheme(s: String, at: Int): Int

Character index after the grapheme that starts at at.

fn prevGrapheme(s: String, at: Int): Int

Character index of the grapheme boundary before at.

fn richRows(s: String, size: Float, maxWidth: Float, wrap: Bool, maxLines: Int, ellipsis: Bool, spans: Array<TextSpan>, lineHeight: Float): RichRows

Break s into rows and shaped runs with inline spans.

fn rows(s: String, size: Float, maxWidth: Float, wrap: Bool, maxLines: Int, ellipsis: Bool): Array<TextRow>

Break s into rows. maxWidth <= 0 disables wrapping and ellipsis.

fn rowsStyled(s: String, size: Float, maxWidth: Float, wrap: Bool, maxLines: Int, ellipsis: Bool, weight: Int, italic: Bool, lineHeight: Float, tracking: Float): Array<TextRow>

Break s into rows with an explicit style. lineHeight is 0.0 for the normal spacing or a multiplier of the font size.

fn setRich(r: fn(String, Float, Float, Bool, Int, Bool, Array<TextSpan>, Float): RichRows)

Install a shaper that also returns the shaped runs for inline spans.

fn setStyled(m: fn(String, Float, Int, Bool, Float): Float, r: fn(String, Float, Float, Bool, Int, Bool, Int, Bool, Float, Float): Array<TextRow>)

Install a styled shaper. Until this is called, the styled methods delegate to the plain functions and ignore the style lanes.

class TextRun

One shaped run inside a row. x is the offset from the row origin.

init(row: Int, start: Int, end: Int, x: Float, advance: Float, flags: Int)

fields

  • advance: Float
  • end: Int
  • flags: Int
  • row: Int
  • start: Int
  • x: Float
class TextSpan

One inline style range. Offsets count characters, the same way s.slice does. Overlapping spans resolve to the last span that covers the offset. color < 0 keeps the role color the node already uses. A non-empty link paints the run as a link and lets the tree hit-test it.

init(start: Int, end: Int, weight: Int, italic: Bool, tracking: Float, color: Int, family: FontFamily, decoration: TextDecoration, font: FontFace?, link: String)

fields

fn decorationBits(): Int

Wire decoration bits for the shaper's style word.

fn fontFamilyId(): Int

Wire family id for the shaper's style word. A named face wins over the generic family.

class Theme

Colors used by the built-in painter. Brand kits pass their own.

init(background: Int, surface: Int, text: Int, accent: Int, muted: Int, border: Int, surfaceRaised: Int, surfaceSunken: Int, textMuted: Int, accentHover: Int, accentText: Int, focus: Int, danger: Int, success: Int, warning: Int, disabled: Int, typeScale: TypeScale?, spaceScale: SpaceScale?, radiusScale: RadiusScale?, elevationScale: ElevationScale?, motionScale: MotionScale?)

fields

  • accent: Int
  • accentHover: Int
  • accentText: Int
  • background: Int
  • border: Int
  • danger: Int
  • disabled: Int
  • elevationScale: ElevationScale
  • focus: Int
  • motionScale: MotionScale
  • muted: Int
  • radiusScale: RadiusScale
  • spaceScale: SpaceScale
  • success: Int
  • surface: Int
  • surfaceRaised: Int
  • surfaceSunken: Int
  • text: Int
  • textMuted: Int
  • typeScale: TypeScale
  • warning: Int
fn elevation(token: ElevationToken): Elevation
fn motion(token: MotionToken): MotionSpec
fn radius(token: RadiusToken): Float
fn space(token: SpaceToken): Int
fn type(token: TypeToken): TypeStyle

Resolve a type token to its size, weight, line height, and tracking.

fn withElevation(token: ElevationToken, e: Elevation): Theme
fn withElevationScale(s: ElevationScale): Theme
fn withMotion(token: MotionToken, m: MotionSpec): Theme
fn withMotionScale(s: MotionScale): Theme
fn withRadius(token: RadiusToken, v: Float): Theme
fn withRadiusScale(s: RadiusScale): Theme
fn withSpace(token: SpaceToken, v: Int): Theme
fn withSpaceScale(s: SpaceScale): Theme
fn withType(token: TypeToken, s: TypeStyle): Theme
fn withTypeScale(s: TypeScale): Theme
class Transition

A declarative enter and leave transition for Presence.

init(duration: Float, curve: Curve, fade: Bool)

fields

  • curve: Curve
  • duration: Float
  • fade: Bool
class Tree

init(e: TextEngine)

fields

  • absV: Array<Bool>
  • accentV: Array<Bool>
  • actions: Array<Int>
  • alignSelfV: Array<Int>
  • aligned: Bool
  • autoV: Array<Bool>
  • blendV: Array<Int>
  • blurSigmaV: Array<Float>
  • bottomV: Array<Int>
  • busyV: Array<Bool>
  • cacheAvail: Array<Int>
  • cacheExact: Array<Bool>
  • cacheH: Array<Int>
  • cacheVer: Array<Int>
  • cacheW: Array<Int>
  • canvasHandler: Array<Int>
  • canvasHandlers: Array<fn(Canvas): Void>
  • caretV: Array<Int>
  • checked: Array<Bool>
  • claimed: Array<Bool>
  • clipRadiusV: Array<Float>
  • clipV: Array<Bool>
  • columnsV: Array<Int>
  • controlsIdV: Array<Int>
  • count: Array<Int>
  • crossAlignV: Array<Int>
  • cursor: Int
  • cursorHandler: fn(Int): Void
  • cursorShapeV: Int
  • densityV: Float
  • describedByIdV: Array<Int>
  • descriptionV: Array<String>
  • disabledV: Array<Bool>
  • dragDataV: DragData?
  • dragDxV: Float
  • dragDyV: Float
  • dragKindV: Array<String>
  • dragNodeV: Int
  • dragPhaseV: Int
  • dragPointerV: Int
  • dragSourceV: Int
  • dragTextV: Array<String>
  • dragVelXV: Float
  • dragVelYV: Float
  • dropHandlerV: Array<Int>
  • dropHandlers: Array<fn(DragData): Void>
  • dropHoverV: Int
  • dropKindsV: Array<String>
  • elevationV: Array<Int>
  • engine: TextEngine
  • expandedV: Array<Int>
  • first: Array<Int>
  • fixedH: Array<Int>
  • fixedW: Array<Int>
  • focus: Int
  • focusVisible: Bool
  • fontWeightV: Array<Int>
  • frameDtV: Float
  • frameOpen: Bool
  • gapPctV: Array<Float>
  • gapPxV: Array<Int>
  • gapV: Array<Int>
  • gestureTimeV: Float
  • gradientV: Array<Bool>
  • growV: Array<Float>
  • h: Array<Int>
  • handler: Array<Int>
  • handlers: Array<fn(): Void>
  • hovered: Int
  • idealHV: Array<Int>
  • idealWV: Array<Int>
  • imageFitV: Array<Int>
  • imageIntrHV: Array<Int>
  • imageIntrWV: Array<Int>
  • imageV: Array<ByteBuffer>
  • inertV: Array<Bool>
  • invalidV: Array<Int>
  • italicV: Array<Bool>
  • key: Array<String>
  • keyIndexIds: Array<Int>
  • keyIndexKeys: Array<String>
  • keyboardV: Int
  • labelIdV: Array<Int>
  • last: Array<Int>
  • lastDropTargetV: Int
  • lastDropV: DragData?
  • lastScroller: Int
  • lastTapXV: Float
  • lastTapYV: Float
  • leftV: Array<Int>
  • letterSpacingV: Array<Float>
  • levelV: Array<Int>
  • lineHeightV: Array<Float>
  • linkHandler: fn(String): Void
  • live: Array<Bool>
  • liveV: Array<Int>
  • longPressLatched: Bool
  • mainAlignV: Array<Int>
  • marginV: Array<Int>
  • maskRadiusV: Array<Float>
  • maxHV: Array<Int>
  • maxWV: Array<Int>
  • measureHits: Int
  • measureVer: Int
  • minHV: Array<Int>
  • minWV: Array<Int>
  • name: Array<String>
  • next: Array<Int>
  • numberHandler: Array<Int>
  • numberHandlers: Array<fn(Float): Void>
  • numberV: Array<Float>
  • offsetYV: Array<Float>
  • opacityV: Array<Float>
  • orderV: Array<Int>
  • padV: Array<Int>
  • parent: Array<Int>
  • pendingKey: String
  • pinchActiveV: Bool
  • pinchRotationV: Float
  • pinchScaleV: Float
  • pinchSlotA: Int
  • pinchSlotB: Int
  • pinchStartAngleV: Float
  • pinchStartDistV: Float
  • pointerButtonV: Array<Int>
  • pointerDownV: Array<Bool>
  • pointerHoldV: Array<Float>
  • pointerIds: Array<Int>
  • pointerLastX: Array<Float>
  • pointerLastY: Array<Float>
  • pointerLinkV: Array<String>
  • pointerLongFired: Array<Bool>
  • pointerNodeV: Array<Int>
  • pointerPhaseV: Array<Int>
  • pointerSampleN: Array<Int>
  • pointerSampleT: Array<Int>
  • pointerSampleX: Array<Float>
  • pointerSampleY: Array<Float>
  • pointerStartX: Array<Float>
  • pointerStartY: Array<Float>
  • pointerTimed: Array<Bool>
  • portalLayerV: Array<Int>
  • portalV: Array<Bool>
  • preeditV: Array<String>
  • presenceCurves: Array<Curve>
  • presenceDurations: Array<Float>
  • presenceKeys: Array<String>
  • presenceProgress: Array<Float>
  • presenceRaw: Array<Float>
  • presenceTarget: Array<Float>
  • presenceTouched: Array<Bool>
  • pressed: Int
  • prevBlend: Array<Int>
  • prevBlurSigma: Array<Float>
  • prevCaret: Array<Int>
  • prevChecked: Array<Bool>
  • prevDisabled: Array<Bool>
  • prevFocus: Int
  • prevFocusVisible: Bool
  • prevH: Array<Int>
  • prevHovered: Int
  • prevMaskRadius: Array<Float>
  • prevName: Array<String>
  • prevNumber: Array<Float>
  • prevOpacity: Array<Float>
  • prevPreedit: Array<String>
  • prevPressed: Int
  • prevRole: Array<Int>
  • prevSelEnd: Array<Int>
  • prevSelStart: Array<Int>
  • prevValue: Array<String>
  • prevW: Array<Int>
  • prevX: Array<Int>
  • prevY: Array<Int>
  • raisedV: Array<Bool>
  • rangeMaxV: Array<Float>
  • rangeMinV: Array<Float>
  • rangeStepV: Array<Float>
  • ratioV: Array<Float>
  • requiredV: Array<Bool>
  • richHandler: Array<Int>
  • richHandlers: Array<fn(String, Array<TextSpan>): Void>
  • rightV: Array<Int>
  • role: Array<Int>
  • root: Int
  • roundV: Array<Bool>
  • rovingV: Array<Bool>
  • rtlV: Bool
  • safeB: Int
  • safeL: Int
  • safeR: Int
  • safeT: Int
  • scope: Int
  • scopePrevFocus: Int
  • scrollDecayV: Array<Decay>
  • scrollFlingV: Array<Bool>
  • scrollMax: Array<Float>
  • scrollOverV: Array<Float>
  • scrollSpringV: Array<Spring>
  • scrollV: Array<Float>
  • scrollVelV: Array<Float>
  • selEndV: Array<Int>
  • selStartV: Array<Int>
  • selectedV: Array<Bool>
  • seqNext: Int
  • seqV: Array<Int>
  • shadowBlurV: Array<Float>
  • shadowColorV: Array<Int>
  • shadowDxV: Array<Float>
  • shadowDyV: Array<Float>
  • shadowRadiusV: Array<Float>
  • shrinkV: Array<Float>
  • sizeV: Array<Int>
  • tapCountV: Int
  • tapPendingV: Bool
  • tapTimeV: Float
  • textAlignV: Array<Int>
  • textCacheSigV: Array<Int>
  • textCacheTextV: Array<String>
  • textHandler: Array<Int>
  • textHandlers: Array<fn(String): Void>
  • textLayoutV: Array<TextLayout>
  • textLines: Array<Int>
  • textScaleV: Float
  • textSizeV: Array<Int>
  • textSpansV: Array<Array<TextSpan>>
  • textWrapV: Array<Bool>
  • themeV: Theme
  • toneV: Array<Int>
  • tooltipV: Array<String>
  • topV: Array<Int>
  • value: Array<String>
  • verticalV: Bool
  • w: Array<Int>
  • x: Array<Int>
  • y: Array<Int>
  • zV: Array<Int>
fn actionsOf(id: Int): Int
fn adjust(n: Node, delta: Float): Bool

Move a slider by delta, using the same path as the arrow keys.

fn attach(p: Int, c: Int)

Link a child under a parent, keeping child order.

fn beginFrame()

Start a frame. Existing nodes become reusable and handlers are cleared.

fn blendOf(n: Node): Int

Encoded blend id of a node, 0 for normal.

fn blurSigmaOf(n: Node): Float

Group blur standard deviation of a node, 0 when it has no blur.

fn button(s: String, onTap: fn(): Void): Node
fn buttonInert(s: String): Node
fn can(n: Node, a: Action): Bool
fn canvas(s: String, w: Int, h: Int, paint: fn(Canvas): Void): Node

A fixed-size node that draws itself. The paint function runs during painting with a {@link Canvas} clipped to the node's rectangle, so an animation is a pure function of the frame clock and draws every frame.

fn caretX(n: Node): Int

Caret x offset inside a text box, in local coordinates.

fn checkbox(s: String, on: Bool, onToggle: fn(): Void): Node
fn checkedOf(id: Int): Bool
fn childCount(n: Node): Int
fn clearDropResult()

Forget the last completed drop so the next one reports cleanly.

fn clearFocusScope()
fn clearLongPress()

Consume the latched long press so a view reports it once.

fn clearPreedit(n: Node)
fn clipRadiusOf(n: Node): Float

Rounded clip radius of a node, 0 when it clips to a rectangle.

fn commit()

Close the frame and drop focus from nodes that were not rebuilt.

Snapshot the presented state. Call once after painting a frame, so input that arrives between frames is compared against what the screen shows rather than against a value that was already mutated by the event.

fn controlsIdOf(id: Int): Int
fn cursorShape(): Int

Current cursor shape id: 0 default, 1 text, 2 pointer.

fn damageOf(width: Int, height: Int, full: Bool): Damage

Rectangles that changed since the previous frame, in surface space. full forces the whole surface, which the first frame and a resize need because the target starts undefined.

fn deleteBackward(n: Node): Bool
fn deleteForward(n: Node): Bool
fn deleteSurrounding(n: Node, before: Int, after: Int): Bool

Delete text around the caret, as an IME does for surrounding text.

fn density(): Float
fn describedByIdOf(id: Int): Int
fn disabledAt(id: Int): Bool
fn dp(n: Int): Int

Convert logical units to device pixels at the current density.

fn dragDx(): Float
fn dragDy(): Float
fn dragNode(): Int

The node that owns the current drag.

fn dragPayload(): DragData?

The active drag payload, or null when the drag is plain or finished.

fn dragPhase(): Int

Drag lifecycle: 0 none, 1 began, 2 changed, 3 ended, 4 cancelled.

fn dragVelocityX(): Float
fn dragVelocityY(): Float
fn dragging(id: Int): Bool

Whether this pointer id owns the active drag.

fn dropHover(): Int

The node currently accepting the active payload, or -1.

fn dropTargetAt(px: Int, py: Int, kind: String): Int

The nearest node at the point that accepts kind: the hit node first, then its ancestors. Returns -1 when nothing accepts.

fn effectsChanged(): Bool

True when any mask or blur lane differs from the committed frame.

fn endFrame()
fn find(r: Role, n: String): Int
fn firstRole(r: Role): Int
fn focusIsVisible(): Bool

Whether the focus ring should be painted (keyboard or programmatic focus).

fn focusNext(): Int
fn focusOn(n: Node)
fn focusPrev(): Int
fn focusScope(n: Node)

Restrict focus traversal to a subtree, as a dialog does while open.

fn focused(): Int
fn fontWeightOf(id: Int): Int
fn frameDt(): Float

Seconds used by the most recent frame step.

fn hasEffects(): Bool

True when a live attached node carries an alpha mask or group blur. The app repaints the whole surface for those frames so a style change cannot leave stale pixels behind.

fn hitPortal(px: Int, py: Int): Int

Portals paint above the camera, so they hit in screen coordinates.

fn hitTest(px: Int, py: Int): Int
fn hitTestCamera(px: Float, py: Float, cam: Camera): Int

Hit test through a camera: the caller passes screen coordinates.

fn hoverIn(id: Int): Bool

True when the pointer is on this node or one of its descendants.

fn inPortal(id: Int): Bool

True when this node is inside a portal subtree.

fn inertAt(id: Int): Bool

True when this node or any ancestor is inert.

fn isChecked(n: Node): Bool
fn isRTL(): Bool
fn isVertical(): Bool
fn italicOf(id: Int): Bool
fn keyDown(n: Node, k: Key, shift: Bool): Bool

Activation keys reach the same handler a tap does.

fn keyboardInset(): Int
fn labelIdOf(id: Int): Int
fn lastDrop(): DragData?

The payload of the most recent completed drop, or null.

fn lastDropTarget(): Int

The node that handled the most recent completed drop, or -1.

fn lastTapX(): Float

X of the most recent tap.

fn lastTapY(): Float

Y of the most recent tap.

fn layout(root: Node, width: Int)

One measure pass and one place pass. Widths flow down, heights up.

fn layoutConstrained(root: Node, width: Int, height: Int, c: Constraints)

Lay out inside a viewport with an explicit constraint object.

fn layoutIn(root: Node, width: Int, height: Int)

Layout with a height budget, so a root can fill the window.

fn len(): Int
fn letterSpacingOf(id: Int): Float
fn lineHeightOf(id: Int): Float
fn linkAt(x: Int, y: Int): String

The URL under a screen point, or an empty string.

fn linkRects(id: Int): Array<LinkRect>

One rectangle per link span on a text or textbox node.

fn listItem(s: String, onTap: fn(): Void): Node
fn longPressPending(): Bool

True while a held pointer could still become a long press.

fn longPressed(): Bool

True for the frame in which a long press fired.

fn maskRadiusOf(n: Node): Float

Alpha mask radius of a node, 0 when it has no mask.

fn measureHits(): Int
fn menuItem(s: String, onTap: fn(): Void): Node
fn nameOf(id: Int): String
fn newNode(r: Role, n: String): Node
fn numberOf(n: Node): Float
fn opacityOf(n: Node): Float

Group opacity of a node.

fn paintPortals(d: DisplayList, th: Theme)

Paint portal subtrees above the tree, clipped to their layer.

fn pinchActive(): Bool

True while two pointers are tracked for pinch and rotate.

fn pinchRotation(): Float

Angle delta since the second pointer landed, in radians.

fn pinchScale(): Float

Current distance divided by the distance when the second pointer landed.

fn pointerCancelId(id: Int): Bool

Cancel one pointer id, restore its start point, and drop its samples.

fn pointerDown(x: Int, y: Int): Bool

Route a pointer press through the hit test to the same handler a key reaches.

fn pointerDownAt(x: Int, y: Int, id: Int): Bool

Dispatch a pointer press that already resolved to a node.

fn pointerDownCamera(px: Float, py: Float, cam: Camera): Bool

Press through a camera; portals keep screen coordinates.

fn pointerDownId(id: Int, x: Int, y: Int, button: Int): Bool

Record a press for one pointer id. The node under the point becomes the drag owner; pointer zero keeps the legacy activation path.

fn pointerLeave(): Bool

Cancel every active pointer and clear hover.

fn pointerMove(x: Int, y: Int): Bool

Track hover and an active drag. Returns true when something visible changed.

fn pointerMoveAt(x: Int, y: Int, h: Int): Bool

Update hover and drag state for a press that already resolved to a node.

fn pointerMoveCamera(px: Float, py: Float, cam: Camera): Bool

Move through a camera; portals keep screen coordinates.

fn pointerMoveId(id: Int, x: Int, y: Int): Bool

Move one pointer id with velocity disabled.

fn pointerMoveTimed(id: Int, x: Int, y: Int, timeNs: Int): Bool

Move one pointer id and add a velocity sample at timeNs.

fn pointerUp(x: Int, y: Int): Bool
fn pointerUpId(id: Int, x: Int, y: Int): Bool

Release one pointer id. A started drag ends; a tap keeps phase none.

fn preeditOf(n: Node): String
fn presenceAnimating(): Bool

True while any presence is still moving toward its target.

fn presenceProgressOf(k: String): Float

Current eased opacity for a keyed presence, or 1 when it is unknown.

fn presenceValue(k: String, show: Bool, duration: Float, curve: Curve): Float

Read or create the keyed presence state and report its current opacity. A new key starts at zero so the first shown frame fades in rather than jumping to full opacity.

fn radio(s: String, selected: Bool, onTap: fn(): Void): Node
fn replaceSelection(n: Node, s: String): Bool

Replace the selection of a text box with s.

fn resetMeasureStats()
fn roleNameOf(id: Int): String
fn rootId(): Int
fn safeBottom(): Int
fn safeLeft(): Int
fn safeRight(): Int
fn safeTop(): Int
fn scrollAt(x: Int, y: Int, dy: Float): Bool

Scroll the nearest scrollable ancestor of the node under the point. If the point is just outside the list, fall back to the last list that scrolled, then to any scrollable node containing the point.

fn scrollAtCamera(px: Float, py: Float, dy: Float, cam: Camera): Bool

Wheel through a camera; portals scroll in screen coordinates.

fn scrollFling(n: Node, velocity: Float): Bool

Start a friction fling from the present offset.

fn scrollForKey(k: String): Float

Scroll offset of a keyed node from the previous frame.

fn scrollMaxOf(n: Node): Float
fn scrollOf(n: Node): Float
fn scrollOverscrollOf(n: Node): Float

Compressed distance past a bound: negative above the top, positive below the end.

fn scrollVelocityOf(n: Node): Float

Velocity of an in-flight fling, in pixels per second.

fn selectAllText(n: Node): Bool
fn selectedText(n: Node): String

The selected text of a text box, or an empty string.

fn setAbsolute(id: Int, on: Bool)
fn setAccent(id: Int, on: Bool)
fn setAlignSelf(id: Int, a: Align)
fn setAspectRatio(id: Int, r: Float)
fn setAutoMargin(id: Int, on: Bool)
fn setBlend(id: Int, m: Int)
fn setBlurSigma(id: Int, sigma: Float)
fn setBottom(id: Int, n: Int)
fn setBusy(id: Int, on: Bool)
fn setChecked(n: Node, v: Bool)

The checked state of a toggle, radio, or checkbox.

fn setClip(id: Int, on: Bool)
fn setClipRound(id: Int, radius: Float)
fn setColumns(id: Int, n: Int)
fn setConstraints(id: Int, c: Constraints)
fn setControlsId(id: Int, n: Int)
fn setCrossAlign(id: Int, a: Align)
fn setCursorHandler(cb: fn(Int): Void)

Handler called with the cursor shape id when it changes.

fn setDensity(d: Float)

Device pixel ratio hint. Layout stays in logical units.

fn setDescribedById(id: Int, n: Int)
fn setDescription(id: Int, s: String)
fn setDisabled(id: Int, on: Bool)
fn setDraggable(id: Int, kind: String, text: String)
fn setDropTarget(id: Int, kinds: String, cb: fn(DragData): Void)
fn setElevation(id: Int, e: ElevationToken)
fn setExpanded(id: Int, n: Int)
fn setFixedHeight(id: Int, h: Int)
fn setFixedWidth(id: Int, w: Int)
fn setFontWeight(id: Int, weight: Int)

CSS weight for this node's text, 100 to 900.

fn setFrameDt(dt: Float)

Store the frame delta that presence transitions use on the next frame.

fn setGap(id: Int, n: Int)
fn setGapPercent(id: Int, p: Float)
fn setGradient(id: Int, on: Bool)
fn setGrow(id: Int, f: Float)
fn setIdealHeight(id: Int, h: Int)
fn setIdealWidth(id: Int, w: Int)
fn setImage(id: Int, png: ByteBuffer)
fn setImageFit(id: Int, f: ImageFit)
fn setImageIntrinsic(id: Int, w: Int, h: Int)
fn setInert(id: Int, on: Bool)
fn setInvalid(id: Int, n: Int)
fn setItalic(id: Int, on: Bool)
fn setKey(id: Int, k: String)
fn setKeyboardInset(bottom: Int)

The soft-keyboard inset, added to the bottom safe area.

fn setLabelId(id: Int, n: Int)
fn setLeft(id: Int, n: Int)
fn setLetterSpacing(id: Int, f: Float)

Extra advance per character, in logical pixels.

fn setLevel(id: Int, n: Int)
fn setLineHeight(id: Int, f: Float)

Row height as a multiplier of the font size; zero keeps normal spacing.

fn setLinkHandler(cb: fn(String): Void)

Handler called once for a completed link click.

fn setLive(id: Int, n: Int)
fn setMainAlign(id: Int, a: Align)
fn setMargin(id: Int, n: Int)
fn setMaskRadius(id: Int, radius: Float)
fn setMaxHeight(id: Int, h: Int)
fn setMaxWidth(id: Int, w: Int)
fn setMinHeight(id: Int, h: Int)
fn setMinWidth(id: Int, w: Int)
fn setNumber(id: Int, v: Float)
fn setOffsetY(id: Int, y: Float)
fn setOpacity(id: Int, f: Float)
fn setOrder(id: Int, n: Int)
fn setPadding(id: Int, n: Int)
fn setPendingKey(k: String)
fn setPortal(id: Int, layer: Int)
fn setPreedit(n: Node, s: String)

Inline IME preedit for a text box. Kept out of the value until commit.

fn setRTL(on: Bool)

Right-to-left rows and mirrored start/end alignment.

fn setRaised(id: Int, on: Bool)
fn setRange(id: Int, min: Float, max: Float, step: Float)
fn setRequired(id: Int, on: Bool)
fn setRight(id: Int, n: Int)
fn setRound(id: Int, on: Bool)
fn setRoving(id: Int, on: Bool)
fn setSafeArea(top: Int, right: Int, bottom: Int, left: Int)

Screen edges owned by the system, in logical units.

fn setScroll(id: Int, v: Float, max: Float)

Place the offset, clamped to 0..max. An exact scroll creates no overscroll.

fn setScrollTo(id: Int, v: Float)
fn setSelected(id: Int, on: Bool)
fn setShadow(id: Int, color: Int, dx: Float, dy: Float, blur: Float, radius: Float)
fn setShrink(id: Int, f: Float)
fn setSizeMode(id: Int, n: Int)
fn setText(n: Node, v: String): Bool

Apply typed text and notify the field's handler.

fn setTextAlign(id: Int, a: Align)
fn setTextEngine(e: TextEngine)

Replace the text backend. Called once by the app before the first view.

fn setTextMaxLines(id: Int, n: Int)
fn setTextScale(f: Float)

Dynamic type multiplier for every text role.

fn setTextSize(id: Int, px: Int)
fn setTextSpans(id: Int, spans: Array<TextSpan>)

Inline style spans for this node's text.

fn setTextValue(n: Node, s: String): Bool

Replace a text box value as a screen reader would.

fn setTextWrap(id: Int, on: Bool)
fn setTheme(th: Theme)

Point this tree at the theme that supplies its token tables. Type tokens are read during layout, so a theme swap bumps the measure version.

fn setTone(id: Int, t: ButtonTone)
fn setTooltip(id: Int, s: String)
fn setTop(id: Int, n: Int)
fn setValue(n: Node, v: String)

The current value of a text field or slider, for the semantic tree.

fn setWritingMode(m: WritingMode)
fn setZIndex(id: Int, z: Int)
fn shadowBlurOf(n: Node): Float
fn shadowColorOf(n: Node): Int

Shadow color lane of a node, 0 when it has no shadow.

fn shadowDxOf(n: Node): Float
fn shadowDyOf(n: Node): Float
fn shadowRadiusOf(n: Node): Float
fn slider(s: String): Node
fn sliderValue(s: String, v: Float, onChange: fn(Float): Void): Node
fn snapshot(): String

One line per node in tree order, for snapshots and the inspector.

fn space(token: SpaceToken): Int
fn stepGestures(dt: Float)

Advance time-driven gestures by one frame. Long press accumulates while a pointer stays inside the slop and fires once at 500 ms. Pinch values are refreshed from the live pointer positions.

fn stepScroll(dt: Float): Bool

Advance every active fling and returning overscroll by dt. Returns true while anything is still moving, so the app keeps requesting frames. A fling clamps at a bound and stops; no overscroll is created by a fling.

fn stopScroll(n: Node)

End a fling and hold the present offset.

fn tab(s: String, selected: Bool, onTap: fn(): Void): Node
fn tap(n: Node): Bool
fn tapCount(): Int

Taps seen in the latest single or double tap: 0, 1, or 2.

fn textField(v: String, placeholder: String, onChange: fn(String): Void): Node
fn textFieldRich(v: String, placeholder: String, spans: Array<TextSpan>, onChange: fn(String, Array<TextSpan>): Void): Node

A text box that keeps inline spans while editing.

fn textScale(): Float
fn textSpansOf(id: Int): Array<TextSpan>
fn theme(): Theme
fn toggle(s: String): Node
fn toggleWith(s: String, onToggle: fn(): Void): Node
fn typeText(n: Node, s: String): Bool

Insert text at the caret, replacing the selection.

fn unnamedInteractive(): Int
fn valueOf(n: Node): String
class TypeScale

The seven text roles. The default sizes are the ones the roles used before the token scale existed: 56 display, 20 heading and dialog, 14 body, label and mono, 12 caption. Title has no built-in role yet, so its 28 is free to use.

init(display: TypeStyle, title: TypeStyle, heading: TypeStyle, body: TypeStyle, label: TypeStyle, caption: TypeStyle, mono: TypeStyle)

fields

fn replace(t: TypeToken, s: TypeStyle): TypeScale
fn styleFor(t: TypeToken): TypeStyle
fn styleForRole(role: Int): TypeStyle

Map a paint role id to its type token. Buttons use the label style; headings and dialogs use heading; display uses display; the rest use body.

class TypeStyle

Size, weight, line height, and tracking for one text role.

init(size: Float, weight: Int, lineHeight: Float, tracking: Float)

fields

  • lineHeight: Float
  • size: Float
  • tracking: Float
  • weight: Int
class View

A screen description. Construct one with Page, List, Text, and the other component functions; the app mounts it into the retained tree.

init(kind: ViewKind)

fields

  • absolutePos: Bool
  • accent: Bool
  • align: Align
  • aspectRatio: Float
  • blend: BlendMode
  • blurSigma: Float
  • bottom: Int
  • buildComponent: fn(): View
  • busy: Bool
  • buttonSize: ButtonSize
  • canvasH: Int
  • canvasW: Int
  • center: Bool
  • checked: Bool
  • children: Array<View>
  • clip: Bool
  • clipRadius: Float
  • columns: Int
  • component: Int
  • controlsId: Int
  • describedById: Int
  • description: String
  • dragKind: String
  • dragText: String
  • dropKinds: String
  • elevation: ElevationToken
  • expanded: Int
  • fontWeight: Int
  • gap: Int
  • gradient: Bool
  • grow: Float
  • height: Int
  • horizontal: Bool
  • image: ByteBuffer
  • imageFit: ImageFit
  • imageH: Int
  • imageLabel: String
  • imageW: Int
  • invalid: Int
  • italic: Bool
  • key: String
  • kind: ViewKind
  • labelId: Int
  • left: Int
  • letterSpacing: Float
  • level: Int
  • lineHeight: Float
  • live: Int
  • maskRadius: Float
  • maxWidth: Int
  • mountCb: fn(Tree, Node): Void
  • name: String
  • onChange: fn(Float): Void
  • onDrop: fn(DragData): Void
  • onRichText: fn(String, Array<TextSpan>): Void
  • onTap: fn(): Void
  • onText: fn(String): Void
  • onToggle: fn(): Void
  • opacity: Float
  • owner: GenRef<Reactive>?
  • padding: Int
  • paint: fn(Canvas): Void
  • placeholder: String
  • portal: Bool
  • raised: Bool
  • required: Bool
  • right: Int
  • round: Bool
  • selected: Bool
  • shadowBlur: Float
  • shadowColor: Int
  • shadowDx: Float
  • shadowDy: Float
  • shadowRadius: Float
  • show: Bool
  • spans: Array<TextSpan>
  • text: String
  • textSize: Int
  • title: String
  • tone: ButtonTone
  • top: Int
  • transition: Transition
  • value: Float
  • valueMax: Float
  • valueMin: Float
  • valueStep: Float
  • width: Int
  • z: Int
fn at(x: Int, y: Int, w: Int, h: Int): View
fn blend(m: BlendMode): View

Blend this view's whole group against the backdrop.

fn clipped(): View
fn draggable(kind: String, text: String): View

Make this view a drag source carrying a typed payload.

fn dropTarget(kinds: String, cb: fn(DragData): Void): View

Accept drops of the comma-separated kinds on this view.

fn inset(l: Int, t: Int, r: Int, b: Int): View
fn keyed(k: String): View

Stable identity for keyed reconciliation.

fn named(n: String): View
fn onMount(cb: fn(Tree, Node): Void): View
fn opacity(f: Float): View

Group opacity for this view and everything under it.

fn portalToRoot(): View
fn zIndex(n: Int): View
class VirtualRange

The visible window of a virtual list.

init(node: Node, first: Int, count: Int, offset: Float)

fields

  • count: Int
  • first: Int
  • node: Node
  • offset: Float
class WindowMorph

A window-to-thumbnail morph built on matched geometry.

init(windowX: Float, windowY: Float, windowW: Float, windowH: Float)

fields

fn done(): Bool
fn enter(thumbX: Float, thumbY: Float, thumbW: Float, thumbH: Float)

Morph from a window rectangle to an overview thumbnail.

fn h(): Float
fn leave(windowX: Float, windowY: Float, windowW: Float, windowH: Float)

Morph back to the window rectangle.

fn progress(): Float
fn step(dt: Float): Float
fn swapped(): Bool

True once the thumbnail content should replace the window content.

fn w(): Float
fn x(): Float
fn y(): Float
enum Action
  • dismiss
  • setValue
  • tap
  • toggle
enum Align
  • baseline
  • center
  • end
  • start
  • stretch
enum BlendMode
  • darken
  • difference
  • exclusion
  • lighten
  • multiply
  • normal
  • overlay
  • plus
  • screen
enum ButtonSize
  • lg
  • md
  • sm
enum ButtonTone
  • accent
  • danger
  • ghost
  • neutral
enum ColorSpace
  • displayP3
  • linear
  • srgb
enum CurveKind
  • cubic
  • linear
  • steps
enum ElevationToken
  • level0
  • level1
  • level2
  • level3
  • level4
  • level5
enum FontFamily
  • cursive
  • emoji
  • fantasy
  • math
  • mono
  • sans
  • serif
  • system
  • uiMono
  • uiRounded
  • uiSans
  • uiSerif
enum GestureAxis
  • both
  • horizontal
  • none
  • vertical
enum ImageFit
  • contain
  • cover
  • fill
  • none
  • scaleDown
enum Key
  • backspace
  • delete
  • down
  • end
  • enter
  • escape
  • home
  • left
  • pageDown
  • pageUp
  • right
  • space
  • tab
  • up
enum MotionKind
  • curve
  • decay
  • spring
enum MotionToken
  • fast
  • normal
  • slow
  • spring
enum RadiusToken
  • lg
  • md
  • none
  • pill
  • sm
enum Role
  • button
  • canvas
  • checkbox
  • column
  • dialog
  • display
  • divider
  • grid
  • heading
  • icon
  • image
  • link
  • list
  • listitem
  • menubar
  • menuitem
  • progress
  • radio
  • radiogroup
  • root
  • row
  • scroll
  • section
  • slider
  • stack
  • tab
  • text
  • textbox
  • toggle
  • wrap
enum SpaceToken
  • lg
  • md
  • sm
  • xl
  • xs
  • xxl
enum StepJump
  • both
  • end
  • none
  • start
enum StrokeCap
  • butt
  • round
  • square
enum StrokeJoin
  • bevel
  • miter
  • round
enum TextDecoration
  • both
  • none
  • strikethrough
  • underline
enum TypeToken
  • body
  • caption
  • display
  • heading
  • label
  • mono
  • title
enum ViewKind
  • buttonKind
  • canvasKind
  • cardKind
  • checkboxKind
  • componentKind
  • crossfadeKind
  • displayKind
  • dividerKind
  • gridKind
  • headerKind
  • headingKind
  • imageKind
  • listKind
  • listRowKind
  • overlayKind
  • pageKind
  • presenceKind
  • progressKind
  • richFieldKind
  • scrollKind
  • sectionKind
  • sliderKind
  • spacerKind
  • stackKind
  • textFieldKind
  • textKind
  • toolbarKind
enum WritingMode
  • horizontal
  • vertical

Functions

fn rgba(r: Int, g: Int, b: Int, a: Int): Int
fn rubberBand(offset: Float, dimension: Float, constant: Float): Float

Damp an overscroll offset past a bound. constant is usually 0.55.

fn rubberBandInverse(offset: Float, dimension: Float, constant: Float): Float

Invert rubberBand so dragging back through the bound stays continuous.