TachyonUI 0.1.0
High-performance UI for building tools.
Loading...
Searching...
No Matches
gui_element_storage.h
Go to the documentation of this file.
1// Element Storage: per-frame hierarchical storage for GUI elements.
2// See the ElementStorage class documentation below.
3
4#pragma once
5
8
10
14
16
17#include <gui_core/gui_id.h>
20
21#include <unordered_map>
22
23namespace tachyon
24{
27
28 class GUIRenderer;
29 class ElementStorage;
30 class StyleManager;
31 class ElementDataStore;
32
35 enum class ScrollOffsetHandle : uint32_t { Invalid = 0 };
36
37
38 // ------------------------------------------------------------------------
39 // Result type for element storage operations.
40 // ------------------------------------------------------------------------
53
55 struct AddResult
56 {
59
60 operator bool() const { return status == ElementStorageResult::Success; }
61
62 inline bool operator==(ElementStorageResult rhs) const { return status == rhs; }
63 inline bool operator!=(ElementStorageResult rhs) const { return !(*this == rhs); }
64
65 inline bool operator==(const ElementRef& rhs) const { return ref == rhs; }
66 inline bool operator!=(const ElementRef& rhs) const { return !(*this == rhs); }
67 };
68
69 // ------------------------------------------------------------------------
70 // Element Storage - Main storage class
71 // ------------------------------------------------------------------------
72
100 {
101 static constexpr int32_t kMinimumReservedDepth = 32;
102 static constexpr int32_t kMinimumReservedBreadth = 256;
103 public:
104 // ----------------- Construction ------------------
105
106 ElementStorage(StyleManager& styleManager, ElementDataStore* dataStore = nullptr)
107 : m_styleManager(styleManager), m_elementDataStore(dataStore)
108 {
109 while (kMinimumReservedDepth > m_depths.size())
110 {
111 m_depths.emplace_back().Reserve(kMinimumReservedBreadth);
112 }
113 }
114
115 const StyleManager& GetStyleManager() const noexcept { return m_styleManager; }
116
117 ElementStorage(ElementStorage&&) noexcept = default;
118 ElementStorage& operator=(ElementStorage&&) = delete;
119
121 ElementStorage& operator=(const ElementStorage&) = delete;
122
123 // ----------------- Construction ------------------
124
128 {
129 if (m_constructionModeActive) return ElementStorageResult::DuplicateCall;
130 m_generation++; // Wraps around
131 if (m_generation == 0) m_generation = 1; // never 0
132 ClearStorage();
133 m_constructionModeActive = true;
135 }
136
140 {
141 if (!m_constructionModeActive) return ElementStorageResult::NotConstructing;
142 const bool unclosed = !m_parentStack.empty();
143 while (!m_parentStack.empty())
144 (void)EndChildren();
145 m_constructionModeActive = false;
147 }
148
151 [[nodiscard]] AddResult Add(Element&& element, LayoutOverride&& constraints = {});
152
156
160
163
168
171
176 [[nodiscard]] ElementStorageResult MoveChild(uint32_t childDepth, uint32_t rangeBegin,
177 uint32_t fromLocal, uint32_t toLocal,
178 ElementMove* outMove = nullptr);
179
180 // ------------------ Statistics -------------------
181
182 inline bool Empty() const { return m_elementCount == 0; }
183 inline uint32_t ElementCount() const { return m_elementCount; }
184 inline ID GetLastAddedID() const { return m_lastAddedID; }
188 inline ID GetLastItemID() const { return m_lastItemID; }
189 inline ElementRef GetLastAddedRef() const { return m_lastAddedRef; }
190 inline uint32_t GetCurrentNestingDepth() const { return static_cast<uint32_t>(m_parentStack.size()); }
191 inline uint32_t NumberOfDepthLevels() const { return m_usedDepthCount; }
192
193 inline uint32_t DepthSizeOf(uint32_t depth) const
194 {
195 return depth >= m_usedDepthCount ? 0 : m_depths[depth].Size();
196 }
197
198 // ---------------- Queries ----------------
199
203 const ID GetElementIDAt(ElementRef root, int2 position, ID* disabledHit = nullptr) const;
204
212
216
217
218 inline bool IsValidRef(const ElementRef& ref) const
219 {
220 return ref.depth >= m_usedDepthCount ? false :
221 ref.index < m_depths[ref.depth].Size();
222 }
223
224 inline ElementRef GetFirstElementRef() const { return m_usedDepthCount == 0 ? ElementRef::Invalid() : ElementRef{ 0, 0 }; }
225 inline bool HasChildren(const ElementRef& ref) const { return GetChildCount(ref) > 0; }
226
227 inline uint32_t GetChildCount(const ElementRef& ref) const
228 {
229 auto hierarchy = GetHierarchyInfoPtr(ref);
230 return (hierarchy == nullptr) ? 0 : hierarchy->childCount;
231 }
232
233 inline ElementRef GetParentRef(const ElementRef& ref) const
234 {
235 if (ref.depth == 0) return ElementRef::Invalid();
236 auto hierarchy = GetHierarchyInfoPtr(ref);
237 if (hierarchy == nullptr) return ElementRef::Invalid();
238 return ElementRef{ ref.depth - 1, hierarchy->parentIndex };
239 }
240
241 inline ElementRef GetNextSiblingRef(const ElementRef& ref) const
242 {
243 const HierarchyInfo *nodeHierarchy = GetHierarchyInfoPtr(ref);
244 if (nodeHierarchy == nullptr ||
246 return ElementRef{ .depth = ref.depth, .index = nodeHierarchy->nextSiblingIndex };
247 }
248
250 inline Element *GetElementPtr(const ElementRef &elementRef) { if (!IsValidRef(elementRef)) { return nullptr; } return &GetElementUnsafe(elementRef); }
251
252 inline const Element *GetElementPtr(const ElementRef &elementRef) const { if (!IsValidRef(elementRef)) { return nullptr; } return &GetElementUnsafe(elementRef); }
253 inline Element& GetElementUnsafe(const ElementRef &elementRef) { return m_depths[elementRef.depth].elements[elementRef.index]; }
254 inline const Element& GetElementUnsafe(const ElementRef &elementRef) const { return m_depths[elementRef.depth].elements[elementRef.index]; }
255
256 inline ElementRect* GetElementRectPtr(const ElementRef &elementRef) { if (!IsValidRef(elementRef)) { return nullptr; } return &GetElementRectUnsafe(elementRef); }
257 inline const ElementRect* GetElementRectPtr(const ElementRef &elementRef) const { if (!IsValidRef(elementRef)) { return nullptr; } return &GetElementRectUnsafe(elementRef); }
258 inline ElementRect &GetElementRectUnsafe(const ElementRef &elementRef) { return m_depths[elementRef.depth].elementRects[elementRef.index]; }
259 inline const ElementRect& GetElementRectUnsafe(const ElementRef& elementRef) const { return m_depths[elementRef.depth].elementRects[elementRef.index]; }
260
263 inline bool SetContentTransform(const ElementRef& ref, const float3x2& transform)
264 {
265 if (!IsValidRef(ref)) return false;
266 GetElementRectUnsafe(ref).contentTransform = transform;
267 return true;
268 }
269
270 inline const ElementCustomDraw* GetCustomDraw(const ElementRef& elementRef) const
271 {
272 if (!IsValidRef(elementRef)) return nullptr;
273 const auto& cd = m_depths[elementRef.depth].elementCustomDraws[elementRef.index];
274 return (cd.callback || cd.afterHead != UINT32_MAX) ? &cd : nullptr;
275 }
276
283 inline const std::vector<PostLayoutEntry>& GetPostLayoutEntries() const { return m_postLayoutEntries; }
284
286 {
287 return m_depths[elementRef.depth].elementCustomDraws[elementRef.index];
288 }
289
290 inline PostDrawEntry& GetPostDrawEntryUnsafe(uint32_t index)
291 {
292 return m_postDrawEntries[index];
293 }
294
296 std::span<Element> GetChildrenSpan(const ElementRef& parentRef)
297 {
298 auto range = GetChildRange(parentRef); // checks parentRef
299 if (range.Empty()) return {};
300 return { m_depths[parentRef.depth + 1].elements.data() + range.begin, range.Size() };
301 }
302
304 std::span<Element> GetChildrenSpanUnsafe(int depth, const IndexRange range)
305 {
306 return {m_depths[depth].elements.data() + range.begin, range.Size()};
307 }
308
310 std::span<const Element> GetChildrenSpanUnsafe(int depth, const IndexRange range) const
311 {
312 return {m_depths[depth].elements.data() + range.begin,
313 range.Size()};
314 }
315
316
317 std::span<ElementRect> GetChildRectSpanUnsafe(int depth, const IndexRange range)
318 {
319 return {m_depths[depth].elementRects.data() + range.begin, range.Size()};
320 }
321
322 std::span<const ElementRect> GetChildRectSpanUnsafe(int depth, const IndexRange range) const
323 {
324 return {m_depths[depth].elementRects.data() + range.begin, range.Size()};
325 }
326
328 std::span<const Element> GetChildrenSpan(const ElementRef& parentRef) const
329 {
330 auto range = GetChildRange(parentRef); // checks parentRef
331 if (range.Empty()) return {};
332 return { m_depths[parentRef.depth + 1].elements.data() + range.begin, range.Size() };
333 }
334
337 IndexRange GetChildRange(const ElementRef& parentRef) const
338 {
339 if (!IsValidRef(parentRef)) return {};
340 return GetChildRangeUnsafe(parentRef);
341 }
342
343 // ----- Range helpers that return the iterators -----
344 // Only valid after EndConstruction.
345
348 {
349 assert(!m_constructionModeActive);
350 if (Empty()) return TopDownDepthScanTerminator();
351 DepthScanCursor cursor{ .parentCountAtDepth = DepthSizeOf(0) };
352 cursor.childRange = GetChildRangeUnsafe(cursor.CurrentRef());
353 return TopDownDepthScanIterator{*this, m_generation, cursor};
354 }
356 {
357 assert(!m_constructionModeActive && "TopDownDepthScanEnd called during BeginConstruction/EndConstruction");
358 return TopDownDepthScanTerminator();
359 }
360
363 {
364 assert(!m_constructionModeActive);
365 if (Empty()) return BottomUpDepthScanTerminator();
366 DepthScanCursor cursor{ .parentDepth = m_usedDepthCount - 1, .parentIndex = 0 };
368 cursor.childRange = GetChildRangeUnsafe(cursor.CurrentRef());
369 return BottomUpDepthScanIterator{*this, m_generation, cursor};
370 }
372 {
373 assert(!m_constructionModeActive && "BottomUpDepthScanIterator called during BeginConstruction/EndConstruction");
374 return BottomUpDepthScanTerminator();
375 }
376
379
380
381 private:
382 inline TopDownDepthScanIterator TopDownDepthScanTerminator() const { return TopDownDepthScanIterator{ .storage{*this}, .generation = m_generation, .cursor = DepthScanCursor::EndCursor() }; }
383 inline BottomUpDepthScanIterator BottomUpDepthScanTerminator() const { return BottomUpDepthScanIterator{ .storage{*this}, .generation = m_generation, .cursor = DepthScanCursor::EndCursor() }; }
384
385 void AdvanceTopDownDepthScan(DepthScanCursor& cursor) const;
386
388 void AdvanceBottomUpDepthScan(DepthScanCursor& cursor) const;
389
390
391 private:
392 inline const HierarchyInfo* GetHierarchyInfoPtr(const ElementRef& elementRef) const
393 {
394 if (!IsValidRef(elementRef)) return nullptr;
395 return &m_depths[elementRef.depth].hierarchy[elementRef.index];
396 }
397
398 inline HierarchyInfo *GetHierarchyInfoPtr(const ElementRef &elementRef)
399 {
400 if (!IsValidRef(elementRef)) return nullptr;
401 return &m_depths[elementRef.depth].hierarchy[elementRef.index];
402 }
403
404 inline const HierarchyInfo* GetHierarchyInfoPtrUnsafe(const ElementRef& elementRef) const
405 {
406 return &m_depths[elementRef.depth].hierarchy[elementRef.index];
407 }
408
409 inline HierarchyInfo* GetHierarchyInfoPtrUnsafe(const ElementRef& elementRef)
410 {
411 return &m_depths[elementRef.depth].hierarchy[elementRef.index];
412 }
413
415 IndexRange GetChildRangeUnsafe(const ElementRef& parentRef) const
416 {
417 auto& parent = m_depths[parentRef.depth].hierarchy[parentRef.index];
418 if (parent.childCount == 0) return {};
419 return IndexRange{ parent.childOffset, parent.childOffset + parent.childCount };
420 }
421
423 void RotateDepthLevel(uint32_t depth, uint32_t begin, uint32_t mid, uint32_t end);
424
425 void RebuildSiblingLinks(uint32_t depth, uint32_t rangeBegin, uint32_t rangeEnd, uint32_t parentIndex);
426
428 void ClearStorage();
429
430
431 private:
433 struct DepthLevel
434 {
435 std::vector<Element> elements;
436 std::vector<ElementRect> elementRects;
437 std::vector<ElementCustomDraw> elementCustomDraws;
438 std::vector<HierarchyInfo> hierarchy;
439
440 inline uint32_t Size() const { return static_cast<uint32_t>(elements.size()); }
441 inline bool Empty() const { return elements.empty(); }
442
443 void Clear();
444
445 void Reserve(uint32_t capacity);
446
447 inline uint32_t PeekIndex() const
448 {
449 return Size();
450 }
451
452 inline uint32_t Add(int32_t parentIndex, Element&& element, ElementRect&& elementRect)
453 {
454 uint32_t index = Size();
455 elements.push_back(std::move(element));
456 elementRects.push_back(std::move(elementRect));
457 elementCustomDraws.push_back({});
458 hierarchy.push_back(HierarchyInfo::Initialize(parentIndex));
459 return index;
460 }
461 };
462
463 std::vector<DepthLevel> m_depths;
464
465 struct ParentStackEntry
466 {
467 ElementRef ref = {};
468 uint32_t startChildIndex = 0;
469 ID itemBefore = ID::Invalid();
470 };
471
472 std::vector<ParentStackEntry> m_parentStack;
473
475 ElementRef m_lastAddedRef = ElementRef::Invalid();
476 ID m_lastAddedID = ID::Invalid();
477 ID m_lastItemID = ID::Invalid();
478 bool m_childrenBegun = false;
479
480 uint32_t m_elementCount = 0;
481
483 uint32_t m_usedDepthCount = 0;
484
485 uint64_t m_generation = 1;
486 bool m_constructionModeActive = false;
487
488
489 std::vector<PostDrawEntry> m_postDrawEntries;
490 std::vector<PostLayoutEntry> m_postLayoutEntries;
491
492 StyleManager &m_styleManager;
493 ElementDataStore* m_elementDataStore = nullptr;
494
496 mutable std::unordered_map<ID, ElementRef> m_idIndex;
497 mutable bool m_idIndexStale = false;
498 void IndexElement(ID id, ElementRef ref) const;
499 };
500
501
502 // ------------------------------------------------------------------------
503 // ElementStorage iterators and range helpers (members)
504 // ------------------------------------------------------------------------
505
506 inline bool TopDownDepthScanIterator::Validate() const { return storage.m_generation == generation; }
507 inline bool BottomUpDepthScanIterator::Validate() const { return storage.m_generation == generation; }
508
509 inline TopDownDepthScanIterator& TopDownDepthScanIterator::operator++() { if (!Validate()) cursor.SetDone(); else storage.AdvanceTopDownDepthScan(cursor); return *this; }
510 inline TopDownDepthScanIterator TopDownDepthScanIterator::operator++(int) { TopDownDepthScanIterator tmp = *this; if (!Validate()) cursor.SetDone(); else storage.AdvanceTopDownDepthScan(cursor); return tmp; }
511
512 inline BottomUpDepthScanIterator& BottomUpDepthScanIterator::operator++() { if (!Validate()) cursor.SetDone(); else storage.AdvanceBottomUpDepthScan(cursor); return *this; }
513 inline BottomUpDepthScanIterator BottomUpDepthScanIterator::operator++(int) { BottomUpDepthScanIterator tmp = *this; if (!Validate()) cursor.SetDone(); else storage.AdvanceBottomUpDepthScan(cursor); return tmp; }
514
516} // namespace tachyon
Per-element typed state keyed by ID, kept across frames (drag start, double-click timing).
Definition gui_element_data_store.h:23
The frame's element tree.
Definition gui_element_storage.h:100
const std::vector< PostLayoutEntry > & GetPostLayoutEntries() const
Definition gui_element_storage.h:283
PostDrawEntry & GetPostDrawEntryUnsafe(uint32_t index)
Definition gui_element_storage.h:290
const Element * GetElementPtr(const ElementRef &elementRef) const
Definition gui_element_storage.h:252
uint32_t NumberOfDepthLevels() const
Definition gui_element_storage.h:191
const ElementRect & GetElementRectUnsafe(const ElementRef &elementRef) const
Definition gui_element_storage.h:259
ElementStorageResult MoveChild(uint32_t childDepth, uint32_t rangeBegin, uint32_t fromLocal, uint32_t toLocal, ElementMove *outMove=nullptr)
Moves a child (with its subtree) to another sibling position, during construction.
uint32_t DepthSizeOf(uint32_t depth) const
Definition gui_element_storage.h:193
uint32_t GetChildCount(const ElementRef &ref) const
Definition gui_element_storage.h:227
const ElementCustomDraw * GetCustomDraw(const ElementRef &elementRef) const
Definition gui_element_storage.h:270
const StyleManager & GetStyleManager() const noexcept
Definition gui_element_storage.h:115
ID GetLastItemID() const
The element last added at the level being built, its children done: after a control with parts,...
Definition gui_element_storage.h:188
BottomUpDepthScanRangeIterator BottomUpDepthScanRange() const
Definition gui_element_storage.h:378
ElementRef FindElementRefByID(ID id) const
The element with id; Invalid when not found (always for ID::Invalid).
friend struct TopDownDepthScanIterator
Definition gui_element_storage.h:346
ElementStorage(StyleManager &styleManager, ElementDataStore *dataStore=nullptr)
Definition gui_element_storage.h:106
Element & GetElementUnsafe(const ElementRef &elementRef)
Definition gui_element_storage.h:253
IndexRange GetChildRange(const ElementRef &parentRef) const
The indices of parentRef's children at the next depth; empty on invalid ref or no children.
Definition gui_element_storage.h:337
BottomUpDepthScanIterator BottomUpDepthScanEnd() const
Definition gui_element_storage.h:371
ElementStorageResult AddCustomDrawAfter(const ElementRef &ref, CustomDrawCallback callback)
Draws callback after ref's whole subtree, in the same space as AddCustomDraw.
ElementRect * GetElementRectPtr(const ElementRef &elementRef)
Definition gui_element_storage.h:256
ElementRef GetFirstElementRef() const
Definition gui_element_storage.h:224
bool Empty() const
Definition gui_element_storage.h:182
ElementStorageResult AddPostLayout(const ElementRef &ref, PostLayoutCallback callback)
Runs callback after layout, before rendering, with read-only final geometry.
std::span< Element > GetChildrenSpan(const ElementRef &parentRef)
Valid until the next BeginConstruction. Empty on invalid ref or no children.
Definition gui_element_storage.h:296
TopDownDepthScanRangeIterator TopDownDepthScanRange() const
Definition gui_element_storage.h:377
std::span< Element > GetChildrenSpanUnsafe(int depth, const IndexRange range)
Unchecked. Valid until the next BeginConstruction.
Definition gui_element_storage.h:304
TopDownDepthScanIterator TopDownDepthScanBegin() const
Definition gui_element_storage.h:347
ElementStorage(ElementStorage &&) noexcept=default
ElementRect & GetElementRectUnsafe(const ElementRef &elementRef)
Definition gui_element_storage.h:258
std::span< const Element > GetChildrenSpan(const ElementRef &parentRef) const
Valid until the next BeginConstruction. Empty on invalid ref or no children.
Definition gui_element_storage.h:328
friend struct BottomUpDepthScanIterator
Definition gui_element_storage.h:361
int2 ScreenToElementSpace(int2 screenPos, ElementRef ref) const
Converts a screen point into the space ref's own rect is stored in, applying each ancestor's inverse ...
bool SetContentTransform(const ElementRef &ref, const float3x2 &transform)
Sets the transform applied to ref's children at render / hit-test time (pan, zoom).
Definition gui_element_storage.h:263
ElementCustomDraw & GetElementCustomDrawUnsafe(const ElementRef &elementRef)
Definition gui_element_storage.h:285
bool IsValidRef(const ElementRef &ref) const
Definition gui_element_storage.h:218
ElementStorageResult BeginConstruction()
Starts building a new tree, clearing the previous one.
Definition gui_element_storage.h:127
Element * GetElementPtr(const ElementRef &elementRef)
The element, or nullptr for an invalid ref.
Definition gui_element_storage.h:250
AddResult Add(Element &&element, LayoutOverride &&constraints={})
Adds element after the previous one at the current nesting level.
ElementStorageResult AddCustomDraw(const ElementRef &ref, CustomDrawCallback callback)
Draws callback before ref's children render.
BottomUpDepthScanIterator BottomUpDepthScanBegin() const
Definition gui_element_storage.h:362
uint32_t GetCurrentNestingDepth() const
Definition gui_element_storage.h:190
std::span< const ElementRect > GetChildRectSpanUnsafe(int depth, const IndexRange range) const
Definition gui_element_storage.h:322
uint32_t ElementCount() const
Definition gui_element_storage.h:183
bool HasChildren(const ElementRef &ref) const
Definition gui_element_storage.h:225
ElementStorageResult BeginChildren()
Begins adding children to the last added element; elements without BeginChildren are leaves.
ElementStorageResult EndChildren()
Closes the innermost BeginChildren. Fails outside construction or without one open.
ElementRef GetLastAddedRef() const
Definition gui_element_storage.h:189
ElementStorageResult EndConstruction()
Finishes the tree; NotConstructing if not constructing.
Definition gui_element_storage.h:139
ID GetLastAddedID() const
Definition gui_element_storage.h:184
std::span< ElementRect > GetChildRectSpanUnsafe(int depth, const IndexRange range)
Definition gui_element_storage.h:317
const Element & GetElementUnsafe(const ElementRef &elementRef) const
Definition gui_element_storage.h:254
IntRect ElementRectOnScreen(ElementRef ref) const
ref's border box on the screen: through its ancestors' contentTransforms (a canvas's pan and zoom),...
ElementRef GetNextSiblingRef(const ElementRef &ref) const
Definition gui_element_storage.h:241
const ElementRect * GetElementRectPtr(const ElementRef &elementRef) const
Definition gui_element_storage.h:257
TopDownDepthScanIterator TopDownDepthScanEnd() const
Definition gui_element_storage.h:355
std::span< const Element > GetChildrenSpanUnsafe(int depth, const IndexRange range) const
Unchecked. Valid until the next BeginConstruction.
Definition gui_element_storage.h:310
ElementRef GetParentRef(const ElementRef &ref) const
Definition gui_element_storage.h:233
const ID GetElementIDAt(ElementRef root, int2 position, ID *disabledHit=nullptr) const
The element at position that takes input, or Invalid.
Definition gui_renderer.h:43
Bakes serializable Styles into deduplicated runtime layout/visual styles; a StyleRef holds indices in...
Definition gui_style_manager.h:39
std::function< void(PostLayoutContext &ctx)> PostLayoutCallback
Runs after layout, before rendering, with read-only access to final rects/transforms.
Definition gui_element.h:94
Range< BottomUpDepthScanIterator > BottomUpDepthScanRangeIterator
Definition gui_element_iterators.h:132
TopDownDepthScanIterator & operator++()
Definition gui_element_storage.h:509
Range< TopDownDepthScanIterator > TopDownDepthScanRangeIterator
Definition gui_element_iterators.h:131
ScrollOffsetHandle
A handle to a stored scroll offset.
Definition gui_element_storage.h:35
bool Validate() const
Definition gui_element_storage.h:506
BottomUpDepthScanIterator & operator++()
Definition gui_element_storage.h:512
ElementStorageResult
Outcome of an ElementStorage call.
Definition gui_element_storage.h:43
bool Validate() const
Definition gui_element_storage.h:507
std::function< void(CustomDrawContext &ctx)> CustomDrawCallback
Render-time callback.
Definition gui_element.h:89
@ InvalidStyle
The element's style is invalid.
Definition gui_element_storage.h:50
@ NotConstructing
Called outside BeginConstruction/EndConstruction.
Definition gui_element_storage.h:45
@ MissingBeginChildren
EndChildren without an open BeginChildren.
Definition gui_element_storage.h:47
@ Success
Definition gui_element_storage.h:44
@ MissingEndChildren
BeginChildren left open when construction ended.
Definition gui_element_storage.h:48
@ UnknownProblem
An invalid ref or another unexpected state.
Definition gui_element_storage.h:51
@ MissingAdd
Called without first calling Add.
Definition gui_element_storage.h:46
@ DuplicateCall
Called again where once is allowed (e.g. BeginChildren twice).
Definition gui_element_storage.h:49
@ Invalid
Definition gui_image.h:37
Definition gui_logging.h:24
What Add returns: the new element's ref and status; true on success.
Definition gui_element_storage.h:56
bool operator==(const ElementRef &rhs) const
Definition gui_element_storage.h:65
bool operator!=(ElementStorageResult rhs) const
Definition gui_element_storage.h:63
ElementStorageResult status
Definition gui_element_storage.h:58
bool operator!=(const ElementRef &rhs) const
Definition gui_element_storage.h:66
ElementRef ref
Definition gui_element_storage.h:57
bool operator==(ElementStorageResult rhs) const
Definition gui_element_storage.h:62
Definition gui_element_iterators.h:89
const ElementStorage & storage
Definition gui_element_iterators.h:90
DepthScanCursor cursor
Definition gui_element_iterators.h:92
uint64_t generation
Definition gui_element_iterators.h:91
Definition gui_element_iterators.h:20
uint32_t parentDepth
Definition gui_element_iterators.h:21
static constexpr DepthScanCursor EndCursor()
Definition gui_element_iterators.h:49
uint32_t parentCountAtDepth
Definition gui_element_iterators.h:23
IndexRange childRange
This parent's children at parentDepth + 1.
Definition gui_element_iterators.h:26
void SetDone()
Definition gui_element_iterators.h:50
ElementRef CurrentRef() const
Definition gui_element_iterators.h:30
callback fires before the children render; the after-list fires after the whole subtree.
Definition gui_element.h:193
What a MoveChild did: the slot rotations it applied at each depth, so code that stores ElementRefs (e...
Definition gui_element.h:162
Definition gui_element.h:57
float3x2 contentTransform
Applied to children at render/hit-test time; layout ignores it except for scroll clamping.
Definition gui_element.h:72
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
uint32_t depth
Definition gui_element.h:128
uint32_t index
Index into the depth's array, which holds children of many parents.
Definition gui_element.h:131
Fired in registration order between layout and rendering.
Definition gui_element_storage.h:279
ElementRef ownerRef
Definition gui_element_storage.h:281
PostLayoutCallback callback
Definition gui_element_storage.h:280
Definition gui_element.h:33
Definition gui_element.h:101
static constexpr uint32_t kInvalidNextIndex
Definition gui_element.h:113
static constexpr HierarchyInfo Initialize(uint32_t parentIndex)
Definition gui_element.h:102
uint32_t nextSiblingIndex
Next sibling at same depth.
Definition gui_element.h:116
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
A half-open range [begin, end) of indices within one depth.
Definition gui_element.h:148
uint32_t begin
Definition gui_element.h:149
uint32_t Size() const
Definition gui_element.h:153
Definition gui_base_types.h:407
Per-element overrides of style layout properties.
Definition gui_constraints.h:150
Node in the flat post-draw linked list stored in ElementStorage.
Definition gui_element.h:183
Definition gui_element_iterators.h:64
const ElementStorage & storage
Definition gui_element_iterators.h:65
DepthScanCursor cursor
Definition gui_element_iterators.h:67
uint64_t generation
Definition gui_element_iterators.h:66
2D affine transform matrix (2 rows x 3 columns): x' = r0.x*x + r0.y*y + r0.z y' = r1....
Definition gui_base_types.h:219
Integer 2D vector.
Definition gui_base_types.h:19