Interface and input

The 2D layer

116 symbols, imported from @driftengine/ui2d.

Explained in Sprites and tilemaps.

Interfaces

A11yHost
A11yNode
Camera2D
A 2D camera: where it is, how far in, and which way up.
DirtyTracker
PointerState
RowWindow
Which rows a scroll offset makes visible, so that a list costs a screenful rather than a list.
SheetEntry
One entry of an atlas, in texels, as a packer emits it.
SliceInset
SpriteBatch
One frame's worth of sprites.
SpriteFrame
A UvRect a caller owns and refills, so reading a frame allocates nothing.
SpritePass
SpritePassOptions
SpritePlacement
Where a sprite goes, in whatever space the batch is being drawn in.
SpriteRun
A run of consecutive instances that share a texture.
SpriteSheet
The frames of one texture.
SpriteTextureOptions
TextHost
TextModel
A caret, a selection, and the operations that move them.
TextRun
Overlapping style runs, normalised into disjoint ones that cover every character once.
Theme
Named colours and sizes, so an interface stops repeating its own constants.
Tilemap
UiContentSink
Where a caller draws what a quad cannot be.
UiInput
What the router remembers between calls.
UiNode
A node.
UiNodeOptions
UiRect
A resolved box, in whatever units the tree is laid out in. Written by layoutUiTree.
UvRect
A rectangle of a texture, in the 0..1 the sampler reads. See spriteSheet.ts.
ViewRect
What the view can see, in the same units the map is placed in.

Functions

a11yTree
Fill out with every node worth describing, in tree order. Returns how many.
addUiChild
Put child at the end of parent's children, detaching it from wherever it was.
applyComposition
Fold one composition update into the model.
beginDrag
capturePointer
clampScroll
clearDirty
clipRectFor
The rectangle node may draw into, cut by every clipping ancestor between it and root.
createAffine2D
createDirtyTracker
createNullA11yHost
A host that accepts a tree and does nothing with it. See the header.
createNullTextHost
A host that focuses nothing and whose clipboard is empty.
createPointerState
createSpriteBatch
createSpriteFrame
createSpritePass
createTextModel
createTheme
createTilemap
createUiInput
createUiNode
deleteBackward
deleteForward
deriveTheme
A new theme with overrides applied over base. base is not modified.
diffTree
Compare the tree against last frame and mark what changed.
dirtyBounds
The union of everything marked. Returns false when nothing was.
drawSprite
Push one quad. Allocates nothing.
drawTilemap
Draw the tiles the view can see. Returns how many that was.
drawUiTree
Draw a tree. Returns how many quads it came to.
dropTarget
The node a drop would land on, or null.
endDrag
Finish a drag and report where it landed. Null when no drag was in progress.
frameOf
The index a name has, or -1.
gridSheet
A sheet cut into equal cells, row-major: left to right, then down.
insertText
intersectClip
Write the overlap of two rectangles into out. Never negative; see the header.
layerOrder
Fill out with the tree in draw order and return how many entries were written.
layoutUiTree
Lay a tree out into x, y, w, h.
markDirty
Union rect into what must be redrawn. A zero-area rectangle still counts as a change.
moveCaret
moveToLineEdge
namedSheet
A sheet from an atlas description: whatever rectangles a packer put where.
pointerTarget
Who should receive pointer input at this position.
releasePointer
removeUiChild
Take child out of parent. A child that is not there is left alone.
resetSpriteBatch
resetUiInput
Forget everything, and clear the flags this router set on the tree.
routeScrollWheel
Give a wheel to the innermost container under the pointer that can use it, then outwards.
routeUiKey
Route a key. Returns the node it activated, or null.
routeUiPointer
Route a pointer. Returns the node this call activated, or null.
runsFor
Fill out with disjoint, ordered, gap-free runs covering [0, text.length).
screenToNdc
The affine for CSS pixels with a top-left origin — the convention InsetRect and fillPanel already use, and the one a caller laying out an overlay already has.
scrollBy
Scroll, clamped. Returns whether anything actually moved — see the header for why.
scrollExtent
How far this node's contents extend past its own box, along each axis.
selectAll
selectedText
selectionRange
setTile
Put a frame in a cell. A cell outside the map is ignored rather than wrapping into another row.
setUiFocus
Move focus, clearing whatever had it. null focuses nothing.
sheetFrame
Read a frame into a rectangle the caller owns. Allocates nothing.
sheetFrameHeight
A frame's height in texels, or 0 for an index the sheet does not have.
sheetFrameWidth
A frame's width in texels, or 0 for an index the sheet does not have.
sliceInto
spriteRun
Read a run back. For tests and diagnostics; the pass reads runs directly.
themeColour
themeRgba
themeColour and unpackRgba in one call, which is how a widget uses both.
themeSize
tileAt
The frame in a cell, or TILE_EMPTY — including for a cell outside the map.
uiFocusNext
The next focusable node after current, wrapping.
uiFocusOrder
Every focusable node, in tree order, appended to out.
uiFocusPrevious
The focusable node before current, wrapping.
uiHitTest
The interactive node under a point, or null.
uiNodeNamed
The node named, depth-first from root, or null. For a caller finding its own tree again.
uiRectHolds
Whether a point is inside a node's resolved box.
unpackRgba
A packed 0xRRGGBBAA token as the four floats a node's background and tint are.
visibleRange
Uniform row heights, which is arithmetic.
visibleRangeVariable
Variable row heights, through a prefix-sum table of row tops the caller owns.
worldToNdc
The affine for a 2D world seen through a camera.

Types

Affine2D
Six numbers, laid out the way a 2D graphics API has laid them out for thirty years:
SpriteImage
The three sources both backends take without a conversion.
UiAlign
Where children sit across the parent's main axis. stretch gives them the whole cross extent.
UiJustify
How the leftover along the main axis is spent when no child asked to grow.
UiSize
How big a node asks to be along one axis.

Constants

DEFAULT_SPRITE_CAPACITY
Sprites a frame, if the caller does not say. Four thousand quads is 224 KB of instance data.
DEFAULT_SPRITE_SLOTS
Texture slots, if the caller does not say.
DEFAULT_SPRITE_TEXTURE_OPTIONS
SLICE_STRIDE
Floats per placement: x, y, w, h, u0, v0, u1, v1.
SPRITE_FLOATS
Floats per instance: two edge vectors, a UV rectangle, a tint, and an origin.
TILE_EMPTY
A cell holding nothing. Negative, so it can never be a frame index.