Skip to content

Commit

Permalink
Docking: Simplify logic of moving tabs between nodes. Amends 0abe7d. (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
rokups authored and ocornut committed Aug 5, 2022
1 parent e9f50fb commit ff1567e
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down

0 comments on commit ff1567e

Please sign in to comment.