From f1ddf63027acc7fbcc588ddb98de048b311f20eb Mon Sep 17 00:00:00 2001 From: Neil Bickford Date: Mon, 19 Dec 2022 09:11:33 -0800 Subject: [PATCH] ScrollToRectEx: Fix bug where scrolling horizontally to an always-centered element that is not visible but could be would take the item's Y coordinate into account. Neither behavior were used in the codebase for this axis. Amend 27c58c39 (#5902, #2812, #4242, #2900) Signed-off-by: Neil Bickford --- imgui.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/imgui.cpp b/imgui.cpp index 52714c9ba..501f5c914 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -9666,7 +9666,7 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui else if (((flags & ImGuiScrollFlags_KeepVisibleCenterX) && !fully_visible_x) || (flags & ImGuiScrollFlags_AlwaysCenterX)) { if (can_be_fully_visible_x) - SetScrollFromPosX(window, ImFloor((item_rect.Min.x + item_rect.Max.y) * 0.5f) - window->Pos.x, 0.5f); + SetScrollFromPosX(window, ImFloor((item_rect.Min.x + item_rect.Max.x) * 0.5f) - window->Pos.x, 0.5f); else SetScrollFromPosX(window, item_rect.Min.x - window->Pos.x, 0.0f); }