mirror of
https://github.com/ocornut/imgui.git
synced 2024-12-13 04:39:02 +08:00
Docking: Amend 24dfebf
. Fixed incorrect focus highlight on docking node with nested hierarchies.
This commit is contained in:
parent
506717390f
commit
9764adc7bb
27
imgui.cpp
27
imgui.cpp
@ -6325,7 +6325,7 @@ void ImGui::UpdateWindowParentAndRootLinks(ImGuiWindow* window, ImGuiWindowFlags
|
||||
}
|
||||
if (parent_window && (flags & ImGuiWindowFlags_Popup))
|
||||
window->RootWindowPopupTree = parent_window->RootWindowPopupTree;
|
||||
if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup)))
|
||||
if (parent_window && !(flags & ImGuiWindowFlags_Modal) && (flags & (ImGuiWindowFlags_ChildWindow | ImGuiWindowFlags_Popup))) // FIXME: simply use _NoTitleBar ?
|
||||
window->RootWindowForTitleBarHighlight = parent_window->RootWindowForTitleBarHighlight;
|
||||
while (window->RootWindowForNav->Flags & ImGuiWindowFlags_NavFlattened)
|
||||
{
|
||||
@ -15293,6 +15293,21 @@ void ImGui::DockNodeEndAmendTabBar()
|
||||
End();
|
||||
}
|
||||
|
||||
static bool IsDockNodeTitleBarHighlighted(ImGuiDockNode* node, ImGuiDockNode* root_node, ImGuiWindow* host_window)
|
||||
{
|
||||
// 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 ((parent_node = ImGui::DockNodeGetRootNode(parent_node)) == root_node)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Submit the tab bar corresponding to a dock node and various housekeeping details.
|
||||
static void ImGui::DockNodeUpdateTabBar(ImGuiDockNode* node, ImGuiWindow* host_window)
|
||||
{
|
||||
@ -15308,14 +15323,8 @@ 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 (g.NavWindowingTarget)
|
||||
is_focused = (g.NavWindowingTarget->DockNode == node);
|
||||
else if (g.NavWindow && g.NavWindow->RootWindowForTitleBarHighlight == host_window->RootWindowDockTree && root_node->LastFocusedNodeId == node->ID)
|
||||
{
|
||||
// FIXME-DOCKING: May want alternative to treat central node void differently? e.g. if (g.NavWindow == host_window)
|
||||
if (g.NavWindow->DockNode && DockNodeIsInHierarchyOf(g.NavWindow->DockNode, root_node)) // Omit child windows injected in window hierarchy
|
||||
is_focused = true;
|
||||
}
|
||||
if (IsDockNodeTitleBarHighlighted(node, root_node, host_window))
|
||||
is_focused = true;
|
||||
|
||||
// Hidden tab bar will show a triangle on the upper-left (in Begin)
|
||||
if (node->IsHiddenTabBar() || node->IsNoTabBar())
|
||||
|
Loading…
Reference in New Issue
Block a user