1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-02-02 03:40:06 +00:00

Nav: fixed WrapX/LoopX handling in menu layer. (#9178)

Amend 3050f653cb
This commit is contained in:
ocornut 2026-01-23 16:00:28 +01:00
parent e1217227b2
commit d1cf58e590
2 changed files with 7 additions and 2 deletions

View file

@ -171,6 +171,7 @@ Other Changes:
- Nav:
- Fixed remote/shortcut InputText() not teleporting mouse cursor when
nav cursor is visible and `io.ConfigNavMoveSetMousePos` is enabled.
- Fixed a looping/wrapping issue when done in menu layer. (#9178)
- Scrollbar: fixed a codepath leading to a divide-by-zero (which would not be
noticeable by user but detected by sanitizers). (#9089) [@judicaelclair]
- InvisibleButton: allow calling with size (0,0) to fit to available content

View file

@ -14252,9 +14252,13 @@ static void ImGui::NavUpdateCreateWrappingRequest()
const ImGuiNavMoveFlags move_flags = g.NavMoveFlags;
//const ImGuiAxis move_axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
// Menu layer does not maintain scrolling / content size (#9178)
ImVec2 wrap_size = (g.NavLayer == ImGuiNavLayer_Menu) ? window->Size : window->ContentSize + window->WindowPadding;
if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
{
bb_rel.Min.x = bb_rel.Max.x = window->ContentSize.x + window->WindowPadding.x;
bb_rel.Min.x = bb_rel.Max.x = wrap_size.x;
if (move_flags & ImGuiNavMoveFlags_WrapX)
{
bb_rel.TranslateY(-bb_rel.GetHeight()); // Previous row
@ -14274,7 +14278,7 @@ static void ImGui::NavUpdateCreateWrappingRequest()
}
if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
{
bb_rel.Min.y = bb_rel.Max.y = window->ContentSize.y + window->WindowPadding.y;
bb_rel.Min.y = bb_rel.Max.y = wrap_size.y;
if (move_flags & ImGuiNavMoveFlags_WrapY)
{
bb_rel.TranslateX(-bb_rel.GetWidth()); // Previous column