From 7cc86d4bc9f5b6a1590201a2381e2b72a7205529 Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 10 Jan 2019 18:20:52 +0100 Subject: [PATCH] Docking: Fixed docking a split node into the empty central node of a dockspace leading to the central node tag being incorrectly carried along. (#2109) --- imgui.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 01899b62..bece4001 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -10514,6 +10514,15 @@ void ImGui::DockContextProcessDock(ImGuiContext* ctx, ImGuiDockRequest* req) DockNodeMoveWindows(visible_node, target_node); DockSettingsMoveDockReferencesInInactiveWindow(target_node->ID, visible_node->ID); } + if (target_node->IsCentralNode) + { + // Central node property needs to be moved to a leaf node, pick the last focused one. + ImGuiDockNode* last_focused_node = DockContextFindNodeByID(ctx, payload_node->LastFocusedNodeID); + IM_ASSERT(last_focused_node != NULL && DockNodeGetRootNode(last_focused_node) == DockNodeGetRootNode(payload_node)); + last_focused_node->IsCentralNode = true; + target_node->IsCentralNode = false; + } + IM_ASSERT(target_node->Windows.Size == 0); DockNodeMoveChildNodes(target_node, payload_node); } @@ -10837,7 +10846,7 @@ static void DockNodeUpdateScanRec(ImGuiDockNode* node, ImGuiDockNodeUpdateScanRe if (node->IsCentralNode) { IM_ASSERT(results->CentralNode == NULL); // Should be only one - IM_ASSERT(node->IsLeafNode() && "If you get this assert: your .ini file may have been damaged by an old bug. OR please submit repro of actions leading to this"); + IM_ASSERT(node->IsLeafNode() && "If you get this assert: please submit .ini file + repro of actions leading to this."); results->CentralNode = node; } if (results->CountNodesWithWindows > 1 && results->CentralNode != NULL)