Skip to content

Commit

Permalink
Add ability to test arbitrary rectangle for visibility without need o…
Browse files Browse the repository at this point in the history
…f moving cursor.
  • Loading branch information
thedmd committed Aug 5, 2016
1 parent 907265d commit 7588dfb
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9102,6 +9102,12 @@ bool ImGui::IsRectVisible(const ImVec2& size)
return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size));
}

bool ImGui::IsRectVisible(const ImVec2& a, const ImVec2& b)
{
ImGuiWindow* window = GetCurrentWindowRead();
return window->ClipRect.Overlaps(ImRect(a, b));
}

// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
void ImGui::BeginGroup()
{
Expand Down
1 change: 1 addition & 0 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,7 @@ namespace ImGui
IMGUI_API bool IsRootWindowOrAnyChildFocused(); // is current root window or any of its child (including current window) focused
IMGUI_API bool IsRootWindowOrAnyChildHovered(); // is current root window or any of its child (including current window) hovered and hoverable (not blocked by a popup)
IMGUI_API bool IsRectVisible(const ImVec2& size); // test if rectangle of given size starting from cursor pos is visible (not clipped). to perform coarse clipping on user's side (as an optimization)
IMGUI_API bool IsRectVisible(const ImVec2& a, const ImVec2& b); // "
IMGUI_API bool IsPosHoveringAnyWindow(const ImVec2& pos); // is given position hovering any active imgui window
IMGUI_API float GetTime();
IMGUI_API int GetFrameCount();
Expand Down

0 comments on commit 7588dfb

Please sign in to comment.