mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
ScrollToItem: amend fully visible tests to take account of spacing used (fix nav in one axis scrolling back and forth between axises when space is tight by just < ItemSpacing*2) (#3692, #2812, #4242, #2900)
Amend 8f495e55
This commit is contained in:
parent
eb654f1bad
commit
d1eb7b5757
@ -6164,7 +6164,7 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
// Inner rectangle
|
// Inner rectangle
|
||||||
// Not affected by window border size. Used by:
|
// Not affected by window border size. Used by:
|
||||||
// - InnerClipRect
|
// - InnerClipRect
|
||||||
// - ScrollToBringRectIntoView()
|
// - ScrollToRectEx()
|
||||||
// - NavUpdatePageUpPageDown()
|
// - NavUpdatePageUpPageDown()
|
||||||
// - Scrollbar()
|
// - Scrollbar()
|
||||||
window->InnerRect.Min.x = window->Pos.x;
|
window->InnerRect.Min.x = window->Pos.x;
|
||||||
@ -8042,8 +8042,8 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui
|
|||||||
|
|
||||||
const bool fully_visible_x = item_rect.Min.x >= window_rect.Min.x && item_rect.Max.x <= window_rect.Max.x;
|
const bool fully_visible_x = item_rect.Min.x >= window_rect.Min.x && item_rect.Max.x <= window_rect.Max.x;
|
||||||
const bool fully_visible_y = item_rect.Min.y >= window_rect.Min.y && item_rect.Max.y <= window_rect.Max.y;
|
const bool fully_visible_y = item_rect.Min.y >= window_rect.Min.y && item_rect.Max.y <= window_rect.Max.y;
|
||||||
const bool can_be_fully_visible_x = item_rect.GetWidth() <= window_rect.GetWidth();
|
const bool can_be_fully_visible_x = (item_rect.GetWidth() + g.Style.ItemSpacing.x * 2.0f) <= window_rect.GetWidth();
|
||||||
const bool can_be_fully_visible_y = item_rect.GetHeight() <= window_rect.GetHeight();
|
const bool can_be_fully_visible_y = (item_rect.GetHeight() + g.Style.ItemSpacing.y * 2.0f) <= window_rect.GetHeight();
|
||||||
|
|
||||||
if ((flags & ImGuiScrollFlags_KeepVisibleEdgeX) && !fully_visible_x)
|
if ((flags & ImGuiScrollFlags_KeepVisibleEdgeX) && !fully_visible_x)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user