Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered().
| 3698 | |
| 3699 | // Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered(). |
| 3700 | bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) |
| 3701 | { |
| 3702 | ImGuiContext& g = *GImGui; |
| 3703 | if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap) |
| 3704 | return false; |
| 3705 | |
| 3706 | ImGuiWindow* window = g.CurrentWindow; |
| 3707 | if (g.HoveredWindow != window) |
| 3708 | return false; |
| 3709 | if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap) |
| 3710 | return false; |
| 3711 | if (!IsMouseHoveringRect(bb.Min, bb.Max)) |
| 3712 | return false; |
| 3713 | |
| 3714 | // Done with rectangle culling so we can perform heavier checks now. |
| 3715 | ImGuiItemFlags item_flags = (g.LastItemData.ID == id ? g.LastItemData.InFlags : g.CurrentItemFlags); |
| 3716 | if (!(item_flags & ImGuiItemFlags_NoWindowHoverableCheck) && !IsWindowContentHoverable(window, ImGuiHoveredFlags_None)) |
| 3717 | { |
| 3718 | g.HoveredIdDisabled = true; |
| 3719 | return false; |
| 3720 | } |
| 3721 | |
| 3722 | // We exceptionally allow this function to be called with id==0 to allow using it for easy high-level |
| 3723 | // hover test in widgets code. We could also decide to split this function is two. |
| 3724 | if (id != 0) |
| 3725 | SetHoveredID(id); |
| 3726 | |
| 3727 | // When disabled we'll return false but still set HoveredId |
| 3728 | if (item_flags & ImGuiItemFlags_Disabled) |
| 3729 | { |
| 3730 | // Release active id if turning disabled |
| 3731 | if (g.ActiveId == id) |
| 3732 | ClearActiveID(); |
| 3733 | g.HoveredIdDisabled = true; |
| 3734 | return false; |
| 3735 | } |
| 3736 | |
| 3737 | if (id != 0) |
| 3738 | { |
| 3739 | // [DEBUG] Item Picker tool! |
| 3740 | // We perform the check here because SetHoveredID() is not frequently called (1~ time a frame), making |
| 3741 | // the cost of this tool near-zero. We can get slightly better call-stack and support picking non-hovered |
| 3742 | // items if we performed the test in ItemAdd(), but that would incur a small runtime cost. |
| 3743 | if (g.DebugItemPickerActive && g.HoveredIdPreviousFrame == id) |
| 3744 | GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255)); |
| 3745 | //if (g.DebugItemPickerBreakId == id) |
| 3746 | // IM_DEBUG_BREAK(); |
| 3747 | } |
| 3748 | |
| 3749 | if (g.NavDisableMouseHover) |
| 3750 | return false; |
| 3751 | |
| 3752 | return true; |
| 3753 | } |
| 3754 | |
| 3755 | // FIXME: This is inlined/duplicated in ItemAdd() |
| 3756 | bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id) |
nothing calls this directly
no test coverage detected