Skip to main content

Module table_header

Module table_header 

Source
Expand description

TableHeader — the column header strip of TableView and TreeTableView, and a widget of its own for an application that lays out its own rows under columns: a section list with full-width group rows, an album card beside its tracks.

Both views compose this widget, so there is one header implementation: the HeaderCells (label, sort indicator, filter popover, the resize grip on each divider, the column-reorder drag, Role::ColumnHeader with its sort direction and AccessKit Increment / Decrement), the strip that lays them out in pinned and scrolling bands and paints their separators, and the drop target that turns a reorder drag into a new column order.

§State

The header’s state is six signals — the width overrides, the sort, the column order, the pinning overrides, the filters and the horizontal scroll offset. Each builder (widths, sort, order, pinning, filters, scroll_x) adopts an application’s signal; one that is not given is the header’s own, read back through its getter. The rules are the views’ (“Column state an application owns” in the table_view module docs): the header writes nothing into these signals until the user acts on it, ignores ids it does not declare, and keeps them when it writes. Hand the same signals to a TableView and the two stay in step.

The width map holds overrides, not the layout: a column with no entry takes its declared ColumnWidth. What the header actually laid each column out at is resolved_widths_signal, which is what rows of an application’s own read to line their cells up.

§Hosted

Inside a view the header is hosted (TableHeader::hosted): the view resolves the widths and the display order (its body needs both before the header is placed), paints the OnRelease resize guide across the whole table, rebuilds the header whenever its state changes, and holds the resize-drag state, which a relayout keeps. A rebuild abandons an in-flight resize, hosted or not: it destroys the cells and the pointer capture with them (see TableHeader::build). A standalone header does all of that itself, within its own bounds, which it clips to.

Structs§

TableHeader
A table’s column header strip: one Role::ColumnHeader cell per column, with click-to-sort, drag-to-resize on every divider, drag-to-reorder, pinned columns, the filter popover and a horizontal scroll offset to follow a scrolled body.