1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-15 11:33:29 +01:00

Docking+Viewports: Fixed extraneous viewport+platform-window recreation. Part 4.

Part 4: store reference viewport id from last visible single window stored in node. So Win1 -> Win1|Win2 can reuse viewport on split.
Refer to "viewport_owner_change_1" and "viewport_owner_change_2" in ImGuiTestSuite.
This commit is contained in:
ocornut 2023-06-23 16:03:01 +02:00
parent 35b41949fb
commit 057fcae30c
2 changed files with 6 additions and 0 deletions

View File

@ -15786,6 +15786,7 @@ ImGuiDockNode::ImGuiDockNode(ImGuiID id)
LastFocusedNodeId = 0;
SelectedTabId = 0;
WantCloseTabId = 0;
RefViewportId = 0;
AuthorityForPos = AuthorityForSize = ImGuiDataAuthority_DockNode;
AuthorityForViewport = ImGuiDataAuthority_Auto;
IsVisible = true;
@ -16277,6 +16278,7 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
single_window->ViewportOwned = true;
}
}
node->RefViewportId = single_window->ViewportId;
}
DockNodeHideHostWindow(node);
@ -16366,6 +16368,8 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
// Sync Viewport
if (node->AuthorityForViewport == ImGuiDataAuthority_Window && ref_window)
SetNextWindowViewport(ref_window->ViewportId);
else if (node->AuthorityForViewport == ImGuiDataAuthority_Window && node->RefViewportId != 0)
SetNextWindowViewport(node->RefViewportId);
SetNextWindowClass(&node->WindowClass);
@ -16408,6 +16412,7 @@ static void ImGui::DockNodeUpdate(ImGuiDockNode* node)
if (node->WantMouseMove && node->HostWindow)
DockNodeStartMouseMovingWindow(node, node->HostWindow);
}
node->RefViewportId = 0; // Clear when we have a host window
// Update focused node (the one whose title bar is highlight) within a node tree
if (node->IsSplitNode())

View File

@ -1685,6 +1685,7 @@ struct IMGUI_API ImGuiDockNode
ImGuiID LastFocusedNodeId; // [Root node only] Which of our child docking node (any ancestor in the hierarchy) was last focused.
ImGuiID SelectedTabId; // [Leaf node only] Which of our tab/window is selected.
ImGuiID WantCloseTabId; // [Leaf node only] Set when closing a specific tab/window.
ImGuiID RefViewportId; // Reference viewport ID from visible window when HostWindow == NULL.
ImGuiDataAuthority AuthorityForPos :3;
ImGuiDataAuthority AuthorityForSize :3;
ImGuiDataAuthority AuthorityForViewport :3;