Browse Source

Internals: reorder tests in ItemHoverable() so most likely early out are taken first.

ocornut 2 years ago
parent
commit
b03a4993b3
2 changed files with 5 additions and 7 deletions
  1. 5 5
      imgui.cpp
  2. 0 2
      imgui_tables.cpp

+ 5 - 5
imgui.cpp

@@ -4031,17 +4031,17 @@ bool ImGui::IsItemHovered(ImGuiHoveredFlags flags)
 bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
 bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id)
 {
 {
     ImGuiContext& g = *GImGui;
     ImGuiContext& g = *GImGui;
-    if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap)
-        return false;
-
     ImGuiWindow* window = g.CurrentWindow;
     ImGuiWindow* window = g.CurrentWindow;
     if (g.HoveredWindow != window)
     if (g.HoveredWindow != window)
         return false;
         return false;
-    if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap)
-        return false;
     if (!IsMouseHoveringRect(bb.Min, bb.Max))
     if (!IsMouseHoveringRect(bb.Min, bb.Max))
         return false;
         return false;
 
 
+    if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap)
+        return false;
+    if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap)
+        return false;
+
     // Done with rectangle culling so we can perform heavier checks now.
     // Done with rectangle culling so we can perform heavier checks now.
     ImGuiItemFlags item_flags = (g.LastItemData.ID == id ? g.LastItemData.InFlags : g.CurrentItemFlags);
     ImGuiItemFlags item_flags = (g.LastItemData.ID == id ? g.LastItemData.InFlags : g.CurrentItemFlags);
     if (!(item_flags & ImGuiItemFlags_NoWindowHoverableCheck) && !IsWindowContentHoverable(window, ImGuiHoveredFlags_None))
     if (!(item_flags & ImGuiItemFlags_NoWindowHoverableCheck) && !IsWindowContentHoverable(window, ImGuiHoveredFlags_None))

+ 0 - 2
imgui_tables.cpp

@@ -1167,8 +1167,6 @@ void ImGui::TableUpdateLayout(ImGuiTable* table)
 
 
 // Process hit-testing on resizing borders. Actual size change will be applied in EndTable()
 // Process hit-testing on resizing borders. Actual size change will be applied in EndTable()
 // - Set table->HoveredColumnBorder with a short delay/timer to reduce visual feedback noise.
 // - Set table->HoveredColumnBorder with a short delay/timer to reduce visual feedback noise.
-// - Submit ahead of table contents and header, use ImGuiButtonFlags_AllowItemOverlap to prioritize
-//   widgets overlapping the same area.
 void ImGui::TableUpdateBorders(ImGuiTable* table)
 void ImGui::TableUpdateBorders(ImGuiTable* table)
 {
 {
     ImGuiContext& g = *GImGui;
     ImGuiContext& g = *GImGui;