Skip to content

Commit

Permalink
Docking: Fixed incorrect focus highlight on docking node when focusin…
Browse files Browse the repository at this point in the history
…g a menu. (ocornut#5702)
  • Loading branch information
ocornut committed Sep 26, 2022
1 parent 6fd2ee9 commit 8f43487
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ Other Changes:

Docking+Viewports Branch:

- Docking: Fixed incorrect focus highlight on docking node when focusing a menu. (#5702)
- Docking, Nav: Fixed using gamepad/keyboard navigation not being able enter menu layer when
it only contained the standard Collapse/Close buttons and no actual menu. (#5463, #4792)
- Docking: Fixed regression introduced in v1.87 when docked window content not rendered
Expand Down
14 changes: 10 additions & 4 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15514,18 +15514,24 @@ void ImGui::DockNodeEndAmendTabBar()
End();
}

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

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

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

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

0 comments on commit 8f43487

Please sign in to comment.