Skip to content

A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.

2.4 KB
Raw Blame

UI List

A data-driven, virtualized list and grid built with createListView — the one-call widget over the collection primitives (DataSource + LayoutProvider

  • view pool + scroll container + UIMask clipping).

Two collections run side by side:

  • Contacts (left) — a 500-row vertical list. Only a screenful of row entities ever exists; they're recycled and re-bound as you scroll. Each row is a zebra-striped container with a hue stripe and a label, all rebound in the item template's idempotent bind.
  • Tiles (right) — the same widget in grid mode (columns: 4), 120 tiles colored by index.

The stats line at the bottom is the proof of virtualization: the mounted entity counts stay flat (~10 for the list) no matter how many rows the data source holds.

Controls

Input Action
Mouse wheel Scroll whichever list is under the cursor
Drag (mouse/touch) Grab the content and fling it — kinetic scrolling with inertia
+ Append row data.append(…) — the list grows live, then jumps to it
− Remove first data.remove(0) — rows above re-bind in place
Top / End scrollToIndex() — programmatic jumps

What it shows

  • createListView with both layout sugars: { itemHeight } (column list) and { columns, itemSize } (grid).
  • A raw ArrayDataSource as the backing store — mutate it (append / remove / update) and the widget re-syncs; there is no manual refresh.
  • ListItemTemplate — create builds a pooled row once, bind re-applies data on every recycle, so it must be idempotent.
  • scrollToIndex and the mountedCount() escape hatch.

The scene authors the static frame (panel, headers, empty slots); the startup system finds the named slots and instantiates the widgets — the same scene-plus-factories split as the ui-controls example.

The panel sits under an absolute SafeArea content container. Device cutouts move the whole interactive list and its controls together; the panel keeps its authored margins inside that container.

The panes and widget viewports fill their constrained parent heights. After layout, the widgets use their resolved sizes for virtualization and scrolling, so a home indicator or a smaller window cannot hide the last row behind the footer.