From eb18636e0287d90a3756115d90b99f4a7201e638 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 5 Aug 2020 19:26:54 +0200 Subject: [PATCH] Tables: Fix settings not being saved in child window (issue 3367) + fix for change in master. --- imgui_internal.h | 2 +- imgui_tables.cpp | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/imgui_internal.h b/imgui_internal.h index 513b7f241..73c7ba58f 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -2001,7 +2001,7 @@ struct ImGuiTable ImRect InnerClipRect; ImRect BackgroundClipRect; // We use this to cpu-clip cell background color fill ImRect HostClipRect; // This is used to check if we can eventually merge our columns draw calls into the current draw call of the current window. - ImRect HostWorkRect; // Backup of InnerWindow->WorkRect at the end of BeginTable() + ImRect HostBackupParentWorkRect; // Backup of InnerWindow->ParentWorkRect at the end of BeginTable() ImRect HostBackupClipRect; // Backup of InnerWindow->ClipRect during PushTableBackground()/PopTableBackground() ImVec2 HostCursorMaxPos; // Backup of InnerWindow->DC.CursorMaxPos at the end of BeginTable() ImGuiWindow* OuterWindow; // Parent window for the table diff --git a/imgui_tables.cpp b/imgui_tables.cpp index 5e785af34..ad98797a1 100644 --- a/imgui_tables.cpp +++ b/imgui_tables.cpp @@ -193,7 +193,14 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG } flags = TableFixFlags(flags); - if (outer_window->Flags & ImGuiWindowFlags_NoSavedSettings) + + // Inherit _NoSavedSettings from top-level window (child windows always have _NoSavedSettings set) +#ifdef IMGUI_HAS_DOCK + ImGuiWindow* window_for_settings = outer_window->RootWindowDockStop; +#else + ImGuiWindow* window_for_settings = outer_window->RootWindow; +#endif + if (window_for_settings->Flags & ImGuiWindowFlags_NoSavedSettings) flags |= ImGuiTableFlags_NoSavedSettings; // Acquire storage for the table @@ -253,8 +260,9 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG table->HostIndentX = inner_window->DC.Indent.x; table->HostClipRect = inner_window->ClipRect; table->HostSkipItems = inner_window->SkipItems; - table->HostWorkRect = inner_window->WorkRect; + table->HostBackupParentWorkRect = inner_window->ParentWorkRect; table->HostCursorMaxPos = inner_window->DC.CursorMaxPos; + inner_window->ParentWorkRect = inner_window->WorkRect; // Borders // - None ........Content..... Pad .....Content........ @@ -1067,7 +1075,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->WorkRect = inner_window->ParentWorkRect; + inner_window->ParentWorkRect = table->HostBackupParentWorkRect; inner_window->SkipItems = table->HostSkipItems; outer_window->DC.CursorPos = table->OuterRect.Min; outer_window->DC.ColumnsOffset.x = 0.0f;