From 136fc56af03ed7976e425e89e58de2c3d047b79d Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 13 Sep 2018 14:38:37 +0200 Subject: [PATCH] Docking: Better handling of window losing its dock node or having its dock node not active. --- imgui.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 18dd2ecf..c2da9f53 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -10132,7 +10132,7 @@ static void ImGui::DockNodeRemoveWindow(ImGuiDockNode* node, ImGuiWindow* window ImGuiDockContext* ctx = g.DockContext; IM_ASSERT(window->DockNode == node); //IM_ASSERT(window->RootWindow == node->HostWindow); - IM_ASSERT(window->LastFrameActive < g.FrameCount); + //IM_ASSERT(window->LastFrameActive < g.FrameCount); // We may call this from Begin() IM_ASSERT(save_dock_id == 0 || save_dock_id == node->ID); window->DockNode = NULL; @@ -11385,8 +11385,12 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) ImGuiDockNode* root_node = DockNodeGetRootNode(dock_node); if (root_node->LastFrameAlive < g.FrameCount) { - root_node->IsExplicitRoot = false; - window->DockIsActive = false; + DockContextProcessUndock(g.DockContext, window); + } + else + { + window->DockIsActive = true; + window->DockTabIsVisible = false; } return; } @@ -11414,12 +11418,12 @@ void ImGui::BeginDocked(ImGuiWindow* window, bool* p_open) g.NextWindowData.PosUndock = false; // Cancel implicit undocking of SetNextWindowPos() window->DockIsActive = true; + window->DockTabIsVisible = false; if (dock_node->Flags & ImGuiDockSpaceFlags_KeepAliveOnly) - { - window->DockTabIsVisible = false; return; - } - window->DockTabIsVisible = (dock_node->TabBar && dock_node->TabBar->VisibleTabId == window->ID); + + if (dock_node->TabBar && dock_node->TabBar->VisibleTabId == window->ID) + window->DockTabIsVisible = true; // When we are about to select this tab (which will only be visible on the _next frame_), flag it with a non-zero HiddenFramesForResize. // This will have the important effect of actually returning true in Begin() and not setting SkipItems, allowing an earlier submission of the window contents.