1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-12-12 16:01:11 +01:00

Merge branch 'master' into navigation + removed extraneous g.NavDisableMouseHover test in IsItemHovered()

# Conflicts:
#	imgui.cpp
This commit is contained in:
omar 2017-12-08 09:35:23 +01:00
commit b6b940c8ee

View File

@ -2344,29 +2344,37 @@ bool ImGui::ItemAdd(const ImRect& bb, ImGuiID id, const ImRect* nav_bb_arg)
bool ImGui::IsItemHovered(ImGuiHoveredFlags flags) bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
ImGuiWindow* window = g.CurrentWindow; ImGuiWindow* window = g.CurrentWindow;
if (g.NavDisableMouseHover) if (g.NavDisableMouseHover)
return IsItemFocused(); return IsItemFocused();
// Test for bounding box overlap, as updated as ItemAdd()
if (!window->DC.LastItemRectHoveredRect) if (!window->DC.LastItemRectHoveredRect)
return false; return false;
IM_ASSERT((flags & ImGuiHoveredFlags_FlattenChilds) == 0); // Flags not supported by this function IM_ASSERT((flags & ImGuiHoveredFlags_FlattenChilds) == 0); // Flags not supported by this function
// Test if we are hovering the right window (our window could be behind another window)
// [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable to use IsItemHovered() after EndChild() itself. // [2017/10/16] Reverted commit 344d48be3 and testing RootWindow instead. I believe it is correct to NOT test for RootWindow but this leaves us unable to use IsItemHovered() after EndChild() itself.
// Until a solution is found I believe reverting to the test from 2017/09/27 is safe since this was the test that has been running for a long while. // Until a solution is found I believe reverting to the test from 2017/09/27 is safe since this was the test that has been running for a long while.
//if (g.HoveredWindow != window) //if (g.HoveredWindow != window)
// return false; // return false;
if (g.HoveredRootWindow != window->RootWindow && !(flags & ImGuiHoveredFlags_AllowWhenOverlapped)) if (g.HoveredRootWindow != window->RootWindow && !(flags & ImGuiHoveredFlags_AllowWhenOverlapped))
return false; return false;
// Test if another item is active (e.g. being dragged)
if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem)) if (!(flags & ImGuiHoveredFlags_AllowWhenBlockedByActiveItem))
if (g.ActiveId != 0 && g.ActiveId != window->DC.LastItemId && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId) if (g.ActiveId != 0 && g.ActiveId != window->DC.LastItemId && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId)
return false; return false;
if (g.NavDisableMouseHover || !IsWindowContentHoverable(window, flags))
// Test if interactions on this window are blocked by an active popup or modal
if (!IsWindowContentHoverable(window, flags))
return false; return false;
// Test if the item is disabled
if (window->DC.ItemFlags & ImGuiItemFlags_Disabled) if (window->DC.ItemFlags & ImGuiItemFlags_Disabled)
return false; return false;
// Special handling for the 1st item after Begin() which represent the title bar. When the window is collapsed (SkipItems==true) that last item will never be overwritten.
// Special handling for the 1st item after Begin() which represent the title bar. When the window is collapsed (SkipItems==true) that last item will never be overwritten so we need to detect tht case.
if (window->DC.LastItemId == window->MoveId && window->WriteAccessed) if (window->DC.LastItemId == window->MoveId && window->WriteAccessed)
return false; return false;
return true; return true;