1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 01:20:55 +01:00

Scrolling, Focus, Combo: fixed SetKeyboardFocusHere()/SetItemDefaultFocus()/ScrollToRectEx() during an appearing form not centering item. (#5902, #2812, #4242, #2900)

Amend 44f801186 and 8f495e554
This commit is contained in:
ocornut 2022-11-24 17:40:51 +01:00
parent 233d7ad3f2
commit 27c58c3946
3 changed files with 15 additions and 7 deletions

View File

@ -35,11 +35,15 @@ HOW TO UPDATE?
VERSION 1.89.1 WIP (In Progress)
-----------------------------------------------------------------------
- Scrolling, Focus: fixed SetKeyboardFocusHere()/SetItemDefaultFocus() during a window-appearing
frame (and associated lower-level functions e.g. ScrollToRectEx()) from not centering item. (#5902)
- Inputs: fixed moving a window or drag and dropping from preventing input-owner-unaware code
from accessing keys. (#5888, #4921, #456)
- Inputs: fixed moving a window or drag and dropping from capturing mods. (#5888, #4921, #456)
- Layout: fixed End()/EndChild() incorrectly asserting if users manipulates cursor position
inside a collapsed/culled window and IMGUI_DISABLE_OBSOLETE_FUNCTIONS is enabled. (#5548, #5911)
- Combo: fixed selected item (marked with SetItemDefaultFocus()) from not being centered when
the combo window initially appears. (#5902).
- ColorEdit: fixed label overlapping when using style.ColorButtonPosition == ImGuiDir_Left to
move the color button on the left side (regression introduced in 1.88 WIP 2022/02/28). (#5912)
- Drag and Drop: fixed GetDragDropPayload() returning a non-NULL value if a drag source is

View File

@ -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);

View File

@ -23,7 +23,7 @@
// Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM > 12345')
#define IMGUI_VERSION "1.89.1 WIP"
#define IMGUI_VERSION_NUM 18903
#define IMGUI_VERSION_NUM 18904
#define IMGUI_HAS_TABLE
/*