Skip to content

Commit

Permalink
Docking: Added an assert to clarify that ImGuiDockNodeFlags_CentralNo…
Browse files Browse the repository at this point in the history
…de flag does not need to be passed to DockSpace(). (#8145)
  • Loading branch information
ocornut committed Nov 26, 2024
1 parent dad1047 commit 14d213c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
3 changes: 3 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ Other changes:

Docking+Viewports Branch:

- Docking: Added an assert to clarify that ImGuiDockNodeFlags_CentralNode flag
(from internals) does not need to be passed to DockSpace(), as it causes general
havoc. (#8145)
- Backends: Win32: Fixed a crash/regression in 1.91.5 when running two processes
with multi-viewports (was using GetProp() to query property which could have
belonged to another process). (#8162, #8069) [@sammyfreg, @ocornut]
Expand Down
6 changes: 4 additions & 2 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4957,7 +4957,7 @@ void ImGui::StartMouseMovingWindowOrNode(ImGuiWindow* window, ImGuiDockNode* nod
{
// Can undock if:
// - part of a hierarchy with more than one visible node (if only one is visible, we'll just move the root window)
// - part of a dockspace node hierarchy: so we can undock the last single visible node too (trivia: undocking from a fixed/central node will create a new node and copy windows)
// - part of a dockspace node hierarchy: so we can undock the last single visible node too. Undocking from a fixed/central node will create a new node and copy windows.
ImGuiDockNode* root_node = DockNodeGetRootNode(node);
if (root_node->OnlyNodeWithWindows != node || root_node->CentralNode != NULL) // -V1051 PVS-Studio thinks node should be root_node and is wrong about that.
can_undock_node = true;
Expand Down Expand Up @@ -19320,7 +19320,9 @@ ImGuiID ImGui::DockSpace(ImGuiID dockspace_id, const ImVec2& size_arg, ImGuiDock
if ((flags & ImGuiDockNodeFlags_KeepAliveOnly) == 0)
window = GetCurrentWindow(); // call to set window->WriteAccessed = true;

IM_ASSERT((flags & ImGuiDockNodeFlags_DockSpace) == 0);
IM_ASSERT((flags & ImGuiDockNodeFlags_DockSpace) == 0); // Flag is automatically set by DockSpace() as LocalFlags, not SharedFlags!
IM_ASSERT((flags & ImGuiDockNodeFlags_CentralNode) == 0); // Flag is automatically set by DockSpace() as LocalFlags, not SharedFlags! (#8145)

IM_ASSERT(dockspace_id != 0);
ImGuiDockNode* node = DockContextFindNodeByID(&g, dockspace_id);
if (node == NULL)
Expand Down
2 changes: 2 additions & 0 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1835,6 +1835,7 @@ enum ImGuiDockNodeFlagsPrivate_
ImGuiDockNodeFlags_NoResizeX = 1 << 16, // //
ImGuiDockNodeFlags_NoResizeY = 1 << 17, // //
ImGuiDockNodeFlags_DockedWindowsInFocusRoute= 1 << 18, // // Any docked window will be automatically be focus-route chained (window->ParentWindowForFocusRoute set to this) so Shortcut() in this window can run when any docked window is focused.

// Disable docking/undocking actions in this dockspace or individual node (existing docked nodes will be preserved)
// Those are not exposed in public because the desirable sharing/inheriting/copy-flag-on-split behaviors are quite difficult to design and understand.
// The two public flags ImGuiDockNodeFlags_NoDockingOverCentralNode/ImGuiDockNodeFlags_NoDockingSplit don't have those issues.
Expand All @@ -1843,6 +1844,7 @@ enum ImGuiDockNodeFlagsPrivate_
ImGuiDockNodeFlags_NoDockingOverOther = 1 << 21, // // Disable this node from being docked over another window or non-empty node.
ImGuiDockNodeFlags_NoDockingOverEmpty = 1 << 22, // // Disable this node from being docked over an empty node (e.g. DockSpace with no other windows)
ImGuiDockNodeFlags_NoDocking = ImGuiDockNodeFlags_NoDockingOverMe | ImGuiDockNodeFlags_NoDockingOverOther | ImGuiDockNodeFlags_NoDockingOverEmpty | ImGuiDockNodeFlags_NoDockingSplit | ImGuiDockNodeFlags_NoDockingSplitOther,

// Masks
ImGuiDockNodeFlags_SharedFlagsInheritMask_ = ~0,
ImGuiDockNodeFlags_NoResizeFlagsMask_ = (int)ImGuiDockNodeFlags_NoResize | ImGuiDockNodeFlags_NoResizeX | ImGuiDockNodeFlags_NoResizeY,
Expand Down

0 comments on commit 14d213c

Please sign in to comment.