diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index b8141f498966..02be164b1553 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -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) ----------------------------------------------------------------------- diff --git a/imgui.cpp b/imgui.cpp index 1a7a8ee62328..0d5325aae0a1 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -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) @@ -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); diff --git a/imgui_internal.h b/imgui_internal.h index c1870cb94567..6f184f84447c 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -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.