From ff1567e2406797cbd1a3ef3d716888d6c3a66bd7 Mon Sep 17 00:00:00 2001 From: Rokas Kupstys Date: Fri, 5 Aug 2022 12:49:31 +0300 Subject: [PATCH] Docking: Simplify logic of moving tabs between nodes. Amends 0abe7d. (#5515) The idea is that in the absence of a tab bar, as new one gets created new tabs will be sorted based on window->DockOrder so this may work but we're not 100% sure. --- imgui.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 140104fe0..7fdd173f6 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -14749,19 +14749,12 @@ static void ImGui::DockNodeMoveWindows(ImGuiDockNode* dst_node, ImGuiDockNode* s src_node->TabBar = NULL; } - for (int n_from_node = 0, n_from_tab_bar = 0; n_from_node < src_node->Windows.Size; n_from_node++, n_from_tab_bar++) + // Tab order is not important here, it is preserved by sorting in DockNodeUpdateTabBar(). + for (ImGuiWindow* window : src_node->Windows) { - // DockNode's TabBar may have non-window Tabs manually appended by user - while (src_tab_bar && src_tab_bar->Tabs[n_from_tab_bar].Window == NULL) - n_from_tab_bar++; - - // Using TabBar order (FIXME: Why? Clarify + add tests for it) - if (ImGuiWindow* window = src_tab_bar ? src_tab_bar->Tabs[n_from_tab_bar].Window : src_node->Windows[n_from_node]) - { - window->DockNode = NULL; - window->DockIsActive = false; - DockNodeAddWindow(dst_node, window, move_tab_bar ? false : true); - } + window->DockNode = NULL; + window->DockIsActive = false; + DockNodeAddWindow(dst_node, window, !move_tab_bar); } src_node->Windows.clear();