Interface and input
The 2D layer
116 symbols, imported from @driftengine/ui2d.
Explained in Sprites and tilemaps.
Interfaces
A11yHostA11yNodeCamera2D- A 2D camera: where it is, how far in, and which way up.
DirtyTrackerPointerStateRowWindow- 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.
SliceInsetSpriteBatch- One frame's worth of sprites.
SpriteFrame- A
UvRecta caller owns and refills, so reading a frame allocates nothing. SpritePassSpritePassOptionsSpritePlacement- 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.
SpriteTextureOptionsTextHostTextModel- 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.
TilemapUiContentSink- Where a caller draws what a quad cannot be.
UiInput- What the router remembers between calls.
UiNode- A node.
UiNodeOptionsUiRect- 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
outwith every node worth describing, in tree order. Returns how many. addUiChild- Put
childat the end ofparent's children, detaching it from wherever it was. applyComposition- Fold one composition update into the model.
beginDragcapturePointerclampScrollclearDirtyclipRectFor- The rectangle
nodemay draw into, cut by every clipping ancestor between it androot. createAffine2DcreateDirtyTrackercreateNullA11yHost- 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.
createPointerStatecreateSpriteBatchcreateSpriteFramecreateSpritePasscreateTextModelcreateThemecreateTilemapcreateUiInputcreateUiNodedeleteBackwarddeleteForwardderiveTheme- A new theme with
overridesapplied overbase.baseis 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.
insertTextintersectClip- Write the overlap of two rectangles into
out. Never negative; see the header. layerOrder- Fill
outwith the tree in draw order and return how many entries were written. layoutUiTree- Lay a tree out into
x,y,w,h. markDirty- Union
rectinto what must be redrawn. A zero-area rectangle still counts as a change. moveCaretmoveToLineEdgenamedSheet- A sheet from an atlas description: whatever rectangles a packer put where.
pointerTarget- Who should receive pointer input at this position.
releasePointerremoveUiChild- Take
childout ofparent. A child that is not there is left alone. resetSpriteBatchresetUiInput- 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
outwith disjoint, ordered, gap-free runs covering[0, text.length). screenToNdc- The affine for CSS pixels with a top-left origin — the convention
InsetRectandfillPanelalready 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.
selectAllselectedTextselectionRangesetTile- 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.
nullfocuses 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.
sliceIntospriteRun- Read a run back. For tests and diagnostics; the pass reads
runsdirectly. themeColourthemeRgbathemeColourandunpackRgbain one call, which is how a widget uses both.themeSizetileAt- 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, ornull. For a caller finding its own tree again. uiRectHolds- Whether a point is inside a node's resolved box.
unpackRgba- A packed
0xRRGGBBAAtoken as the four floats a node'sbackgroundandtintare. 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.
stretchgives 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_OPTIONSSLICE_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.