TachyonUI 1.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_tree_grid_types.h
Go to the documentation of this file.
1#pragma once
2
3#include <gui_core/gui_id.h>
4#include <gui_core/style/gui_style_text.h> // IconID
5
6#include <gui_controls/gui_widget_state_types.h> // MultiSelectState, ItemDragDropConfig, DoubleClickTracker
7
8#include <functional>
9#include <string>
10
11// TreeView / ListView / GridView data + construction state.
12
13namespace tachyon
14{
17
18 // ---- Transient tree/list construction state (valid between Begin/End) ----
19 //
20 // Valid only between Begin*/End* (reset in End*). Event handlers run at end of frame,
21 // so they must capture the user-owned pointers instead of reading m_treeState.
22 //
34
35 // ---- GridView: icon grid ----
36 //
37 // Like TreeViewState: valid only between BeginGridView/EndGridView; handlers must
38 // capture user-owned pointers.
39 //
53
54 // ---- GridView rename lookup ----
55 // Filled by GridViewItem for items with a renameBuffer; read by end-of-frame rename handlers.
57 struct GridItemRenameInfo { std::string* renameBuf = nullptr; std::string renameSeed; };
58
59 // ---- TreeView (flat-data, virtualized) -----------------------------
60 // Caller-owned flat rows shown through a VirtualTable. Call RebuildTreeViewIndex after
61 // structural changes. Selection, scroll, drag-drop and which rows are open live on the
62 // TableState, one per view; a row ID maps to its flat index via
63 // visibleIdx[rowID.value.subRangeParts.index].
66 {
71 std::string name;
72 int depth = 0;
74 std::string* renameBuffer = nullptr;
75
76 // Derived by RebuildTreeViewIndex
77
79 int skipCount = 0;
81 uint32_t ancestorLineMask = 0;
82 bool isLastSibling = true;
83
84 bool HasChildren() const { return skipCount > 0; }
85 };
86
89 inline tachyon::ID TreeViewRowKey(const TreeViewRow& row, size_t flat)
90 {
91 if (row.id != tachyon::ID::Invalid())
92 return row.id;
95 key.value.subRangeParts.index = flat;
96 return key;
97 }
98
99 // ---- Virtualized GridView ----
100 //
101 // Like BeginGridView, but only visible rows are emitted. Column count and visible rows
102 // come from last frame's viewport (one-frame settle on first show / resize).
105 {
106 int32_t lastViewportW = 0;
107 int32_t lastViewportH = 0;
110 int32_t cellStretchedW = 0;
113 std::function<void(tachyon::ID itemID)> onOpen;
114
116 struct Internal
117 {
118 // Slow-re-click rename state
123 // Layout for keyboard navigation, which runs after layout
124 int32_t cols = 1;
125 int32_t rowStride = 1;
126 int32_t cellH = 1;
128 };
129
131}
tachyon::ID TreeViewRowKey(const TreeViewRow &row, size_t flat)
How a view's TableState::openRows names the row at flat index flat: its own ID, or for a row without ...
Definition gui_tree_grid_types.h:89
@ SubRange
one item of a Ranged ID: the range's hash plus an index
Definition gui_id.h:17
IconID
Handle for an icon registered with ITextSystem::RegisterIconFromSVG / RegisterIconFromSVGFile.
Definition gui_style_text.h:15
@ Invalid
Definition gui_style_text.h:15
Definition gui_logging.h:24
Click-gesture tracker, owned per widget instance so instances (and tests) don't share it.
Definition gui_widget_state_types.h:77
Rename buffer and original name of a grid item; internal.
Definition gui_tree_grid_types.h:57
std::string * renameBuf
Definition gui_tree_grid_types.h:57
std::string renameSeed
Definition gui_tree_grid_types.h:57
Construction state of the current GridView; internal.
Definition gui_tree_grid_types.h:41
DoubleClickTracker * clickTracker
Slow-re-click rename state in the user's GridViewVirtualState.
Definition gui_tree_grid_types.h:49
tachyon::ID containerID
Definition gui_tree_grid_types.h:42
int nextItemIndex
Definition gui_tree_grid_types.h:43
int * selectedIndex
Definition gui_tree_grid_types.h:44
const std::function< void(tachyon::ID)> * onOpen
GridViewVirtualState::onOpen.
Definition gui_tree_grid_types.h:51
MultiSelectState * multiSelect
Definition gui_tree_grid_types.h:45
tachyon::ID * pendingRenameClick
see clickTracker
Definition gui_tree_grid_types.h:50
ItemDragDropConfig * dragDrop
Definition gui_tree_grid_types.h:46
Written by the grid view each frame; not part of the API.
Definition gui_tree_grid_types.h:117
int32_t cellH
Definition gui_tree_grid_types.h:126
tachyon::ID pendingRenameClick
Definition gui_tree_grid_types.h:120
int32_t rowStride
Definition gui_tree_grid_types.h:125
int32_t cols
Definition gui_tree_grid_types.h:124
tachyon::ID itemsRangeID
Items range ID, so F2 can map selectedIndex to an ID.
Definition gui_tree_grid_types.h:122
DoubleClickTracker itemClickTracker
Definition gui_tree_grid_types.h:119
User-owned, persistent state of a virtualized GridView; keep it alive across frames.
Definition gui_tree_grid_types.h:105
struct tachyon::GridViewVirtualState::Internal internal
not part of the API
std::function< void(tachyon::ID itemID)> onOpen
Called with an item's ID when it's opened: double-clicked, or Enter while it's the selected one (the ...
Definition gui_tree_grid_types.h:113
int32_t cellStretchedW
Cell width (pixels) that makes the columns exactly fill the viewport; use it for fill-width items.
Definition gui_tree_grid_types.h:110
int32_t lastViewportW
last frame's viewport width, pixels
Definition gui_tree_grid_types.h:106
int32_t lastViewportH
last frame's viewport height, pixels
Definition gui_tree_grid_types.h:107
uint64_t index
Definition gui_id.h:61
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:57
Selected item IDs of a multi-select view; user-owned, keep it alive across frames.
Definition gui_widget_state_types.h:22
One row of a flat-data tree view (VirtualTreeView); rows are in depth-first order.
Definition gui_tree_grid_types.h:66
uint32_t ancestorLineMask
Bit d is set when the ancestor at depth d+1 has a next sibling; drives guide lines.
Definition gui_tree_grid_types.h:81
int depth
nesting level, 0 = root; defines the hierarchy
Definition gui_tree_grid_types.h:72
bool isLastSibling
no later sibling at the same depth
Definition gui_tree_grid_types.h:82
int skipCount
Number of descendant rows (skipped when the row is closed); > 0 means it has children.
Definition gui_tree_grid_types.h:79
std::string name
label
Definition gui_tree_grid_types.h:71
std::string * renameBuffer
null = not renameable
Definition gui_tree_grid_types.h:74
IconID icon
Definition gui_tree_grid_types.h:73
tachyon::ID id
The caller's own ID for the row.
Definition gui_tree_grid_types.h:70
bool HasChildren() const
Definition gui_tree_grid_types.h:84
Construction state of the current TreeView / ListView; internal.
Definition gui_tree_grid_types.h:24
int * selectedIndex
for ListView index-based selection
Definition gui_tree_grid_types.h:29
int depth
nesting depth (0 = top-level, no guide lines)
Definition gui_tree_grid_types.h:28
tachyon::ID * selectedID
for single-ID selection
Definition gui_tree_grid_types.h:30
int nextItemIndex
Definition gui_tree_grid_types.h:26
MultiSelectState * multiSelect
for multi-selection
Definition gui_tree_grid_types.h:31
tachyon::ID containerID
Definition gui_tree_grid_types.h:25
ItemDragDropConfig * dragDrop
drag & drop config
Definition gui_tree_grid_types.h:32
int totalItemCount
Definition gui_tree_grid_types.h:27
struct tachyon::ID::Value::SubRangeParts subRangeParts