mirror of
https://github.com/xemu-project/imgui.git
synced 2024-11-23 10:19:46 +00:00
Internals: fixed ImPool:: iteration, rename GetBufSize to GetMapSize. Amend c6c82b9f
This commit is contained in:
parent
c6c82b9f1d
commit
94b680e830
16
imgui.cpp
16
imgui.cpp
@ -11023,9 +11023,9 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
cfg->ShowTablesRects |= Combo("##show_table_rects_type", &cfg->ShowTablesRectsType, trt_rects_names, TRT_Count, TRT_Count);
|
||||
if (cfg->ShowTablesRects && g.NavWindow != NULL)
|
||||
{
|
||||
for (int table_n = 0; table_n < g.Tables.GetBufSize(); table_n++)
|
||||
for (int table_n = 0; table_n < g.Tables.GetMapSize(); table_n++)
|
||||
{
|
||||
ImGuiTable* table = g.Tables.TryGetBufData(table_n);
|
||||
ImGuiTable* table = g.Tables.TryGetMapData(table_n);
|
||||
if (table == NULL || table->LastFrameActive < g.FrameCount - 1 || (table->OuterWindow != g.NavWindow && table->InnerWindow != g.NavWindow))
|
||||
continue;
|
||||
|
||||
@ -11110,8 +11110,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
// Details for TabBars
|
||||
if (TreeNode("TabBars", "Tab Bars (%d)", g.TabBars.GetAliveCount()))
|
||||
{
|
||||
for (int n = 0; n < g.TabBars.GetBufSize(); n++)
|
||||
if (ImGuiTabBar* tab_bar = g.TabBars.TryGetBufData(n))
|
||||
for (int n = 0; n < g.TabBars.GetMapSize(); n++)
|
||||
if (ImGuiTabBar* tab_bar = g.TabBars.TryGetMapData(n))
|
||||
{
|
||||
PushID(tab_bar);
|
||||
DebugNodeTabBar(tab_bar, "TabBar");
|
||||
@ -11123,8 +11123,8 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
// Details for Tables
|
||||
if (TreeNode("Tables", "Tables (%d)", g.Tables.GetAliveCount()))
|
||||
{
|
||||
for (int n = 0; n < g.Tables.GetBufSize(); n++)
|
||||
if (ImGuiTable* table = g.Tables.TryGetBufData(n))
|
||||
for (int n = 0; n < g.Tables.GetMapSize(); n++)
|
||||
if (ImGuiTable* table = g.Tables.TryGetMapData(n))
|
||||
DebugNodeTable(table);
|
||||
TreePop();
|
||||
}
|
||||
@ -11259,9 +11259,9 @@ void ImGui::ShowMetricsWindow(bool* p_open)
|
||||
// Overlay: Display Tables Rectangles
|
||||
if (cfg->ShowTablesRects)
|
||||
{
|
||||
for (int table_n = 0; table_n < g.Tables.GetBufSize(); table_n++)
|
||||
for (int table_n = 0; table_n < g.Tables.GetMapSize(); table_n++)
|
||||
{
|
||||
ImGuiTable* table = g.Tables.TryGetBufData(table_n);
|
||||
ImGuiTable* table = g.Tables.TryGetMapData(table_n);
|
||||
if (table == NULL || table->LastFrameActive < g.FrameCount - 1)
|
||||
continue;
|
||||
ImDrawList* draw_list = GetForegroundDrawList(table->OuterWindow);
|
||||
|
2
imgui.h
2
imgui.h
@ -61,7 +61,7 @@ Index of this file:
|
||||
// Version
|
||||
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals. Work in progress versions typically starts at XYY99 then bounce up to XYY00, XYY01 etc. when release tagging happens)
|
||||
#define IMGUI_VERSION "1.84 WIP"
|
||||
#define IMGUI_VERSION_NUM 18303
|
||||
#define IMGUI_VERSION_NUM 18304
|
||||
#define IMGUI_CHECKVERSION() ImGui::DebugCheckVersionAndDataLayout(IMGUI_VERSION, sizeof(ImGuiIO), sizeof(ImGuiStyle), sizeof(ImVec2), sizeof(ImVec4), sizeof(ImDrawVert), sizeof(ImDrawIdx))
|
||||
#define IMGUI_HAS_TABLE
|
||||
|
||||
|
@ -612,7 +612,7 @@ struct IMGUI_API ImPool
|
||||
ImVector<T> Buf; // Contiguous data
|
||||
ImGuiStorage Map; // ID->Index
|
||||
ImPoolIdx FreeIdx; // Next free idx to use
|
||||
ImPoolIdx AliveCount; // Number of active/alive items (for display purpose only)
|
||||
ImPoolIdx AliveCount; // Number of active/alive items (for display purpose)
|
||||
|
||||
ImPool() { FreeIdx = AliveCount = 0; }
|
||||
~ImPool() { Clear(); }
|
||||
@ -627,13 +627,14 @@ struct IMGUI_API ImPool
|
||||
void Remove(ImGuiID key, ImPoolIdx idx) { Buf[idx].~T(); *(int*)&Buf[idx] = FreeIdx; FreeIdx = idx; Map.SetInt(key, -1); AliveCount--; }
|
||||
void Reserve(int capacity) { Buf.reserve(capacity); Map.Data.reserve(capacity); }
|
||||
|
||||
// To iterate a ImPool: for (int n = 0; n < pool.GetBufSize(); n++) if (T* t = pool.TryGetBufData(n)) { ... }
|
||||
// Can be avoided if you know .Remove() has never been called on the pool, or AliveCount == GetBufSize()
|
||||
int GetAliveCount() const { return AliveCount; } // Number of active/alive items in the pool (for display purpose only)
|
||||
int GetBufSize() const { IM_ASSERT(Buf.Size == Map.Data.Size); return Buf.Size; }
|
||||
T* TryGetBufData(ImPoolIdx n) { int idx = Map.Data[n].val_i; if (idx == -1) return NULL; return GetByIndex(idx); }
|
||||
// To iterate a ImPool: for (int n = 0; n < pool.GetMapSize(); n++) if (T* t = pool.TryGetMapData(n)) { ... }
|
||||
// Can be avoided if you know .Remove() has never been called on the pool, or AliveCount == GetMapSize()
|
||||
int GetAliveCount() const { return AliveCount; } // Number of active/alive items in the pool (for display purpose)
|
||||
int GetBufSize() const { return Buf.Size; }
|
||||
int GetMapSize() const { return Map.Data.Size; } // It is the map we need iterate to find valid items, since we don't have "alive" storage anywhere
|
||||
T* TryGetMapData(ImPoolIdx n) { int idx = Map.Data[n].val_i; if (idx == -1) return NULL; return GetByIndex(idx); }
|
||||
#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
|
||||
int GetSize() { return GetBufSize(); } // For ImPlot: should use GetMapSize() from (IMGUI_VERSION_NUM >= 18303)
|
||||
int GetSize() { return GetMapSize(); } // For ImPlot: should use GetMapSize() from (IMGUI_VERSION_NUM >= 18304)
|
||||
#endif
|
||||
};
|
||||
|
||||
|
@ -3298,8 +3298,8 @@ void ImGui::TableLoadSettings(ImGuiTable* table)
|
||||
static void TableSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
||||
{
|
||||
ImGuiContext& g = *ctx;
|
||||
for (int i = 0; i != g.Tables.GetBufSize(); i++)
|
||||
if (ImGuiTable* table = g.Tables.TryGetBufData(i))
|
||||
for (int i = 0; i != g.Tables.GetMapSize(); i++)
|
||||
if (ImGuiTable* table = g.Tables.TryGetMapData(i))
|
||||
table->SettingsOffset = -1;
|
||||
g.SettingsTables.clear();
|
||||
}
|
||||
@ -3308,8 +3308,8 @@ static void TableSettingsHandler_ClearAll(ImGuiContext* ctx, ImGuiSettingsHandle
|
||||
static void TableSettingsHandler_ApplyAll(ImGuiContext* ctx, ImGuiSettingsHandler*)
|
||||
{
|
||||
ImGuiContext& g = *ctx;
|
||||
for (int i = 0; i != g.Tables.GetBufSize(); i++)
|
||||
if (ImGuiTable* table = g.Tables.TryGetBufData(i))
|
||||
for (int i = 0; i != g.Tables.GetMapSize(); i++)
|
||||
if (ImGuiTable* table = g.Tables.TryGetMapData(i))
|
||||
{
|
||||
table->IsSettingsRequestLoad = true;
|
||||
table->SettingsOffset = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user