From c5a79deb38774c76ff416e8f673bf080650f1b52 Mon Sep 17 00:00:00 2001 From: omar Date: Wed, 27 Sep 2017 23:10:46 +0200 Subject: [PATCH] IsItemHovered(), IsHovered(): Shallow tweaks to make them more symetrical. Removed one set of braces. --- imgui.cpp | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 747fcba51..1f1c4f64c 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1954,12 +1954,14 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id) bool ImGui::IsItemHovered() { ImGuiContext& g = *GImGui; + ImGuiWindow* window = g.CurrentWindow; - if (g.HoveredWindow == window) - if (g.ActiveId == 0 || g.ActiveId == window->DC.LastItemId || g.ActiveIdAllowOverlap || g.ActiveId == window->MoveId) - if (IsMouseHoveringRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max)) - if (IsWindowContentHoverable(window)) - return true; + if (g.HoveredWindow != window) + return false; + if (g.ActiveId == 0 || g.ActiveId == window->DC.LastItemId || g.ActiveIdAllowOverlap || g.ActiveId == window->MoveId) + if (IsMouseHoveringRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max)) + if (IsWindowContentHoverable(window)) + return true; return false; } @@ -1974,15 +1976,17 @@ bool ImGui::IsItemRectHovered() bool ImGui::IsHovered(const ImRect& bb, ImGuiID id) { ImGuiContext& g = *GImGui; - if (g.HoveredId == 0 || g.HoveredId == id || g.HoveredIdAllowOverlap) - { - ImGuiWindow* window = g.CurrentWindow; - if (g.HoveredWindow == window) - if (g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdAllowOverlap) - if (IsMouseHoveringRect(bb.Min, bb.Max)) - if (IsWindowContentHoverable(g.HoveredRootWindow)) - return true; - } + if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap) + return false; + + ImGuiWindow* window = g.CurrentWindow; + if (g.HoveredWindow != window) + return false; + if (g.ActiveId == 0 || g.ActiveId == id || g.ActiveIdAllowOverlap) + if (IsMouseHoveringRect(bb.Min, bb.Max)) + if (IsWindowContentHoverable(g.HoveredRootWindow)) + return true; + return false; }