Skip to content

Commit

Permalink
Docking: Internals: added ImGuiDockNodeFlags_NoUndocking. (#2999, #6823
Browse files Browse the repository at this point in the history
…, #6780)
  • Loading branch information
ocornut committed Sep 15, 2023
1 parent 53d68cd commit bbaf673
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
3 changes: 2 additions & 1 deletion imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down
5 changes: 3 additions & 2 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bbaf673

Please sign in to comment.