6#include <source_location>
33 m_parent_stack.reserve(4096);
34 m_static_slots.reserve(4096);
35 m_static_free_list.reserve(4096);
50 public: [[nodiscard]]
inline bool IsInsideFrame()
const {
return !m_parent_stack.empty(); }
75 private:
bool SetGenerationForSlot(uint32_t index, int32_t generation);
85 private: [[nodiscard]]
ID AllocateDynamicID(uint64_t hash);
87#ifdef TACHYON_SUPPORT_CPP20
90 public: [[nodiscard]]
inline ID AllocateDynamicID(
const std::source_location location = std::source_location::current())
92 return AllocateDynamicID(location.file_name(), location.line());
111 private: [[nodiscard]]
ID AllocateRangedID(uint32_t size, uint64_t hash);
113#ifdef TACHYON_SUPPORT_CPP20
116 public: [[nodiscard]]
inline ID AllocateRangedID(uint32_t size,
const std::source_location location = std::source_location::current())
118 return AllocateRangedID(size, location.file_name(), location.line());
175 std::vector<ParentData> m_parent_stack;
180 struct SiteSlot { uint64_t site = 0; uint32_t count = 0; uint32_t frame = 0; };
181 std::vector<SiteSlot> m_site_slots = std::vector<SiteSlot>(1024);
182 uint32_t m_site_used = 0;
183 uint32_t m_frame = 0;
184 uint32_t NextSiteCount(uint64_t site);
187 std::vector<int32_t> m_static_slots;
188 std::vector<uint32_t> m_static_free_list;
189 size_t m_static_id_count = 0;
192 size_t m_dynamic_id_total = 0;
195 size_t m_ranged_count = 0;
197#ifdef TACHYON_ID_DEBUG
198 std::vector<ID> m_debug_dynamic_ids;
199 std::vector<ID> m_debug_ranges;
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 IsInsideFrame() const
True between BeginFrame and EndFrame.
Definition gui_id_manager.h:50
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.
size_t GetDynamicIDCount() const
Live static IDs, and dynamic / ranged IDs made so far this frame.
Definition gui_id_manager.h:162
bool PopParent()
Pops the last PushParent. Never pops the root; false on underflow or outside a frame.
bool IsStaticIDValid(ID id) const
True if the slot is active and the generation matches.
ID GetStackParent() const
The innermost parent; Invalid at the root or outside a frame.
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.
void EndFrame()
Clears the parent stack; reports misuse when a PushParent was left unpopped.
size_t GetStaticIDCount() const
Live static IDs, and dynamic / ranged IDs made so far this frame.
Definition gui_id_manager.h:161
friend struct IDManagerTestAccess
Definition gui_id_manager.h:76
IDManager()
Definition gui_id_manager.h:31
bool BeginFrame()
Resets the parent stack and dynamic/ranged counters.
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 ReleaseStaticID(ID id)
Frees the slot and bumps its generation, invalidating copies of id.
bool IsRangedIDValid(ID id) const
Debug: checks stored ranges (slow). Release: true for any non-Invalid Ranged ID.
bool IsInParentStack(ID id) const
True when id is anywhere on the parent stack. Slow: linear search.
bool IsIDValid(ID id) const
True when id is valid for its mode (see the Is*IDValid functions); slow in debug builds.
bool IsSubRangeIDValid(ID id) const
Debug: checks stored ranges (slow). Release: true for any non-Invalid SubRange ID.
bool PushParent(ID parent_id)
Makes parent_id the parent: dynamic and ranged IDs created under it inherit its hash.
bool IsDynamicIDValid(ID id) const
Debug: checks the tracking list (slow). Release: true for any non-Invalid Dynamic ID.
ID CreateStaticID()
A persistent ID tracked by slot and generation; release it with ReleaseStaticID.
ID AllocateDynamicID(std::string_view hint)
A dynamic ID from hint and the parent stack; different per hint.
size_t GetRangedIDCount() const
Live static IDs, and dynamic / ranged IDs made so far this frame.
Definition gui_id_manager.h:163
Definition gui_logging.h:24
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23