TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
tachyon::TableState Struct Reference

User-owned, persistent state of one table: column widths, selection, sort, options. More...

#include <gui_controls/gui_table_types.h>

Classes

struct  TreeRowInfo
 Per-row metadata from TreeCell(). More...
struct  CellLookupEntry
 Cell-mode click dispatch: cell-element ID -> (rowID, columnIdx). More...
class  LazyReorderFn
 A ReorderColumnsFn that costs one pointer when unset; assign it like a std::function: state.onReorderColumns = [&](int from, int to) { ... };. More...
struct  Internal
 Written by the table each frame; not part of the API. More...

Public Types

using TreeRowMap = std::unordered_map<tachyon::ID, TreeRowInfo>
 row ID -> tree info
using CellLookupMap = std::unordered_map<tachyon::ID, CellLookupEntry>
using ReorderColumnsFn = std::function<void(int fromCol, int toCol)>
 Moves column fromCol to toCol in the caller's column array.

Public Member Functions

tachyon::ID SectionBodyID (int i) const noexcept
 Body element ID of section i (its scroll container); Invalid when out of range.
void SetSectionBodyID (int i, tachyon::ID id)
 Used by the table.
TreeRowMap & EnsureTreeRowInfo ()
 The tree-row map, allocated on first use; read it with FindTreeRow().
CellLookupMap & EnsureCellLookup ()
 The cell lookup map, allocated on first use; read it with FindCell().
tachyon::ID RowIDForIndex (int rowIdx) const noexcept
 A row's sub-range ID, usable outside a frame (unlike IDManager::GetSubID).
tachyon::ID RowIDInRange (int rowIdx) const noexcept
 As RowIDForIndex, without the bound on last frame's row count.
int VisualToDataset (int visualIdx) const noexcept
 Maps a visual (sorted) row index to its dataset index; identity when not sorted.
int DatasetToVisual (int datasetIdx) const noexcept
 Maps a dataset row index to its visual index, or -1 when absent; O(N) when sorted.
void InvalidateRowOrder () noexcept
 Rebuilds the sort permutation next frame; call after changing sorted data.
void RestartFollowTail () noexcept
 With followTail: scrolls to (and selects) the last row next frame, as on first show.
const TreeRowInfo * FindTreeRow (tachyon::ID id) const noexcept
 Tree metadata of row id from TreeCell(); nullptr when not found.
const CellLookupEntry * FindCell (tachyon::ID id) const noexcept
 Cell-mode: the row and column of a cell element; nullptr when not found.

Public Attributes

std::vector< int32_t > columnWidths
 Per-column widths in CSS px, persisted; they follow column reorders.
MultiSelectState * multiSelect = nullptr
 When set, Ctrl/Shift-click selects multiple rows into it.
ItemDragDropConfig * rowDragDrop = nullptr
 When set with a non-zero payloadType, rows become drag sources and drop targets.
tachyon::ID selectedRowID = tachyon::ID::Invalid()
 The selected (cursor) row; keyboard navigation moves it.
bool followTail = false
 Stick to the bottom: start at (and select) the last row, and follow new rows while at the bottom.
int selectedColumn = 0
 cell-mode only, ignored in row mode
int sortColumn = -1
 -1 = unset; VirtualTable snaps an unset or unsortable value to the first sortable column.
TableSelectionMode selectionMode = TableSelectionMode::Row
bool sortDescending = false
 sort direction of sortColumn
bool selectionBar = false
 Row mode: an accent bar on a selected row's left.
StyleRef rowStyle = StyleRef::Invalid()
 Every row's backdrop, in place of the striped .table-row pair.
StyleRef cellStyle = StyleRef::Invalid()
 Every body cell, in place of .table-cell; the row height follows it.
bool showHeaders = true
 False omits the header row (and with it reorder, resize and sort).
bool columnSeparators = true
 1px lines between the columns of a headerless table.
LazyReorderFn onReorderColumns
 headers become drag-to-reorder when set
std::function< void(tachyon::ID rowID)> onRowDoubleClick
 Replaces the default double-click branch toggle (the chevron still toggles).
struct tachyon::TableState::Internal internal

Static Public Attributes

static constexpr int kMaxTableSections = 8
 max sections (see VirtualTableColumn::sectionId)

Detailed Description

User-owned, persistent state of one table: column widths, selection, sort, options.

Keep it alive across frames; its internal member is not part of the API.

Member Typedef Documentation

◆ TreeRowMap

row ID -> tree info

◆ CellLookupMap

◆ ReorderColumnsFn

using tachyon::TableState::ReorderColumnsFn = std::function<void(int fromCol, int toCol)>

Moves column fromCol to toCol in the caller's column array.

Member Function Documentation

◆ SectionBodyID()

tachyon::ID tachyon::TableState::SectionBodyID ( int i) const
inlinenoexcept

Body element ID of section i (its scroll container); Invalid when out of range.

◆ SetSectionBodyID()

void tachyon::TableState::SetSectionBodyID ( int i,
tachyon::ID id )
inline

Used by the table.

◆ EnsureTreeRowInfo()

TreeRowMap & tachyon::TableState::EnsureTreeRowInfo ( )
inline

The tree-row map, allocated on first use; read it with FindTreeRow().

◆ EnsureCellLookup()

CellLookupMap & tachyon::TableState::EnsureCellLookup ( )
inline

The cell lookup map, allocated on first use; read it with FindCell().

◆ RowIDForIndex()

tachyon::ID tachyon::TableState::RowIDForIndex ( int rowIdx) const
inlinenoexcept

A row's sub-range ID, usable outside a frame (unlike IDManager::GetSubID).

Invalid when out of range.

◆ RowIDInRange()

tachyon::ID tachyon::TableState::RowIDInRange ( int rowIdx) const
inlinenoexcept

As RowIDForIndex, without the bound on last frame's row count.

◆ VisualToDataset()

int tachyon::TableState::VisualToDataset ( int visualIdx) const
inlinenoexcept

Maps a visual (sorted) row index to its dataset index; identity when not sorted.

◆ DatasetToVisual()

int tachyon::TableState::DatasetToVisual ( int datasetIdx) const
inlinenoexcept

Maps a dataset row index to its visual index, or -1 when absent; O(N) when sorted.

◆ InvalidateRowOrder()

void tachyon::TableState::InvalidateRowOrder ( )
inlinenoexcept

Rebuilds the sort permutation next frame; call after changing sorted data.

◆ RestartFollowTail()

void tachyon::TableState::RestartFollowTail ( )
inlinenoexcept

With followTail: scrolls to (and selects) the last row next frame, as on first show.

◆ FindTreeRow()

const TreeRowInfo * tachyon::TableState::FindTreeRow ( tachyon::ID id) const
inlinenoexcept

Tree metadata of row id from TreeCell(); nullptr when not found.

◆ FindCell()

const CellLookupEntry * tachyon::TableState::FindCell ( tachyon::ID id) const
inlinenoexcept

Cell-mode: the row and column of a cell element; nullptr when not found.

Member Data Documentation

◆ kMaxTableSections

int tachyon::TableState::kMaxTableSections = 8
staticconstexpr

max sections (see VirtualTableColumn::sectionId)

◆ columnWidths

std::vector<int32_t> tachyon::TableState::columnWidths

Per-column widths in CSS px, persisted; they follow column reorders.

◆ multiSelect

MultiSelectState* tachyon::TableState::multiSelect = nullptr

When set, Ctrl/Shift-click selects multiple rows into it.

◆ rowDragDrop

ItemDragDropConfig* tachyon::TableState::rowDragDrop = nullptr

When set with a non-zero payloadType, rows become drag sources and drop targets.

◆ selectedRowID

tachyon::ID tachyon::TableState::selectedRowID = tachyon::ID::Invalid()

The selected (cursor) row; keyboard navigation moves it.

◆ followTail

bool tachyon::TableState::followTail = false

Stick to the bottom: start at (and select) the last row, and follow new rows while at the bottom.

Scrolling up detaches; scrolling back down re-attaches.

◆ selectedColumn

int tachyon::TableState::selectedColumn = 0

cell-mode only, ignored in row mode

◆ sortColumn

int tachyon::TableState::sortColumn = -1

-1 = unset; VirtualTable snaps an unset or unsortable value to the first sortable column.

◆ selectionMode

TableSelectionMode tachyon::TableState::selectionMode = TableSelectionMode::Row

◆ sortDescending

bool tachyon::TableState::sortDescending = false

sort direction of sortColumn

◆ selectionBar

bool tachyon::TableState::selectionBar = false

Row mode: an accent bar on a selected row's left.

◆ rowStyle

StyleRef tachyon::TableState::rowStyle = StyleRef::Invalid()

Every row's backdrop, in place of the striped .table-row pair.

◆ cellStyle

StyleRef tachyon::TableState::cellStyle = StyleRef::Invalid()

Every body cell, in place of .table-cell; the row height follows it.

◆ showHeaders

bool tachyon::TableState::showHeaders = true

False omits the header row (and with it reorder, resize and sort).

◆ columnSeparators

bool tachyon::TableState::columnSeparators = true

1px lines between the columns of a headerless table.

◆ onReorderColumns

LazyReorderFn tachyon::TableState::onReorderColumns

headers become drag-to-reorder when set

◆ onRowDoubleClick

std::function<void(tachyon::ID rowID)> tachyon::TableState::onRowDoubleClick

Replaces the default double-click branch toggle (the chevron still toggles).

◆ internal

struct tachyon::TableState::Internal tachyon::TableState::internal

The documentation for this struct was generated from the following file: