Tables: Fix settings not being saved in child window (issue 3367) + fix for change in master.
diff --git a/imgui_internal.h b/imgui_internal.h
index 513b7f2..73c7ba5 100644
--- a/imgui_internal.h
+++ b/imgui_internal.h
@@ -2001,7 +2001,7 @@
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 5e785af..ad98797 100644
--- a/imgui_tables.cpp
+++ b/imgui_tables.cpp
@@ -193,7 +193,14 @@
}
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 @@
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 @@
// 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;