Skip to content

Commit d1cf58e

Browse files
committed
Nav: fixed WrapX/LoopX handling in menu layer. (ocornut#9178)
Amend 3050f65
1 parent e121722 commit d1cf58e

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

docs/CHANGELOG.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ Other Changes:
171171
- Nav:
172172
- Fixed remote/shortcut InputText() not teleporting mouse cursor when
173173
nav cursor is visible and `io.ConfigNavMoveSetMousePos` is enabled.
174+
- Fixed a looping/wrapping issue when done in menu layer. (#9178)
174175
- Scrollbar: fixed a codepath leading to a divide-by-zero (which would not be
175176
noticeable by user but detected by sanitizers). (#9089) [@judicaelclair]
176177
- InvisibleButton: allow calling with size (0,0) to fit to available content

imgui.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14252,9 +14252,13 @@ static void ImGui::NavUpdateCreateWrappingRequest()
1425214252

1425314253
const ImGuiNavMoveFlags move_flags = g.NavMoveFlags;
1425414254
//const ImGuiAxis move_axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
14255+
14256+
// Menu layer does not maintain scrolling / content size (#9178)
14257+
ImVec2 wrap_size = (g.NavLayer == ImGuiNavLayer_Menu) ? window->Size : window->ContentSize + window->WindowPadding;
14258+
1425514259
if (g.NavMoveDir == ImGuiDir_Left && (move_flags & (ImGuiNavMoveFlags_WrapX | ImGuiNavMoveFlags_LoopX)))
1425614260
{
14257-
bb_rel.Min.x = bb_rel.Max.x = window->ContentSize.x + window->WindowPadding.x;
14261+
bb_rel.Min.x = bb_rel.Max.x = wrap_size.x;
1425814262
if (move_flags & ImGuiNavMoveFlags_WrapX)
1425914263
{
1426014264
bb_rel.TranslateY(-bb_rel.GetHeight()); // Previous row
@@ -14274,7 +14278,7 @@ static void ImGui::NavUpdateCreateWrappingRequest()
1427414278
}
1427514279
if (g.NavMoveDir == ImGuiDir_Up && (move_flags & (ImGuiNavMoveFlags_WrapY | ImGuiNavMoveFlags_LoopY)))
1427614280
{
14277-
bb_rel.Min.y = bb_rel.Max.y = window->ContentSize.y + window->WindowPadding.y;
14281+
bb_rel.Min.y = bb_rel.Max.y = wrap_size.y;
1427814282
if (move_flags & ImGuiNavMoveFlags_WrapY)
1427914283
{
1428014284
bb_rel.TranslateX(-bb_rel.GetWidth()); // Previous column

0 commit comments

Comments
 (0)