Skip to content

Commit 8f43487

Browse files
committed
Docking: Fixed incorrect focus highlight on docking node when focusing a menu. (ocornut#5702)
1 parent 6fd2ee9 commit 8f43487

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

docs/CHANGELOG.txt

+1
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ Other Changes:
224224

225225
Docking+Viewports Branch:
226226

227+
- Docking: Fixed incorrect focus highlight on docking node when focusing a menu. (#5702)
227228
- Docking, Nav: Fixed using gamepad/keyboard navigation not being able enter menu layer when
228229
it only contained the standard Collapse/Close buttons and no actual menu. (#5463, #4792)
229230
- Docking: Fixed regression introduced in v1.87 when docked window content not rendered

imgui.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -15514,18 +15514,24 @@ void ImGui::DockNodeEndAmendTabBar()
1551415514
End();
1551515515
}
1551615516

15517-
static bool IsDockNodeTitleBarHighlighted(ImGuiDockNode* node, ImGuiDockNode* root_node, ImGuiWindow* host_window)
15517+
static bool IsDockNodeTitleBarHighlighted(ImGuiDockNode* node, ImGuiDockNode* root_node)
1551815518
{
1551915519
// CTRL+Tab highlight (only highlighting leaf node, not whole hierarchy)
1552015520
ImGuiContext& g = *GImGui;
1552115521
if (g.NavWindowingTarget)
1552215522
return (g.NavWindowingTarget->DockNode == node);
1552315523

1552415524
// FIXME-DOCKING: May want alternative to treat central node void differently? e.g. if (g.NavWindow == host_window)
15525-
if (g.NavWindow && g.NavWindow->RootWindowForTitleBarHighlight == host_window->RootWindowDockTree && root_node->LastFocusedNodeId == node->ID)
15526-
for (ImGuiDockNode* parent_node = g.NavWindow->RootWindow->DockNode; parent_node != NULL; parent_node = parent_node->HostWindow ? parent_node->HostWindow->RootWindow->DockNode : NULL)
15525+
if (g.NavWindow && root_node->LastFocusedNodeId == node->ID)
15526+
{
15527+
// FIXME: This could all be backed in RootWindowForTitleBarHighlight? Probably need to reorganize for both dock nodes + other RootWindowForTitleBarHighlight users (not-node)
15528+
ImGuiWindow* parent_window = g.NavWindow->RootWindow;
15529+
while (parent_window->Flags & ImGuiWindowFlags_ChildMenu)
15530+
parent_window = parent_window->ParentWindow->RootWindow;
15531+
for (ImGuiDockNode* parent_node = parent_window->DockNode; parent_node != NULL; parent_node = parent_node->HostWindow ? parent_node->HostWindow->RootWindow->DockNode : NULL)
1552715532
if ((parent_node = ImGui::DockNodeGetRootNode(parent_node)) == root_node)
1552815533
return true;
15534+
}
1552915535
return false;
1553015536
}
1553115537

@@ -15544,7 +15550,7 @@ static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_w
1554415550
// Decide if we should use a focused title bar color
1554515551
bool is_focused = false;
1554615552
ImGuiDockNode* root_node = DockNodeGetRootNode(node);
15547-
if (IsDockNodeTitleBarHighlighted(node, root_node, host_window))
15553+
if (IsDockNodeTitleBarHighlighted(node, root_node))
1554815554
is_focused = true;
1554915555

1555015556
// Hidden tab bar will show a triangle on the upper-left (in Begin)

0 commit comments

Comments
 (0)