22#include <unordered_map>
155 using TreeRowMap = std::unordered_map<tachyon::ID, TreeRowInfo>;
173 template <
typename F,
174 typename = std::enable_if_t<!std::is_same_v<std::decay_t<F>,
LazyReorderFn>>>
177 if (!_fn) _fn = std::make_unique<ReorderColumnsFn>();
178 *_fn = std::forward<F>(f);
183 explicit operator bool() const noexcept {
return _fn &&
static_cast<bool>(*_fn); }
184 void operator()(
int from,
int to)
const { (*_fn)(from, to); }
187 void reset() noexcept { _fn.reset(); }
190 std::unique_ptr<ReorderColumnsFn> _fn;
326 id.value.subRangeParts.index =
static_cast<uint64_t
>(rowIdx);
344 for (
size_t i = 0; i < v.size(); ++i)
345 if (v[i] == datasetIdx)
return int(i);
A ReorderColumnsFn that costs one pointer when unset; assign it like a std::function: state....
Definition gui_table_types.h:168
const ReorderColumnsFn * get() const noexcept
Definition gui_table_types.h:186
void operator()(int from, int to) const
Definition gui_table_types.h:184
ReorderColumnsFn * get() noexcept
Definition gui_table_types.h:185
LazyReorderFn(std::nullptr_t) noexcept
Definition gui_table_types.h:171
LazyReorderFn & operator=(std::nullptr_t) noexcept
Definition gui_table_types.h:181
void reset() noexcept
Definition gui_table_types.h:187
LazyReorderFn & operator=(F &&f)
Definition gui_table_types.h:175
TableSelectionMode
Whether clicks, hover and keyboard navigation work on rows or on cells.
Definition gui_table_types.h:126
ColumnSizing
How a column's track is sized and whether it has a sizer at its right edge.
Definition gui_table_types.h:40
SectionSizing
How a section sizes itself in the bodies row; read from the section's first column.
Definition gui_table_types.h:51
@ Cell
A click selects one cell; arrows/Home/End move by cell; hover highlights the cell.
Definition gui_table_types.h:130
@ Row
A click selects the row; Up/Down/Home/End move by row; hover highlights the whole row.
Definition gui_table_types.h:128
@ Resizable
Fixed track at columnWidths[c], resizable via its sizer.
Definition gui_table_types.h:42
@ FitContent
Exactly the sum of its column widths (Stretch acts as Fixed); no H-scrollbar.
Definition gui_table_types.h:56
@ Scrollable
Shares leftover width with its siblings and scrolls horizontally on overflow.
Definition gui_table_types.h:54
TreeDropPosition
Where a tree reorder drop lands relative to the target row.
Definition gui_widget_state_types.h:44
@ None
Definition gui_widget_state_types.h:45
@ SubRange
one item of a Ranged ID: the range's hash plus an index
Definition gui_id.h:17
@ Row
Horizontal, left to right.
Definition gui_style.h:165
@ Fixed
out of flow in overlay space; doesn't scroll with the parent
Definition gui_style.h:219
@ Stretch
Stretch to fill container.
Definition gui_style.h:186
@ Resizable
Definition gui_window_flags.h:19
Definition gui_logging.h:24
Column-reorder drag in progress; internal, owned by the application.
Definition gui_table_types.h:381
tachyon::ID sectionBodyID
Body of the section being dragged in; drags never leave their section.
Definition gui_table_types.h:393
int fromCol
Definition gui_table_types.h:384
int32_t offsetX
pointer travel since the press, layout space
Definition gui_table_types.h:386
int minTarget
Inclusive target range, bounded by locked columns.
Definition gui_table_types.h:390
std::vector< tachyon::IntRect > headerRects
Header rects at drag start (layout space), for edge-crossing.
Definition gui_table_types.h:388
tachyon::ID tableID
Definition gui_table_types.h:383
int maxTarget
Definition gui_table_types.h:391
bool IsDragging() const
The press has moved the drag distance: a column move, not a sort click.
Definition gui_table_types.h:398
tachyon::PointerDrag press
the header's press; a drag once it moves the drag distance
Definition gui_table_types.h:382
int toCol
Definition gui_table_types.h:385
int32_t startScrollX
Scroll-X at drag start, to correct the cursor for mid-drag scrolling.
Definition gui_table_types.h:395
A size in CSS px.
Definition gui_units.h:18
Click-gesture tracker, owned per widget instance so instances (and tests) don't share it.
Definition gui_widget_state_types.h:75
An element's slot in ElementStorage: its depth and index within that depth.
Definition gui_element.h:127
static constexpr ElementRef Invalid()
Definition gui_element.h:135
Size of one grid column or row (CSS: -tachyon-grid-column-track / -row-track).
Definition gui_style.h:373
uint64_t hashValue
Definition gui_id.h:56
IDMode mode
Definition gui_id.h:60
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
static constexpr ID Invalid()
The "no element" ID (all bits zero); also the default for optional ID parameters.
Definition gui_id.h:66
union tachyon::ID::Value value
Drag & drop setup for item-based views (tree, list, grid): items drag a payload and accept drops of t...
Definition gui_widget_state_types.h:55
Per-element overrides of style layout properties.
Definition gui_constraints.h:150
Selected item IDs of a multi-select view; user-owned, keep it alive across frames.
Definition gui_widget_state_types.h:22
Deferred row-click state for the drag-drop path: MouseDown primes it, MouseUp applies the selection u...
Definition gui_table_types.h:136
tachyon::KeyModifier mods
Definition gui_table_types.h:138
tachyon::ID rowID
Definition gui_table_types.h:137
bool dragPromoted
Definition gui_table_types.h:139
One press on an element that may become a drag.
Definition gui_pointer_drag.h:41
bool dragging
moved the drag distance (or a drag from the press on)
Definition gui_pointer_drag.h:46
A registered style, as StyleManager::Register returns it: indices into the shared style pools,...
Definition gui_style_ref.h:25
static constexpr StyleRef Invalid()
A reference to no style (all indices Invalid).
Definition gui_style_ref.h:31
A table column; callers pass an array of them each frame.
Definition gui_table_types.h:60
bool interactiveContent
Keeps cells hittable in row mode (where cells are NoInput so a click selects the row),...
Definition gui_table_types.h:71
std::string_view header
header text
Definition gui_table_types.h:61
CssPx maxWidth
resize upper limit
Definition gui_table_types.h:64
StyleRef columnBackground
Optional background strip spanning the whole body height, behind the cells and above the row backdrop...
Definition gui_table_types.h:74
CssPx initialWidth
starting width
Definition gui_table_types.h:62
StyleRef cellStyle
Optional style for this column's Cell(text) cells in place of the table's, for example right-aligned ...
Definition gui_table_types.h:77
bool locked
Can't be dragged, and other columns can't be dragged past it.
Definition gui_table_types.h:67
ColumnSizing sizing
Definition gui_table_types.h:68
CssPx minWidth
resize lower limit
Definition gui_table_types.h:63
bool sortable
clicking the header sorts by this column
Definition gui_table_types.h:65
Transient state of one table emit; internal.
Definition gui_table_types.h:416
bool anyVertOverflow
Definition gui_table_types.h:430
StyleRef cellStyleRef
Body text cell style; invalid falls back to theme.tableCellStyleRef.
Definition gui_table_types.h:436
tachyon::ID currentRowID
Definition gui_table_types.h:443
int directGridRow
Definition gui_table_types.h:445
bool columnSeparators
Copied from TableState::columnSeparators.
Definition gui_table_types.h:433
int draggedCol
Reorder-dragged column, or -1; emitted last so it paints on top.
Definition gui_table_types.h:427
TableState * userState
Definition gui_table_types.h:420
std::vector< std::vector< std::function< void()> > > columnCells
Definition gui_table_types.h:455
int currentCol
Definition gui_table_types.h:442
size_t columnCount
Definition gui_table_types.h:419
StyleRef style
Definition gui_table_types.h:452
tachyon::ID containerID
Definition gui_table_types.h:451
bool showHeaders
Definition gui_table_types.h:431
bool isRecording
Recording mode (BeginTable/Cell flow): cells are stored in columnCells[column][row] and replayed by E...
Definition gui_table_types.h:450
bool anyHorzOverflow
Copied from TableState::internal.anyHorzOverflow / anyVertOverflow (last frame).
Definition gui_table_types.h:429
int32_t lastColDragFixedWidth
Definition gui_table_types.h:425
tachyon::EventHandler currentRowHandler
Definition gui_table_types.h:444
VirtualTableColumn * columns
user-owned
Definition gui_table_types.h:418
int rowCount
Definition gui_table_types.h:454
tachyon::EventHandler sharedRowHandler
Definition gui_table_types.h:438
int directColStart
Definition gui_table_types.h:446
tachyon::EventHandler sharedCellHandler
Definition gui_table_types.h:439
LayoutOverride constraints
Definition gui_table_types.h:453
bool cellMode
Definition gui_table_types.h:424
bool dragActive
Definition gui_table_types.h:423
Cell-mode click dispatch: cell-element ID -> (rowID, columnIdx).
Definition gui_table_types.h:159
tachyon::ID rowID
Definition gui_table_types.h:159
int columnIdx
Definition gui_table_types.h:159
Written by the table each frame; not part of the API.
Definition gui_table_types.h:229
std::vector< tachyon::ElementRef > headerRefs
Header cell refs of the current frame, by column.
Definition gui_table_types.h:278
std::unique_ptr< CellLookupMap > cellLookup
populated in cell mode
Definition gui_table_types.h:256
tachyon::ID firstSectionBodyID
Section 0's body ID; sections 1 and up live in extraSectionBodyIDs.
Definition gui_table_types.h:273
int totalRowCount
Definition gui_table_types.h:238
int32_t lastViewportW
Definition gui_table_types.h:234
int sortedRowCount
Definition gui_table_types.h:268
bool anyVertOverflow
Definition gui_table_types.h:244
std::vector< int > treeVisibleIdx
VirtualTreeView: last frame's visible -> flat rows.
Definition gui_table_types.h:255
bool sortedDescending
Definition gui_table_types.h:267
int32_t lastViewportH
sampled by render-time draw
Definition gui_table_types.h:233
int sortedColumn
-2 = unbuilt; -1 = built-as-identity
Definition gui_table_types.h:266
int32_t actualRowHeight
Definition gui_table_types.h:239
std::unique_ptr< std::vector< int > > rowOrder
Visual -> dataset row permutation while sorted, else null.
Definition gui_table_types.h:265
PendingRowClick pendingRowClick
Definition gui_table_types.h:261
DoubleClickTracker treeCellClickTracker
Definition gui_table_types.h:260
tachyon::ID vertScrollbarID
Definition gui_table_types.h:232
int8_t sectionCount
Definition gui_table_types.h:275
bool followInit
Definition gui_table_types.h:248
bool followPinned
Definition gui_table_types.h:249
tachyon::ID rowsRangeID
Written by VirtualTable each frame, so keyboard navigation can address and scroll to rows outside the...
Definition gui_table_types.h:237
std::unique_ptr< std::array< tachyon::ID, kMaxTableSections - 1 > > extraSectionBodyIDs
Definition gui_table_types.h:274
tachyon::ID horzScrollbarID
Definition gui_table_types.h:231
bool rowOrderDirty
Set via InvalidateRowOrder().
Definition gui_table_types.h:270
DoubleClickTracker rowClickTracker
Definition gui_table_types.h:259
bool hasHeaders
VirtualTable's showHeaders, for keyboard scroll-into-view.
Definition gui_table_types.h:246
bool anyHorzOverflow
Set at render time when any section overflows; next frame emits a scrollbar only for an overflowing a...
Definition gui_table_types.h:243
int prevFollowRowCount
Definition gui_table_types.h:250
std::unique_ptr< TreeRowMap > treeRowInfo
populated by TreeCell()
Definition gui_table_types.h:253
tachyon::ID bodyID
canonical scroll-Y
Definition gui_table_types.h:230
Per-row metadata from TreeCell().
Definition gui_table_types.h:148
bool hasChildren
drives drag-drop zone shape (thirds vs halves)
Definition gui_table_types.h:153
int depth
nesting level, 0 = root
Definition gui_table_types.h:150
bool * isOpen
null for leaves
Definition gui_table_types.h:149
std::string renameSeed
original label, seeds rename Start()
Definition gui_table_types.h:152
std::string * renameBuf
null when not renameable
Definition gui_table_types.h:151
User-owned, persistent state of one table: column widths, selection, sort, options.
Definition gui_table_types.h:145
std::unordered_map< tachyon::ID, CellLookupEntry > CellLookupMap
Definition gui_table_types.h:160
std::vector< int32_t > columnWidths
Per-column widths in CSS px, persisted; they follow column reorders.
Definition gui_table_types.h:197
int VisualToDataset(int visualIdx) const noexcept
Maps a visual (sorted) row index to its dataset index; identity when not sorted.
Definition gui_table_types.h:332
StyleRef cellStyle
Every body cell, in place of .table-cell; the row height follows it.
Definition gui_table_types.h:217
bool followTail
Stick to the bottom: start at (and select) the last row, and follow new rows while at the bottom.
Definition gui_table_types.h:206
std::function< void(tachyon::ID rowID)> onRowDoubleClick
Replaces the default double-click branch toggle (the chevron still toggles).
Definition gui_table_types.h:225
int selectedColumn
cell-mode only, ignored in row mode
Definition gui_table_types.h:207
struct tachyon::TableState::Internal internal
const TreeRowInfo * FindTreeRow(tachyon::ID id) const noexcept
Tree metadata of row id from TreeCell(); nullptr when not found.
Definition gui_table_types.h:361
void InvalidateRowOrder() noexcept
Rebuilds the sort permutation next frame; call after changing sorted data.
Definition gui_table_types.h:350
std::unordered_map< tachyon::ID, TreeRowInfo > TreeRowMap
row ID -> tree info
Definition gui_table_types.h:155
tachyon::ID selectedRowID
The selected (cursor) row; keyboard navigation moves it.
Definition gui_table_types.h:203
TreeRowMap & EnsureTreeRowInfo()
The tree-row map, allocated on first use; read it with FindTreeRow().
Definition gui_table_types.h:300
int DatasetToVisual(int datasetIdx) const noexcept
Maps a dataset row index to its visual index, or -1 when absent; O(N) when sorted.
Definition gui_table_types.h:340
bool showHeaders
False omits the header row (and with it reorder, resize and sort).
Definition gui_table_types.h:219
void SetSectionBodyID(int i, tachyon::ID id)
Used by the table.
Definition gui_table_types.h:290
tachyon::ID RowIDForIndex(int rowIdx) const noexcept
A row's sub-range ID, usable outside a frame (unlike IDManager::GetSubID).
Definition gui_table_types.h:314
StyleRef rowStyle
Every row's backdrop, in place of the striped .table-row pair.
Definition gui_table_types.h:215
tachyon::ID RowIDInRange(int rowIdx) const noexcept
As RowIDForIndex, without the bound on last frame's row count.
Definition gui_table_types.h:321
TableSelectionMode selectionMode
Definition gui_table_types.h:210
static constexpr int kMaxTableSections
max sections (see VirtualTableColumn::sectionId)
Definition gui_table_types.h:193
bool sortDescending
sort direction of sortColumn
Definition gui_table_types.h:211
void RestartFollowTail() noexcept
With followTail: scrolls to (and selects) the last row next frame, as on first show.
Definition gui_table_types.h:353
CellLookupMap & EnsureCellLookup()
The cell lookup map, allocated on first use; read it with FindCell().
Definition gui_table_types.h:306
std::function< void(int fromCol, int toCol)> ReorderColumnsFn
Moves column fromCol to toCol in the caller's column array.
Definition gui_table_types.h:163
tachyon::ID SectionBodyID(int i) const noexcept
Body element ID of section i (its scroll container); Invalid when out of range.
Definition gui_table_types.h:283
const CellLookupEntry * FindCell(tachyon::ID id) const noexcept
Cell-mode: the row and column of a cell element; nullptr when not found.
Definition gui_table_types.h:368
MultiSelectState * multiSelect
When set, Ctrl/Shift-click selects multiple rows into it.
Definition gui_table_types.h:199
bool columnSeparators
1px lines between the columns of a headerless table.
Definition gui_table_types.h:221
int sortColumn
-1 = unset; VirtualTable snaps an unset or unsortable value to the first sortable column.
Definition gui_table_types.h:209
LazyReorderFn onReorderColumns
headers become drag-to-reorder when set
Definition gui_table_types.h:223
bool selectionBar
Row mode: an accent bar on a selected row's left.
Definition gui_table_types.h:213
ItemDragDropConfig * rowDragDrop
When set with a non-zero payloadType, rows become drag sources and drop targets.
Definition gui_table_types.h:201
Tree reorder drop target under the cursor; internal, owned by the application.
Definition gui_table_types.h:404
int targetDepth
Definition gui_table_types.h:407
TreeDropPosition position
Definition gui_table_types.h:406
tachyon::ID targetRowID
Definition gui_table_types.h:405
Written by the table each frame (end-of-frame handlers read it); not part of the API.
Definition gui_table_types.h:107
tachyon::ID sizerID
Shared by the header and body copies of the boundary after this column, so their hover state syncs.
Definition gui_table_types.h:113
tachyon::ID bodyID
Definition gui_table_types.h:110
int16_t dragOffsetX
Applied to every element of this column during a reorder drag.
Definition gui_table_types.h:118
GridTrack columnTrack
Resolved once per frame.
Definition gui_table_types.h:120
int32_t maxContentWidth
Widest cell content seen (text + tree prefix), for double-click-to-fit.
Definition gui_table_types.h:109
tachyon::ID headerCellID
Ranged, so it doesn't change when the dragged column is emitted last.
Definition gui_table_types.h:115
tachyon::ElementRef headerRef
Definition gui_table_types.h:116
A VirtualTable column: the TableColumn plus cell generator, sort order and section.
Definition gui_table_types.h:90
std::function< void(int rowIndex)> generateCell
Emits the cell of dataset row rowIndex; null in the BeginTable/Cell flow.
Definition gui_table_types.h:93
struct tachyon::VirtualTableColumn::Internal internal
Written by the table; not part of the API.
std::function< bool(int rowA, int rowB)> sortAscending
Ascending strict-weak ordering on dataset row indices; VirtualTable sorts with it.
Definition gui_table_types.h:97
int sectionId
Consecutive columns with the same sectionId form a section, side by side and scrolling independently.
Definition gui_table_types.h:101
SectionSizing sectionSizing
Read from the section's first column only.
Definition gui_table_types.h:103
TableColumn column
Definition gui_table_types.h:91
struct tachyon::ID::Value::RangedParts rangedParts
struct tachyon::ID::Value::SubRangeParts subRangeParts