Scene Builder
Overview
SceneBuilder is the bridge between the data model (GridState) and the
rendering layer. It produces a SceneFrame — an immutable, ordered list
of drawing primitives.
Usage
Parameters
SceneFrame
SceneFrame is produced fresh each frame — there is no mutable state
between frames. This makes the rendering pipeline pure and predictable.
Draw order
Primitives are ordered back-to-front:
- Background fills (cell backgrounds, alternating rows)
- Grid lines
- Cell text and images
- Selection overlays
- Headers (sticky, drawn on top)
- Scrollbars (topmost layer)
The renderer draws them in sequence — later primitives paint over earlier ones.
What the builder computes
For each frame, the builder:
- Determines visible rows from
ViewportState - Iterates visible columns (with pinned columns first)
- Emits
Rectprimitives for cell backgrounds - Emits
Lineprimitives for grid lines - Formats cell values via
CellFormatand emitsTextprimitives - Emits
Imageprimitives for image-format cells - Draws selection highlight (
Rectwith semi-transparent fill) - Draws search match highlights
- Draws hover row overlay
- Draws sticky header row
- Draws scrollbars (arrows, track, thumb)
- Draws column drag feedback if active
Logical coordinates
All coordinates in SceneFrame are logical pixels (CSS pixels).
The renderer is responsible for applying the DPR:
ColumnDragHint
When a user drags a column to reorder it, a ColumnDragHint provides
visual feedback:
The builder renders a semi-transparent ghost of the dragged column at the current mouse position.