mirror of https://github.com/ocornut/imgui
IsMouseHoveringRect() added 'bool clip' parameter to disable clipping the rectangle with the current parameters (#316)
This commit is contained in:
parent
09f659271e
commit
dbc7903da8
|
@ -2704,14 +2704,15 @@ static ImGuiWindow* FindHoveredWindow(ImVec2 pos, bool excluding_childs)
|
|||
// Test if mouse cursor is hovering given rectangle
|
||||
// NB- Rectangle is clipped by our current clip setting
|
||||
// NB- Expand the rectangle to be generous on imprecise inputs systems (g.Style.TouchExtraPadding)
|
||||
bool ImGui::IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max)
|
||||
bool ImGui::IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max, bool clip)
|
||||
{
|
||||
ImGuiState& g = *GImGui;
|
||||
ImGuiWindow* window = GetCurrentWindowRead();
|
||||
|
||||
// Clip
|
||||
ImRect rect_clipped(pos_min, pos_max);
|
||||
rect_clipped.Clip(window->ClipRect);
|
||||
if (clip)
|
||||
rect_clipped.Clip(window->ClipRect);
|
||||
|
||||
// Expand for touch input
|
||||
const ImRect rect_for_touch(rect_clipped.Min - g.Style.TouchExtraPadding, rect_clipped.Max + g.Style.TouchExtraPadding);
|
||||
|
|
2
imgui.h
2
imgui.h
|
@ -404,7 +404,7 @@ namespace ImGui
|
|||
IMGUI_API bool IsMouseReleased(int button); // did mouse button released (went from Down to !Down)
|
||||
IMGUI_API bool IsMouseHoveringWindow(); // is mouse hovering current window ("window" in API names always refer to current window). disregarding of any consideration of being blocked by a popup. (unlike IsWindowHovered() this will return true even if the window is blocked because of a popup)
|
||||
IMGUI_API bool IsMouseHoveringAnyWindow(); // is mouse hovering any visible window
|
||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup.
|
||||
IMGUI_API bool IsMouseHoveringRect(const ImVec2& pos_min, const ImVec2& pos_max, bool clip = true); // is mouse hovering given bounding rect (in screen space). clipped by current clipping settings. disregarding of consideration of focus/window ordering/blocked by a popup.
|
||||
IMGUI_API bool IsMouseDragging(int button = 0, float lock_threshold = -1.0f); // is mouse dragging. if lock_threshold < -1.0f uses io.MouseDraggingThreshold
|
||||
IMGUI_API ImVec2 GetMousePos(); // shortcut to ImGui::GetIO().MousePos provided by user, to be consistent with other calls
|
||||
IMGUI_API ImVec2 GetMousePosOnOpeningCurrentPopup(); // retrieve backup of mouse positioning at the time of opening popup we have BeginPopup() into
|
||||
|
|
Loading…
Reference in New Issue