Expand description
A virtualized, column-oriented grid over caller-owned rows.
crate::data::Table takes materialized rows, so every cell element
already exists by the time the table sees it and every row it is given is
laid out. DataGrid takes a render closure instead — the same shape
crate::data::List uses — so the body can live inside
gpui::uniform_list and only the rows the viewport holds are ever built.
Everything the grid shows is the caller’s answer. Order, sort, column widths, column order, selection, expansion, and the value in an editing cell are all host state; the grid reports what was operated and renders exactly what it was handed back, so a host that refuses a change keeps showing the state that still holds.
§Which nodes publish
Only the rows the viewport drew publish nodes. The grid node itself carries
the number of rows it was given in value, which is how a snapshot stays
honest about the difference between twelve thousand rows and the fourteen
that are on screen. A cell publishes a Role::Cell node only where the
caller marks it with Cell::published or declares its column editable.
§What this grid does not do
It does not scroll horizontally. uniform_list owns its own scroll
offset and lays every row out at the width it is given; a frozen left group
under a horizontal scroll needs either two vertically-synchronised uniform
lists — and nothing in this GPUI revision keeps two
gpui::UniformListScrollHandles in step without one writing the other
every frame, which is a redraw loop — or a per-row counter-translation that
fights the list’s own content mask. So GridColumn::pinned means “this
column keeps the left edge, whatever order the caller puts the columns in,
and cannot be dragged out of it”, not “this column stays while the rest
scrolls away”. Columns share the grid’s width the way Table’s do.
It does not measure a column to its content. A double click on a resize handle reports a fit request and stops: the grid can only measure the rows it drew, and a width fitted to fourteen of twelve thousand rows is a guess wearing a measurement’s clothes. The host owns the data and can answer properly.
Structs§
- BulkBar
- The bar that appears over a selection, says how large it is, and offers what can be done to it.
- Data
Grid - A grid that renders only the rows its viewport holds.
- Edit
Intent - One finished edit, as it is reported to the host.
- Editing
Cell - The cell the caller has opened for editing, and the value it holds.
- Expanded
- One opened row: its identity, and where it sits.
- Grid
Column - One column of a grid.
- GridRow
- One row, built on demand, keyed by the identity the row already has.
Enums§
- Edit
Outcome - How an edit ended.
- Grid
Lines - Whether a grid draws rules between its rows.
- Selection
Change - What a gesture asked the selection to become.
- Selection
Mode - How many rows may be selected at once.