|
@@ -6740,37 +6740,31 @@ bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
|
|
{
|
|
{
|
|
IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
|
|
IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
- if (g.HoveredWindow == NULL)
|
|
|
|
|
|
+ ImGuiWindow* ref_window = g.HoveredWindow;
|
|
|
|
+ ImGuiWindow* cur_window = g.CurrentWindow;
|
|
|
|
+ if (ref_window == NULL)
|
|
return false;
|
|
return false;
|
|
|
|
|
|
if ((flags & ImGuiHoveredFlags_AnyWindow) == 0)
|
|
if ((flags & ImGuiHoveredFlags_AnyWindow) == 0)
|
|
{
|
|
{
|
|
- ImGuiWindow* window = g.CurrentWindow;
|
|
|
|
- switch (flags & (ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows))
|
|
|
|
- {
|
|
|
|
- case ImGuiHoveredFlags_RootWindow | ImGuiHoveredFlags_ChildWindows:
|
|
|
|
- if (g.HoveredWindow->RootWindow != window->RootWindow)
|
|
|
|
- return false;
|
|
|
|
- break;
|
|
|
|
- case ImGuiHoveredFlags_RootWindow:
|
|
|
|
- if (g.HoveredWindow != window->RootWindow)
|
|
|
|
- return false;
|
|
|
|
- break;
|
|
|
|
- case ImGuiHoveredFlags_ChildWindows:
|
|
|
|
- if (!IsWindowChildOf(g.HoveredWindow, window))
|
|
|
|
- return false;
|
|
|
|
- break;
|
|
|
|
- default:
|
|
|
|
- if (g.HoveredWindow != window)
|
|
|
|
- return false;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
|
|
+ IM_ASSERT(cur_window); // Not inside a Begin()/End()
|
|
|
|
+
|
|
|
|
+ if (flags & ImGuiHoveredFlags_RootWindow)
|
|
|
|
+ cur_window = cur_window->RootWindow;
|
|
|
|
+
|
|
|
|
+ bool result;
|
|
|
|
+ if (flags & ImGuiHoveredFlags_ChildWindows)
|
|
|
|
+ result = IsWindowChildOf(ref_window, cur_window);
|
|
|
|
+ else
|
|
|
|
+ result = (ref_window == cur_window);
|
|
|
|
+ if (!result)
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
- if (!IsWindowContentHoverable(g.HoveredWindow, flags))
|
|
|
|
|
|
+ if (!IsWindowContentHoverable(ref_window, flags))
|
|
return false;
|
|
return false;
|
|
if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
|
|
if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
|
|
- if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != g.HoveredWindow->MoveId)
|
|
|
|
|
|
+ if (g.ActiveId != 0 && !g.ActiveIdAllowOverlap && g.ActiveId != ref_window->MoveId)
|
|
return false;
|
|
return false;
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -6778,22 +6772,22 @@ bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
|
|
bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
|
|
bool ImGui::IsWindowFocused(ImGuiFocusedFlags flags)
|
|
{
|
|
{
|
|
ImGuiContext& g = *GImGui;
|
|
ImGuiContext& g = *GImGui;
|
|
|
|
+ ImGuiWindow* ref_window = g.NavWindow;
|
|
|
|
+ ImGuiWindow* cur_window = g.CurrentWindow;
|
|
|
|
|
|
|
|
+ if (ref_window == NULL)
|
|
|
|
+ return false;
|
|
if (flags & ImGuiFocusedFlags_AnyWindow)
|
|
if (flags & ImGuiFocusedFlags_AnyWindow)
|
|
- return g.NavWindow != NULL;
|
|
|
|
|
|
+ return true;
|
|
|
|
+ IM_ASSERT(cur_window); // Not inside a Begin()/End()
|
|
|
|
|
|
- IM_ASSERT(g.CurrentWindow); // Not inside a Begin()/End()
|
|
|
|
- switch (flags & (ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows))
|
|
|
|
- {
|
|
|
|
- case ImGuiFocusedFlags_RootWindow | ImGuiFocusedFlags_ChildWindows:
|
|
|
|
- return g.NavWindow && g.NavWindow->RootWindow == g.CurrentWindow->RootWindow;
|
|
|
|
- case ImGuiFocusedFlags_RootWindow:
|
|
|
|
- return g.NavWindow == g.CurrentWindow->RootWindow;
|
|
|
|
- case ImGuiFocusedFlags_ChildWindows:
|
|
|
|
- return g.NavWindow && IsWindowChildOf(g.NavWindow, g.CurrentWindow);
|
|
|
|
- default:
|
|
|
|
- return g.NavWindow == g.CurrentWindow;
|
|
|
|
- }
|
|
|
|
|
|
+ if (flags & ImGuiHoveredFlags_RootWindow)
|
|
|
|
+ cur_window = cur_window->RootWindow;
|
|
|
|
+
|
|
|
|
+ if (flags & ImGuiHoveredFlags_ChildWindows)
|
|
|
|
+ return IsWindowChildOf(ref_window, cur_window);
|
|
|
|
+ else
|
|
|
|
+ return (ref_window == cur_window);
|
|
}
|
|
}
|
|
|
|
|
|
// Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext)
|
|
// Can we focus this window with CTRL+TAB (or PadMenu + PadFocusPrev/PadFocusNext)
|