From dc8ff68871ce0da856a533c9dd06826530df821f Mon Sep 17 00:00:00 2001 From: omar Date: Thu, 31 Jan 2019 15:22:40 +0100 Subject: [PATCH] Docking: VisibleWindow of a node spread its _NoMove attribute to the node (fixed dragging or undocking of dock node host from collapse button). (#2325, #2109) --- imgui.cpp | 13 +++++++++++-- imgui_widgets.cpp | 2 +- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index e82eefc9a..b4689e465 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -3172,7 +3172,14 @@ void ImGui::StartMouseMovingWindow(ImGuiWindow* window) SetActiveID(window->MoveId, window); g.NavDisableHighlight = true; g.ActiveIdClickOffset = g.IO.MousePos - window->RootWindow->Pos; - if (!(window->Flags & ImGuiWindowFlags_NoMove) && !(window->RootWindow->Flags & ImGuiWindowFlags_NoMove)) + + bool can_move_window = true; + if ((window->Flags & ImGuiWindowFlags_NoMove) || (window->RootWindow->Flags & ImGuiWindowFlags_NoMove)) + can_move_window = false; + if (ImGuiDockNode* node = window->DockNodeAsHost) + if (node->VisibleWindow && (node->VisibleWindow->Flags & ImGuiWindowFlags_NoMove)) + can_move_window = false; + if (can_move_window) g.MovingWindow = window; } @@ -11064,7 +11071,7 @@ static void ImGui::DockNodeStartMouseMovingWindow(ImGuiDockNode* node, ImGuiWind IM_ASSERT(node->WantMouseMove == true); ImVec2 backup_active_click_offset = g.ActiveIdClickOffset; StartMouseMovingWindow(window); - g.MovingWindow = window; // If we are docked into a non moveable root widnow, StartMouseMovingWindow() won't set g.MovingWindow. OVerride that decision. + g.MovingWindow = window; // If we are docked into a non moveable root window, StartMouseMovingWindow() won't set g.MovingWindow. Override that decision. node->WantMouseMove = false; g.ActiveIdClickOffset = backup_active_click_offset; } @@ -11533,6 +11540,8 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w if (IsMouseClicked(0)) { focus_tab_id = tab_bar->SelectedTabId; + + // Forward moving request to selected window if (ImGuiTabItem* tab = TabBarFindTabByID(tab_bar, focus_tab_id)) StartMouseMovingWindow(tab->Window); } diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 53bbbd0b0..395d4dade 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -712,7 +712,7 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos, ImGuiDockNode* dock_no if (IsItemActive() && IsMouseDragging(0)) { bool can_extract_dock_node = false; - if (dock_node != NULL) + if (dock_node != NULL && dock_node->VisibleWindow && !(dock_node->VisibleWindow->Flags & ImGuiWindowFlags_NoMove)) { ImGuiDockNode* root_node = DockNodeGetRootNode(dock_node); if (root_node->OnlyNodeWithWindows != dock_node || (root_node->CentralNode != NULL))