Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered().
| 3786 | |
| 3787 | // Internal facing ItemHoverable() used when submitting widgets. Differs slightly from IsItemHovered(). |
| 3788 | bool ImGui::ItemHoverable(const ImRect& bb, ImGuiID id) |
| 3789 | { |
| 3790 | ImGuiContext& g = *GImGui; |
| 3791 | if (g.HoveredId != 0 && g.HoveredId != id && !g.HoveredIdAllowOverlap) |
| 3792 | return false; |
| 3793 | |
| 3794 | ImGuiWindow* window = g.CurrentWindow; |
| 3795 | if (g.HoveredWindow != window) |
| 3796 | return false; |
| 3797 | if (g.ActiveId != 0 && g.ActiveId != id && !g.ActiveIdAllowOverlap) |
| 3798 | return false; |
| 3799 | if (!IsMouseHoveringRect(bb.Min, bb.Max)) |
| 3800 | return false; |
| 3801 | |
| 3802 | // Done with rectangle culling so we can perform heavier checks now. |
| 3803 | ImGuiItemFlags item_flags = (g.LastItemData.ID == id ? g.LastItemData.InFlags : g.CurrentItemFlags); |
| 3804 | if (!(item_flags & ImGuiItemFlags_NoWindowHoverableCheck) && !IsWindowContentHoverable(window, ImGuiHoveredFlags_None)) |
| 3805 | { |
| 3806 | g.HoveredIdDisabled = true; |
| 3807 | return false; |
| 3808 | } |
| 3809 | |
| 3810 | // We exceptionally allow this function to be called with id==0 to allow using it for easy high-level |
| 3811 | // hover test in widgets code. We could also decide to split this function is two. |
| 3812 | if (id != 0) |
| 3813 | SetHoveredID(id); |
| 3814 | |
| 3815 | // When disabled we'll return false but still set HoveredId |
| 3816 | if (item_flags & ImGuiItemFlags_Disabled) |
| 3817 | { |
| 3818 | // Release active id if turning disabled |
| 3819 | if (g.ActiveId == id) |
| 3820 | ClearActiveID(); |
| 3821 | g.HoveredIdDisabled = true; |
| 3822 | return false; |
| 3823 | } |
| 3824 | |
| 3825 | if (id != 0) |
| 3826 | { |
| 3827 | // [DEBUG] Item Picker tool! |
| 3828 | // We perform the check here because SetHoveredID() is not frequently called (1~ time a frame), making |
| 3829 | // the cost of this tool near-zero. We can get slightly better call-stack and support picking non-hovered |
| 3830 | // items if we performed the test in ItemAdd(), but that would incur a small runtime cost. |
| 3831 | if (g.DebugItemPickerActive && g.HoveredIdPreviousFrame == id) |
| 3832 | GetForegroundDrawList()->AddRect(bb.Min, bb.Max, IM_COL32(255, 255, 0, 255)); |
| 3833 | if (g.DebugItemPickerBreakId == id) |
| 3834 | IM_DEBUG_BREAK(); |
| 3835 | } |
| 3836 | |
| 3837 | if (g.NavDisableMouseHover) |
| 3838 | return false; |
| 3839 | |
| 3840 | return true; |
| 3841 | } |
| 3842 | |
| 3843 | // FIXME: This is inlined/duplicated in ItemAdd() |
| 3844 | bool ImGui::IsClippedEx(const ImRect& bb, ImGuiID id) |
nothing calls this directly
no test coverage detected