mirror of
https://github.com/Drezil/imgui.git
synced 2024-12-24 16:46:36 +00:00
Merge branch 'master' into navigation
# Conflicts: # imgui.cpp # imgui_internal.h
This commit is contained in:
commit
d394c7ad0b
12
imgui.cpp
12
imgui.cpp
@ -2170,9 +2170,10 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id, const ImRect* nav_bb_ar
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
const bool is_clipped = IsClippedEx(bb, id, false);
|
||||
window->DC.LastItemId = id ? *id : 0;
|
||||
window->DC.LastItemRect = bb;
|
||||
const bool is_clipped = IsClippedEx(bb, id, false);
|
||||
window->DC.LastItemRectHoveredRect = false;
|
||||
if (id != NULL)
|
||||
window->DC.NavLayerActiveFlagsNext |= (1 << window->DC.NavLayerCurrent);
|
||||
|
||||
@ -2223,6 +2224,8 @@ bool ImGui::ItemAdd(const ImRect& bb, const ImGuiID* id, const ImRect* nav_bb_ar
|
||||
return false;
|
||||
//if (g.IO.KeyAlt) window->DrawList->AddRect(bb.Min, bb.Max, IM_COL32(255,255,0,120)); // [DEBUG]
|
||||
|
||||
// We need to calculate this now to take account of the current clipping rectangle (as items like Selectable may change them)
|
||||
window->DC.LastItemRectHoveredRect = IsMouseHoveringRect(bb.Min, bb.Max);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -2235,12 +2238,13 @@ bool ImGui::IsItemHovered()
|
||||
ImGuiWindow* window = g.CurrentWindow;
|
||||
if (g.NavDisableMouseHover)
|
||||
return IsItemFocused();
|
||||
|
||||
if (!window->DC.LastItemRectHoveredRect)
|
||||
return false;
|
||||
if (g.HoveredWindow != window)
|
||||
return false;
|
||||
if (g.ActiveId != 0 && g.ActiveId != window->DC.LastItemId && !g.ActiveIdAllowOverlap && g.ActiveId != window->MoveId)
|
||||
return false;
|
||||
if (!IsMouseHoveringRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max))
|
||||
return false;
|
||||
if (g.NavDisableMouseHover || !IsWindowContentHoverable(window))
|
||||
return false;
|
||||
return true;
|
||||
@ -2249,7 +2253,7 @@ bool ImGui::IsItemHovered()
|
||||
bool ImGui::IsItemRectHovered()
|
||||
{
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
return IsMouseHoveringRect(window->DC.LastItemRect.Min, window->DC.LastItemRect.Max);
|
||||
return window->DC.LastItemRectHoveredRect;
|
||||
}
|
||||
|
||||
// Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered().
|
||||
|
@ -1509,7 +1509,7 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
ImGui::Text("ID"); ImGui::NextColumn();
|
||||
ImGui::Text("Name"); ImGui::NextColumn();
|
||||
ImGui::Text("Path"); ImGui::NextColumn();
|
||||
ImGui::Text("Flags"); ImGui::NextColumn();
|
||||
ImGui::Text("Hovered"); ImGui::NextColumn();
|
||||
ImGui::Separator();
|
||||
const char* names[3] = { "One", "Two", "Three" };
|
||||
const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
|
||||
@ -1520,10 +1520,11 @@ void ImGui::ShowTestWindow(bool* p_open)
|
||||
sprintf(label, "%04d", i);
|
||||
if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
|
||||
selected = i;
|
||||
bool hovered = ImGui::IsItemHovered();
|
||||
ImGui::NextColumn();
|
||||
ImGui::Text(names[i]); ImGui::NextColumn();
|
||||
ImGui::Text(paths[i]); ImGui::NextColumn();
|
||||
ImGui::Text("...."); ImGui::NextColumn();
|
||||
ImGui::Text("%d", hovered); ImGui::NextColumn();
|
||||
}
|
||||
ImGui::Columns(1);
|
||||
ImGui::Separator();
|
||||
|
@ -658,6 +658,7 @@ struct IMGUI_API ImGuiDrawContext
|
||||
int TreeDepth;
|
||||
ImGuiID LastItemId;
|
||||
ImRect LastItemRect;
|
||||
bool LastItemRectHoveredRect;
|
||||
bool NavHasScroll; // Set when scrolling can be used (ScrollMax > 0.0f)
|
||||
int NavLayerCurrent; // Current layer, 0..31 (we currently only use 0..1)
|
||||
int NavLayerActiveFlags, NavLayerActiveFlagsNext; // Which layer have been written to.
|
||||
@ -700,7 +701,8 @@ struct IMGUI_API ImGuiDrawContext
|
||||
LogLinePosY = -1.0f;
|
||||
TreeDepth = 0;
|
||||
LastItemId = 0;
|
||||
LastItemRect = ImRect(0.0f,0.0f,0.0f,0.0f);
|
||||
LastItemRect = ImRect();
|
||||
LastItemRectHoveredRect = false;
|
||||
NavHasScroll = false;
|
||||
NavLayerActiveFlags = NavLayerActiveFlagsNext = 0x00;
|
||||
NavLayerCurrent = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user