VirtualGrid
VirtualGrid virtualizes a vertically scrolling grid.
Resolve columns from available width
Section titled “Resolve columns from available width”VirtualGrid(items, [](const Item& item) { return ItemCard(item).Key(item.id);}) .Columns(GridColumns::Adaptive(220.0F)) .EstimatedRowExtent(180.0F) .ColumnSpacing(16.0F) .RowSpacing(16.0F) .CacheExtent(320.0F)Choose GridColumns::Fixed(count) for a stable column count or GridColumns::Adaptive(minimum_width) to resolve as many columns as available width can support.
Tune rows and spans
Section titled “Tune rows and spans”.RowExtent(...) describes fixed-height rows.
Use .EstimatedRowExtent(...) when rows can vary.
.ItemSpans(...) supplies the number of columns consumed by each corresponding item.
The same range, state range, and count-factory constructors as VirtualList are available.
.Controller(...) supports metrics and indexed scrolling.
Preserve grid semantics
Section titled “Preserve grid semantics”VirtualGrid publishes grid, row and column counts, and realized cell coordinates through accessibility semantics.
- Constructors inherited from
VirtualLayout. - Fluent methods:
.Columns,.RowExtent,.EstimatedRowExtent,.RowSpacing,.ColumnSpacing,.CacheExtent,.ItemSpans,.Controller. - Column model:
GridColumns::FixedorGridColumns::Adaptive.
Use Flow for a small wrapping collection that should mount every child.
Every sizing operation
Section titled “Every sizing operation”| Method | Contract |
|---|---|
Columns(GridColumns) |
Fixed(count) requires a positive count; Adaptive(minimum_width) requires positive width. |
RowExtent(float) |
Positive fixed row height. |
EstimatedRowExtent(float) |
Positive initial estimate when measured row heights vary. |
RowSpacing(float), ColumnSpacing(float) |
Nonnegative logical-pixel gaps. |
CacheExtent(float) |
Nonnegative offscreen realization distance. |
ItemSpans(vector<size_t>) |
Positive spans corresponding to logical items; each clamps to the resolved column count. |
Controller(ScrollController) |
Stable metrics and item-targeted scrolling. |
GridColumns::Resolve(available_width, spacing) returns the resolved count for a proposed width; ordinary applications can let the grid perform this calculation. Adaptive columns respond to the grid’s actual constrained width, so the same declaration works inside a drawer or a main content area.
VirtualGrid scrolls vertically; it does not expose ScrollAxis. Supply a bounded height. A row is measured as a row, so a tall cell affects its neighboring cells’ vertical placement. Use a fixed RowExtent only when that rule matches every cell. Application data and persistent selection should live outside evictable cell scopes, as with VirtualList.

