1
0
Fork 0
mirror of https://github.com/ocornut/imgui.git synced 2026-01-09 23:54:20 +00:00

Nav: fixed scoring when using PageUp/PageDown from a focused item which is outside of visible boundaries. (#9079)

We only use ImGuiNavMoveFlags_AlsoScoreVisibleSet when starting point is visible.
This commit is contained in:
ocornut 2025-11-19 19:01:03 +01:00
parent 0faa0dba15
commit 4ab86e1d61
2 changed files with 12 additions and 6 deletions

View file

@ -13891,11 +13891,17 @@ void ImGui::NavUpdateCreateMoveRequest()
{
ImRect nav_rect_rel = !window->NavRectRel[g.NavLayer].IsInverted() ? window->NavRectRel[g.NavLayer] : ImRect(0, 0, 0, 0);
scoring_rect = WindowRectRelToAbs(window, nav_rect_rel);
if (scoring_page_offset_y != 0.0f)
if (g.NavMoveFlags & ImGuiNavMoveFlags_IsPageMove)
{
// When we start from a visible location, score visible items and prioritize this result.
if (window->InnerRect.Contains(scoring_rect))
g.NavMoveFlags |= ImGuiNavMoveFlags_AlsoScoreVisibleSet;
g.NavScoringNoClipRect = scoring_rect;
scoring_rect.TranslateY(scoring_page_offset_y);
if (scoring_page_offset_y != 0.0f)
scoring_rect.TranslateY(scoring_page_offset_y);
g.NavScoringNoClipRect.Add(scoring_rect);
}
//GetForegroundDrawList()->AddRectFilled(scoring_rect.Min - ImVec2(1, 1), scoring_rect.Max + ImVec2(1, 1), IM_COL32(255, 100, 0, 80)); // [DEBUG] Pre-bias
if (g.NavMoveSubmitted)
NavBiasScoringRect(scoring_rect, window->RootWindowForNav->NavPreferredScoringPosRel[g.NavLayer], g.NavMoveDir, g.NavMoveFlags);
@ -14147,14 +14153,14 @@ static float ImGui::NavUpdatePageUpPageDown()
nav_scoring_rect_offset_y = -page_offset_y;
g.NavMoveDir = ImGuiDir_Down; // Because our scoring rect is offset up, we request the down direction (so we can always land on the last item)
g.NavMoveClipDir = ImGuiDir_Up;
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet | ImGuiNavMoveFlags_IsPageMove;
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_IsPageMove; // ImGuiNavMoveFlags_AlsoScoreVisibleSet may be added later
}
else if (IsKeyPressed(ImGuiKey_PageDown, true))
{
nav_scoring_rect_offset_y = +page_offset_y;
g.NavMoveDir = ImGuiDir_Up; // Because our scoring rect is offset down, we request the up direction (so we can always land on the last item)
g.NavMoveClipDir = ImGuiDir_Down;
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_AlsoScoreVisibleSet | ImGuiNavMoveFlags_IsPageMove;
g.NavMoveFlags = ImGuiNavMoveFlags_AllowCurrentNavId | ImGuiNavMoveFlags_IsPageMove; // ImGuiNavMoveFlags_AlsoScoreVisibleSet may be added later
}
else if (home_pressed)
{

View file

@ -29,7 +29,7 @@
// Library Version
// (Integer encoded as XYYZZ for use in #if preprocessor conditionals, e.g. '#if IMGUI_VERSION_NUM >= 12345')
#define IMGUI_VERSION "1.92.5 WIP"
#define IMGUI_VERSION_NUM 19247
#define IMGUI_VERSION_NUM 19248
#define IMGUI_HAS_TABLE // Added BeginTable() - from IMGUI_VERSION_NUM >= 18000
#define IMGUI_HAS_TEXTURES // Added ImGuiBackendFlags_RendererHasTextures - from IMGUI_VERSION_NUM >= 19198