|
TachyonUI 0.1.0
High-performance UI for building tools.
|
Makes element IDs: per-frame dynamic / ranged IDs (hashed from the call site or a hint and the parent stack) and persistent static IDs. More...
#include <gui_core/gui_id_manager.h>
Public Member Functions | |
| IDManager () | |
| bool | BeginFrame () |
| Resets the parent stack and dynamic/ranged counters. | |
| void | EndFrame () |
| Clears the parent stack; reports misuse when a PushParent was left unpopped. | |
| bool | IsInsideFrame () const |
| True between BeginFrame and EndFrame. | |
| bool | PushParent (ID parent_id) |
| Makes parent_id the parent: dynamic and ranged IDs created under it inherit its hash. | |
| bool | PopParent () |
| Pops the last PushParent. Never pops the root; false on underflow or outside a frame. | |
| ID | CreateStaticID () |
| A persistent ID tracked by slot and generation; release it with ReleaseStaticID. | |
| bool | ReleaseStaticID (ID id) |
| Frees the slot and bumps its generation, invalidating copies of id. | |
| bool | IsStaticIDValid (ID id) const |
| True if the slot is active and the generation matches. | |
| ID | AllocateDynamicID (std::string_view file, int line) |
| A dynamic ID from file and line (FILE, LINE) and the parent stack; different per call site. | |
| ID | AllocateDynamicID (std::string_view hint) |
| A dynamic ID from hint and the parent stack; different per hint. | |
| bool | IsDynamicIDValid (ID id) const |
| Debug: checks the tracking list (slow). Release: true for any non-Invalid Dynamic ID. | |
| ID | AllocateRangedID (uint32_t size, std::string_view file, int line) |
| A ranged ID of size sub-IDs from file and line (FILE, LINE) and the parent stack. | |
| ID | AllocateRangedID (uint32_t size, std::string_view hint) |
| A ranged ID of size sub-IDs from hint and the parent stack; different per hint. | |
| uint32_t | GetRangeSize (ID ranged_id) const |
| The number of sub-IDs in a ranged ID; 0 (and a misuse report) for other modes. | |
| bool | IsRangedIDValid (ID id) const |
| Debug: checks stored ranges (slow). Release: true for any non-Invalid Ranged ID. | |
| ID | GetSubID (ID ranged_id, uint32_t index) const |
| The ID of item index (< range size) in a ranged ID, for indexed content such as list rows. | |
| bool | IsSubRangeIDValid (ID id) const |
| Debug: checks stored ranges (slow). Release: true for any non-Invalid SubRange ID. | |
| bool | IsInParentStack (ID id) const |
| True when id is anywhere on the parent stack. Slow: linear search. | |
| ID | GetStackParent () const |
| The innermost parent; Invalid at the root or outside a frame. | |
| bool | IsIDValid (ID id) const |
| True when id is valid for its mode (see the Is*IDValid functions); slow in debug builds. | |
Friends | |
| struct | IDManagerTestAccess |
| size_t | GetStaticIDCount () const |
| Live static IDs, and dynamic / ranged IDs made so far this frame. | |
| size_t | GetDynamicIDCount () const |
| Live static IDs, and dynamic / ranged IDs made so far this frame. | |
| size_t | GetRangedIDCount () const |
| Live static IDs, and dynamic / ranged IDs made so far this frame. | |
Makes element IDs: per-frame dynamic / ranged IDs (hashed from the call site or a hint and the parent stack) and persistent static IDs.
windowID = idManager.CreateStaticID(); // once: windows, panels, docks
Button("OK", onOK); // the call site is the ID
BeginTabBar(idManager.AllocateDynamicID("tabs"), &selectedTab, nullptr); // a hint
|
inline |
|
nodiscard |
Resets the parent stack and dynamic/ranged counters.
Call before creating any IDs. False (misuse) when the previous frame was not ended.
| void tachyon::IDManager::EndFrame | ( | ) |
Clears the parent stack; reports misuse when a PushParent was left unpopped.
|
inlinenodiscard |
True between BeginFrame and EndFrame.
|
nodiscard |
|
nodiscard |
Pops the last PushParent. Never pops the root; false on underflow or outside a frame.
|
nodiscard |
A persistent ID tracked by slot and generation; release it with ReleaseStaticID.
| bool tachyon::IDManager::ReleaseStaticID | ( | ID | id | ) |
Frees the slot and bumps its generation, invalidating copies of id.
False when id is not the slot's current generation.
| bool tachyon::IDManager::IsStaticIDValid | ( | ID | id | ) | const |
True if the slot is active and the generation matches.
|
nodiscard |
A dynamic ID from file and line (FILE, LINE) and the parent stack; different per call site.
Repeated calls from one site under one parent are numbered in call order.
|
nodiscard |
A dynamic ID from hint and the parent stack; different per hint.
Repeated calls with one hint under one parent are numbered in call order.
|
nodiscard |
Debug: checks the tracking list (slow). Release: true for any non-Invalid Dynamic ID.
|
nodiscard |
|
nodiscard |
A ranged ID of size sub-IDs from hint and the parent stack; different per hint.
| uint32_t tachyon::IDManager::GetRangeSize | ( | ID | ranged_id | ) | const |
The number of sub-IDs in a ranged ID; 0 (and a misuse report) for other modes.
| bool tachyon::IDManager::IsRangedIDValid | ( | ID | id | ) | const |
Debug: checks stored ranges (slow). Release: true for any non-Invalid Ranged ID.
| bool tachyon::IDManager::IsSubRangeIDValid | ( | ID | id | ) | const |
Debug: checks stored ranges (slow). Release: true for any non-Invalid SubRange ID.
| bool tachyon::IDManager::IsInParentStack | ( | ID | id | ) | const |
True when id is anywhere on the parent stack. Slow: linear search.
| ID tachyon::IDManager::GetStackParent | ( | ) | const |
The innermost parent; Invalid at the root or outside a frame.
| bool tachyon::IDManager::IsIDValid | ( | ID | id | ) | const |
True when id is valid for its mode (see the Is*IDValid functions); slow in debug builds.
|
inline |
Live static IDs, and dynamic / ranged IDs made so far this frame.
|
inline |
Live static IDs, and dynamic / ranged IDs made so far this frame.
|
inline |
Live static IDs, and dynamic / ranged IDs made so far this frame.
|
friend |