Tables: Fix settings not being saved in child window (issue 3367) + fix for change in master.

This commit is contained in:
omar 2020-08-05 19:26:54 +02:00 committed by ocornut
parent 9d8b40414a
commit eb18636e02
2 changed files with 13 additions and 4 deletions

View File

@ -2001,7 +2001,7 @@ struct ImGuiTable
ImRect InnerClipRect; ImRect InnerClipRect;
ImRect BackgroundClipRect; // We use this to cpu-clip cell background color fill 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 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() ImRect HostBackupClipRect; // Backup of InnerWindow->ClipRect during PushTableBackground()/PopTableBackground()
ImVec2 HostCursorMaxPos; // Backup of InnerWindow->DC.CursorMaxPos at the end of BeginTable() ImVec2 HostCursorMaxPos; // Backup of InnerWindow->DC.CursorMaxPos at the end of BeginTable()
ImGuiWindow* OuterWindow; // Parent window for the table ImGuiWindow* OuterWindow; // Parent window for the table

View File

@ -193,7 +193,14 @@ bool ImGui::BeginTableEx(const char* name, ImGuiID id, int columns_count, ImG
} }
flags = TableFixFlags(flags); 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; flags |= ImGuiTableFlags_NoSavedSettings;
// Acquire storage for the table // 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->HostIndentX = inner_window->DC.Indent.x;
table->HostClipRect = inner_window->ClipRect; table->HostClipRect = inner_window->ClipRect;
table->HostSkipItems = inner_window->SkipItems; table->HostSkipItems = inner_window->SkipItems;
table->HostWorkRect = inner_window->WorkRect; table->HostBackupParentWorkRect = inner_window->ParentWorkRect;
table->HostCursorMaxPos = inner_window->DC.CursorMaxPos; table->HostCursorMaxPos = inner_window->DC.CursorMaxPos;
inner_window->ParentWorkRect = inner_window->WorkRect;
// Borders // Borders
// - None ........Content..... Pad .....Content........ // - None ........Content..... Pad .....Content........
@ -1067,7 +1075,8 @@ void ImGui::EndTable()
// Layout in outer window // Layout in outer window
IM_ASSERT_USER_ERROR(inner_window->IDStack.back() == table->ID + table->InstanceCurrent, "Mismatching PushID/PopID!"); IM_ASSERT_USER_ERROR(inner_window->IDStack.back() == table->ID + table->InstanceCurrent, "Mismatching PushID/PopID!");
PopID(); PopID();
inner_window->WorkRect = table->HostWorkRect; inner_window->WorkRect = inner_window->ParentWorkRect;
inner_window->ParentWorkRect = table->HostBackupParentWorkRect;
inner_window->SkipItems = table->HostSkipItems; inner_window->SkipItems = table->HostSkipItems;
outer_window->DC.CursorPos = table->OuterRect.Min; outer_window->DC.CursorPos = table->OuterRect.Min;
outer_window->DC.ColumnsOffset.x = 0.0f; outer_window->DC.ColumnsOffset.x = 0.0f;