diff --git a/docs/CHANGELOG.txt b/docs/CHANGELOG.txt index dea1b0a44..f5d620027 100644 --- a/docs/CHANGELOG.txt +++ b/docs/CHANGELOG.txt @@ -95,6 +95,10 @@ Other Changes: most typically achieved when resizing programmatically or via a docking layout reacting to a platform window resize). (#3237, #9007) [@anton-kl, @ocornut] - Nav: + - Reworked PageUp/PageDown to pick same-page top/bottom page based + on inner rectangle rather than clipping rectangle, ensuring consistent + (but occasionally less practical) navigation result when a window is + partially out of screen. (#787) - Clipper: fixed an issue when using up/down from an item outside of visible bound and using the clipper. (#9079) - Fonts: diff --git a/imgui.cpp b/imgui.cpp index 3332e62bf..f9b65c484 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -13207,10 +13207,14 @@ static void ImGui::NavProcessItem() // Features like PageUp/PageDown need to maintain a separate score for the visible set of items. const float VISIBLE_RATIO = 0.70f; - if ((g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb)) - if (ImClamp(nav_bb.Max.y, window->ClipRect.Min.y, window->ClipRect.Max.y) - ImClamp(nav_bb.Min.y, window->ClipRect.Min.y, window->ClipRect.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO) - if (NavScoreItem(&g.NavMoveResultLocalVisible, nav_bb)) - NavApplyItemToResult(&g.NavMoveResultLocalVisible); + if (g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) + { + const ImRect& r = window->InnerRect; // window->ClipRect + if (r.Overlaps(nav_bb)) + if (ImClamp(nav_bb.Max.y, r.Min.y, r.Max.y) - ImClamp(nav_bb.Min.y, r.Min.y, r.Max.y) >= (nav_bb.Max.y - nav_bb.Min.y) * VISIBLE_RATIO) + if (NavScoreItem(&g.NavMoveResultLocalVisible, nav_bb)) + NavApplyItemToResult(&g.NavMoveResultLocalVisible); + } } } }