Skip to content

Commit 24dfebf

Browse files
committed
Docking: Fixed incorrect focus highlight on docking node when focusing empty central node or a child window which was manually injected into a dockspace window.
1 parent e900ca3 commit 24dfebf

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

docs/CHANGELOG.txt

+2
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,8 @@ Docking+Viewports Branch:
223223
when io.ConfigWindowsMoveFromTitleBarOnly is true and multi-viewports are disabled. (#5044)
224224
- Docking: Fixed a regression where moving window would be interrupted after undocking a tab
225225
when io.ConfigDockingAlwaysTabBar is true. (#5324) [@rokups]
226+
- Docking: Fixed incorrect focus highlight on docking node when focusing empty central node
227+
or a child window which was manually injected into a dockspace window.
226228
- Viewports: Fixed translating a host viewport from briefly altering the size of AlwaysAutoResize windows. (#5057)
227229
- Viewports: Fixed main viewport size not matching ImDrawData::DisplaySize for one frame during resize
228230
when multi-viewports are disabled. (#4900)

imgui.cpp

+10-5
Original file line numberDiff line numberDiff line change
@@ -15259,7 +15259,11 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
1525915259
if (g.NavWindowingTarget)
1526015260
is_focused = (g.NavWindowingTarget->DockNode == node);
1526115261
else if (g.NavWindow && g.NavWindow->RootWindowForTitleBarHighlight == host_window->RootWindowDockTree && root_node->LastFocusedNodeId == node->ID)
15262-
is_focused = true;
15262+
{
15263+
// FIXME-DOCKING: May want alternative to treat central node void differently? e.g. if (g.NavWindow == host_window)
15264+
if (g.NavWindow->DockNode && DockNodeIsInHierarchyOf(g.NavWindow->DockNode, root_node)) // Omit child windows injected in window hierarchy
15265+
is_focused = true;
15266+
}
1526315267

1526415268
// Hidden tab bar will show a triangle on the upper-left (in Begin)
1526515269
if (node->IsHiddenTabBar() || node->IsNoTabBar())
@@ -18263,10 +18267,11 @@ void ImGui::DebugNodeDockNode(ImGuiDockNode* node, const char* label)
1826318267
const bool is_active = (g.FrameCount - node->LastFrameActive < 2); // Submitted
1826418268
if (!is_alive) { PushStyleColor(ImGuiCol_Text, GetStyleColorVec4(ImGuiCol_TextDisabled)); }
1826518269
bool open;
18270+
ImGuiTreeNodeFlags tree_node_flags = node->IsFocused ? ImGuiTreeNodeFlags_Selected : ImGuiTreeNodeFlags_None;
1826618271
if (node->Windows.Size > 0)
18267-
open = TreeNode((void*)(intptr_t)node->ID, "%s 0x%04X%s: %d windows (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", node->Windows.Size, node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
18272+
open = TreeNodeEx((void*)(intptr_t)node->ID, tree_node_flags, "%s 0x%04X%s: %d windows (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", node->Windows.Size, node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
1826818273
else
18269-
open = TreeNode((void*)(intptr_t)node->ID, "%s 0x%04X%s: %s split (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", (node->SplitAxis == ImGuiAxis_X) ? "horizontal" : (node->SplitAxis == ImGuiAxis_Y) ? "vertical" : "n/a", node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
18274+
open = TreeNodeEx((void*)(intptr_t)node->ID, tree_node_flags, "%s 0x%04X%s: %s split (vis: '%s')", label, node->ID, node->IsVisible ? "" : " (hidden)", (node->SplitAxis == ImGuiAxis_X) ? "horizontal" : (node->SplitAxis == ImGuiAxis_Y) ? "vertical" : "n/a", node->VisibleWindow ? node->VisibleWindow->Name : "NULL");
1827018275
if (!is_alive) { PopStyleColor(); }
1827118276
if (is_active && IsItemHovered())
1827218277
if (ImGuiWindow* window = node->HostWindow ? node->HostWindow : node->VisibleWindow)
@@ -18280,10 +18285,10 @@ void ImGui::DebugNodeDockNode(ImGuiDockNode* node, const char* label)
1828018285
DebugNodeWindow(node->HostWindow, "HostWindow");
1828118286
DebugNodeWindow(node->VisibleWindow, "VisibleWindow");
1828218287
BulletText("SelectedTabID: 0x%08X, LastFocusedNodeID: 0x%08X", node->SelectedTabId, node->LastFocusedNodeId);
18283-
BulletText("Misc:%s%s%s%s%s%s",
18288+
BulletText("Misc:%s%s%s%s%s%s%s",
1828418289
node->IsDockSpace() ? " IsDockSpace" : "",
1828518290
node->IsCentralNode() ? " IsCentralNode" : "",
18286-
is_alive ? " IsAlive" : "", is_active ? " IsActive" : "",
18291+
is_alive ? " IsAlive" : "", is_active ? " IsActive" : "", node->IsFocused ? " IsFocused" : "",
1828718292
node->WantLockSizeOnce ? " WantLockSizeOnce" : "",
1828818293
node->HasCentralNodeChild ? " HasCentralNodeChild" : "");
1828918294
if (TreeNode("flags", "Flags Merged: 0x%04X, Local: 0x%04X, InWindows: 0x%04X, Shared: 0x%04X", node->MergedFlags, node->LocalFlags, node->LocalFlagsInWindows, node->SharedFlags))

0 commit comments

Comments
 (0)