From bbaf67330a7e6ca7de2093a28f02544de9370339 Mon Sep 17 00:00:00 2001 From: ocornut Date: Fri, 15 Sep 2023 20:15:13 +0200 Subject: [PATCH] Docking: Internals: added ImGuiDockNodeFlags_NoUndocking. (#2999, #6823, #6780) --- imgui.cpp | 3 ++- imgui_internal.h | 5 +++-- imgui_widgets.cpp | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index f830659f97c71..520ebc0af0bda 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -4461,7 +4461,7 @@ void ImGui::StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* nod { ImGuiContext& g = *GImGui; bool can_undock_node = false; - if (node != NULL && node->VisibleWindow && (node->VisibleWindow->Flags & ImGuiWindowFlags_NoMove) == 0) + if (node != NULL && node->VisibleWindow && (node->VisibleWindow->Flags & ImGuiWindowFlags_NoMove) == 0 && (node->MergedFlags & ImGuiDockNodeFlags_NoUndocking) == 0) { // Can undock if: // - part of a floating node hierarchy with more than one visible node (if only one is visible, we'll just move the whole hierarchy) @@ -19893,6 +19893,7 @@ static void DebugNodeDockNodeFlags(ImGuiDockNodeFlags* p_flags, const char* labe CheckboxFlags("NoDockingOverMe", p_flags, ImGuiDockNodeFlags_NoDockingOverMe); CheckboxFlags("NoDockingOverOther", p_flags, ImGuiDockNodeFlags_NoDockingOverOther); CheckboxFlags("NoDockingOverEmpty", p_flags, ImGuiDockNodeFlags_NoDockingOverEmpty); + CheckboxFlags("NoUndocking", p_flags, ImGuiDockNodeFlags_NoUndocking); if (!enabled) EndDisabled(); PopStyleVar(); diff --git a/imgui_internal.h b/imgui_internal.h index 9b466eab4842a..5007b91329245 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -1679,8 +1679,9 @@ enum ImGuiDockNodeFlagsPrivate_ ImGuiDockNodeFlags_NoDockingOverMe = 1 << 19, // // [EXPERIMENTAL] Prevent another window/node to be docked over this node. ImGuiDockNodeFlags_NoDockingOverOther = 1 << 20, // // [EXPERIMENTAL] Prevent this node to be docked over another window or non-empty node. ImGuiDockNodeFlags_NoDockingOverEmpty = 1 << 21, // // [EXPERIMENTAL] Prevent this node to be docked over an empty node (e.g. DockSpace with no other windows) - ImGuiDockNodeFlags_NoResizeX = 1 << 22, // // [EXPERIMENTAL] - ImGuiDockNodeFlags_NoResizeY = 1 << 23, // // [EXPERIMENTAL] + ImGuiDockNodeFlags_NoUndocking = 1 << 22, // // Disable undocking from this node. + ImGuiDockNodeFlags_NoResizeX = 1 << 23, // // [EXPERIMENTAL] + ImGuiDockNodeFlags_NoResizeY = 1 << 24, // // [EXPERIMENTAL] ImGuiDockNodeFlags_SharedFlagsInheritMask_ = ~0, ImGuiDockNodeFlags_NoResizeFlagsMask_ = ImGuiDockNodeFlags_NoResize | ImGuiDockNodeFlags_NoResizeX | ImGuiDockNodeFlags_NoResizeY, // When splitting those flags are moved to the inheriting child, never duplicated diff --git a/imgui_widgets.cpp b/imgui_widgets.cpp index 97d60169634c0..05fec01808771 100644 --- a/imgui_widgets.cpp +++ b/imgui_widgets.cpp @@ -8639,7 +8639,8 @@ bool ImGui::TabItemEx(ImGuiTabBar* tab_bar, const char* label, bool* p_open, } // Extract a Dockable window out of it's tab bar - if (docked_window != NULL && !(docked_window->Flags & ImGuiWindowFlags_NoMove)) + const bool can_undock = docked_window != NULL && !(docked_window->Flags & ImGuiWindowFlags_NoMove) && !(node->MergedFlags & ImGuiDockNodeFlags_NoUndocking); + if (can_undock) { // We use a variable threshold to distinguish dragging tabs within a tab bar and extracting them out of the tab bar bool undocking_tab = (g.DragDropActive && g.DragDropPayload.SourceId == id);