From 7ca70dcb81c77c37b5e225d476c0fc82256735ae Mon Sep 17 00:00:00 2001 From: ocornut Date: Wed, 17 Jun 2020 15:27:17 +0200 Subject: [PATCH] Tables: Using same seed ID regardless of when using a child window or not. --- imgui_tables.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 0027b854..8e9cb702 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -216,6 +216,7 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG table->OuterRect = outer_rect; table->WorkRect = outer_rect; + // When not using a child window, WorkRect.Max will grow as we append contents. if (use_child_window) { // Ensure no vertical scrollbar appears if we only want horizontal one, to make flag consistent @@ -241,11 +242,9 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG table->WorkRect = table->InnerWindow->WorkRect; table->OuterRect = table->InnerWindow->Rect(); } - else - { - // WorkRect.Max will grow as we append contents. - PushID(instance_id); - } + + // Push a standardized ID for both child and not-child using tables, equivalent to BeginTable() doing PushID(label) matching + PushOverrideID(instance_id); // Backup a copy of host window members we will modify ImGuiWindow* inner_window = table->InnerWindow; @@ -1057,6 +1056,8 @@ void ImGui::EndTable() } // Layout in outer window + IM_ASSERT_USER_ERROR(inner_window->IDStack.back() == table->ID + table->InstanceCurrent, "Mismatching PushID/PopID!"); + PopID(); inner_window->WorkRect = table->HostWorkRect; inner_window->SkipItems = table->HostSkipItems; outer_window->DC.CursorPos = table->OuterRect.Min; @@ -1067,7 +1068,6 @@ void ImGui::EndTable() } else { - PopID(); ImVec2 item_size = table->OuterRect.GetSize(); item_size.x = table->ColumnsTotalWidth; ItemSize(item_size);