mirror of
https://github.com/ocornut/imgui.git
synced 2026-01-12 00:14:20 +00:00
IsWindowHovered(): Changed default behavior to now return false is a widget from another window is active + Added support for ImGuiHoveredFlags_AllowWhenBlockedByActiveItem. (relate to drag'n drop idoms: #143)
This commit is contained in:
parent
564ff2dfd3
commit
695ea45fca
2 changed files with 22 additions and 8 deletions
22
imgui.cpp
22
imgui.cpp
|
|
@ -5091,9 +5091,16 @@ const char* ImGui::GetStyleColorName(ImGuiCol idx)
|
|||
|
||||
bool ImGui::IsWindowHovered(ImGuiHoveredFlags flags)
|
||||
{
|
||||
IM_ASSERT((flags & (ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) == 0); // Flags not supported by this function
|
||||
IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
|
||||
ImGuiContext& g = *GImGui;
|
||||
return g.HoveredWindow == g.CurrentWindow && IsWindowContentHoverable(g.HoveredRootWindow, flags);
|
||||
if (g.HoveredWindow != g.CurrentWindow)
|
||||
return false;
|
||||
if (!IsWindowContentHoverable(g.HoveredRootWindow, flags))
|
||||
return false;
|
||||
if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
|
||||
if (g.ActiveId != 0 && g.ActiveIdWindow != g.CurrentWindow)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ImGui::IsWindowFocused()
|
||||
|
|
@ -5116,9 +5123,16 @@ bool ImGui::IsRootWindowOrAnyChildFocused()
|
|||
|
||||
bool ImGui::IsRootWindowOrAnyChildHovered(ImGuiHoveredFlags flags)
|
||||
{
|
||||
IM_ASSERT((flags & (ImGuiHoveredFlags_AllowWhenOverlapped | ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) == 0); // Flags not supported by this function
|
||||
IM_ASSERT((flags & ImGuiHoveredFlags_AllowWhenOverlapped) == 0); // Flags not supported by this function
|
||||
ImGuiContext& g = *GImGui;
|
||||
return g.HoveredRootWindow && (g.HoveredRootWindow == g.CurrentWindow->RootWindow) && IsWindowContentHoverable(g.HoveredRootWindow, flags);
|
||||
if (!g.HoveredRootWindow || (g.HoveredRootWindow != g.CurrentWindow->RootWindow))
|
||||
return false;
|
||||
if (!IsWindowContentHoverable(g.HoveredRootWindow, flags))
|
||||
return false;
|
||||
if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
|
||||
if (g.ActiveId != 0 && g.ActiveIdWindow != g.CurrentWindow)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
float ImGui::GetWindowWidth()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue