Skip to content

Commit

Permalink
Docking: added ImGuiDockNodeFlags_DockedWindowsInFocusRoute to config…
Browse files Browse the repository at this point in the history
…ure a dock node to automatically set ParentWindowForFocusRoute on its docked windows. (#6798, #2637, #456)
  • Loading branch information
ocornut committed Jan 16, 2024
1 parent cceff46 commit 80c83a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/CHANGELOG.txt
Expand Up @@ -58,6 +58,9 @@ Docking+Viewports Branch:
- Added ImGuiWindowClass::FocusRouteParentWindowId as a way to connect the focus route between
a tool window to a parent document window, so that Shortcuts in the documents are routed when the
tool is focused (regardless of whether the tool is docked or in a floating viewport, etc.) (#6798)
- Added ImGuiDockNodeFlags_DockedWindowsInFocusRoute to automatically make a dockspace connect
the focus route of its docked window. This is provided a convenience in case you have windows
where a connection is not explicit. (#6798)


-----------------------------------------------------------------------
Expand Down
4 changes: 4 additions & 0 deletions imgui.cpp
Expand Up @@ -6844,6 +6844,9 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
// There's little point to expose a flag to set this: because the interesting cases won't be using parent_window_in_stack,
// Use for e.g. linking a tool window in a standalone viewport to a document window, regardless of their Begin() stack parenting. (#6798)
window->ParentWindowForFocusRoute = (window->RootWindow != window) ? parent_window_in_stack : NULL;
if (window->ParentWindowForFocusRoute == NULL && window->DockNode != NULL)
if (window->DockNode->MergedFlags & ImGuiDockNodeFlags_DockedWindowsInFocusRoute)
window->ParentWindowForFocusRoute = window->DockNode->HostWindow;

// Override with SetNextWindowClass() field or direct call to SetWindowParentWindowForFocusRoute()
if (window->WindowClass.FocusRouteParentWindowId != 0)
Expand Down Expand Up @@ -20380,6 +20383,7 @@ static void DebugNodeDockNodeFlags(ImGuiDockNodeFlags* p_flags, const char* labe
CheckboxFlags("HiddenTabBar", p_flags, ImGuiDockNodeFlags_HiddenTabBar);
CheckboxFlags("NoWindowMenuButton", p_flags, ImGuiDockNodeFlags_NoWindowMenuButton);
CheckboxFlags("NoCloseButton", p_flags, ImGuiDockNodeFlags_NoCloseButton);
CheckboxFlags("DockedWindowsInFocusRoute", p_flags, ImGuiDockNodeFlags_DockedWindowsInFocusRoute);
CheckboxFlags("NoDocking", p_flags, ImGuiDockNodeFlags_NoDocking); // Multiple flags
CheckboxFlags("NoDockingSplit", p_flags, ImGuiDockNodeFlags_NoDockingSplit);
CheckboxFlags("NoDockingSplitOther", p_flags, ImGuiDockNodeFlags_NoDockingSplitOther);
Expand Down
1 change: 1 addition & 0 deletions imgui_internal.h
Expand Up @@ -1723,6 +1723,7 @@ enum ImGuiDockNodeFlagsPrivate_
ImGuiDockNodeFlags_NoCloseButton = 1 << 15, // Saved // Disable close button
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 Down

0 comments on commit 80c83a4

Please sign in to comment.