mirror of
https://github.com/Drezil/imgui.git
synced 2025-07-07 13:35:49 +02:00
Scrolling, Focus, Combo: fixed SetKeyboardFocusHere()/SetItemDefaultFocus()/ScrollToRectEx() during an appearing form not centering item. (#5902, #2812, #4242, #2900)
Amend44f801186
and8f495e554
This commit is contained in:
16
imgui.cpp
16
imgui.cpp
@ -9519,8 +9519,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_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() + g.Style.ItemSpacing.x * 2.0f) <= window_rect.GetWidth();
|
||||
const bool can_be_fully_visible_y = (item_rect.GetHeight() + g.Style.ItemSpacing.y * 2.0f) <= window_rect.GetHeight();
|
||||
const bool can_be_fully_visible_x = (item_rect.GetWidth() + g.Style.ItemSpacing.x * 2.0f) <= window_rect.GetWidth() || (window->AutoFitFramesX > 0) || (window->Flags & ImGuiWindowFlags_AlwaysAutoResize) != 0;
|
||||
const bool can_be_fully_visible_y = (item_rect.GetHeight() + g.Style.ItemSpacing.y * 2.0f) <= window_rect.GetHeight() || (window->AutoFitFramesY > 0) || (window->Flags & ImGuiWindowFlags_AlwaysAutoResize) != 0;
|
||||
|
||||
if ((flags & ImGuiScrollFlags_KeepVisibleEdgeX) && !fully_visible_x)
|
||||
{
|
||||
@ -9531,8 +9531,10 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui
|
||||
}
|
||||
else if (((flags & ImGuiScrollFlags_KeepVisibleCenterX) && !fully_visible_x) || (flags & ImGuiScrollFlags_AlwaysCenterX))
|
||||
{
|
||||
float target_x = can_be_fully_visible_x ? ImFloor((item_rect.Min.x + item_rect.Max.x - window->InnerRect.GetWidth()) * 0.5f) : item_rect.Min.x;
|
||||
SetScrollFromPosX(window, target_x - window->Pos.x, 0.0f);
|
||||
if (can_be_fully_visible_x)
|
||||
SetScrollFromPosX(window, ImFloor((item_rect.Min.x + item_rect.Max.y) * 0.5f) - window->Pos.x, 0.5f);
|
||||
else
|
||||
SetScrollFromPosX(window, item_rect.Min.x - window->Pos.x, 0.0f);
|
||||
}
|
||||
|
||||
if ((flags & ImGuiScrollFlags_KeepVisibleEdgeY) && !fully_visible_y)
|
||||
@ -9544,8 +9546,10 @@ ImVec2 ImGui::ScrollToRectEx(ImGuiWindow* window, const ImRect& item_rect, ImGui
|
||||
}
|
||||
else if (((flags & ImGuiScrollFlags_KeepVisibleCenterY) && !fully_visible_y) || (flags & ImGuiScrollFlags_AlwaysCenterY))
|
||||
{
|
||||
float target_y = can_be_fully_visible_y ? ImFloor((item_rect.Min.y + item_rect.Max.y - window->InnerRect.GetHeight()) * 0.5f) : item_rect.Min.y;
|
||||
SetScrollFromPosY(window, target_y - window->Pos.y, 0.0f);
|
||||
if (can_be_fully_visible_y)
|
||||
SetScrollFromPosY(window, ImFloor((item_rect.Min.y + item_rect.Max.y) * 0.5f) - window->Pos.y, 0.5f);
|
||||
else
|
||||
SetScrollFromPosY(window, item_rect.Min.y - window->Pos.y, 0.0f);
|
||||
}
|
||||
|
||||
ImVec2 next_scroll = CalcNextScrollFromScrollTargetAndClamp(window);
|
||||
|
Reference in New Issue
Block a user