|
@@ -1291,7 +1291,7 @@ static float NavUpdatePageUpPageDown();
|
|
|
static inline void NavUpdateAnyRequestFlag();
|
|
|
static void NavUpdateCreateWrappingRequest();
|
|
|
static void NavEndFrame();
|
|
|
-static bool NavScoreItem(ImGuiNavItemData* result);
|
|
|
+static bool NavScoreItem(ImGuiNavItemData* result, const ImRect& nav_bb);
|
|
|
static void NavApplyItemToResult(ImGuiNavItemData* result);
|
|
|
static void NavProcessItem();
|
|
|
static void NavProcessItemForTabbingRequest(ImGuiID id, ImGuiItemFlags item_flags, ImGuiNavMoveFlags move_flags);
|
|
@@ -12870,7 +12870,7 @@ static float inline NavScoreItemDistInterval(float cand_min, float cand_max, flo
|
|
|
}
|
|
|
|
|
|
// Scoring function for keyboard/gamepad directional navigation. Based on https://gist.github.com/rygorous/6981057
|
|
|
-static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
|
|
|
+static bool ImGui::NavScoreItem(ImGuiNavItemData* result, const ImRect& nav_bb)
|
|
|
{
|
|
|
ImGuiContext& g = *GImGui;
|
|
|
ImGuiWindow* window = g.CurrentWindow;
|
|
@@ -12878,7 +12878,7 @@ static bool ImGui::NavScoreItem(ImGuiNavItemData* result)
|
|
|
return false;
|
|
|
|
|
|
// FIXME: Those are not good variables names
|
|
|
- ImRect cand = g.LastItemData.NavRect; // Current item nav rectangle
|
|
|
+ ImRect cand = nav_bb; // Current item nav rectangle
|
|
|
const ImRect curr = g.NavScoringRect; // Current modified source rect (NB: we've applied Max.x = Min.x in NavUpdate() to inhibit the effect of having varied item width)
|
|
|
g.NavScoringDebugCount++;
|
|
|
|
|
@@ -13045,13 +13045,13 @@ static void ImGui::NavProcessItem()
|
|
|
const ImGuiID id = g.LastItemData.ID;
|
|
|
const ImGuiItemFlags item_flags = g.LastItemData.ItemFlags;
|
|
|
|
|
|
- // When inside a container that isn't scrollable with Left<>Right, clip NavRect accordingly (#2221)
|
|
|
+ // When inside a container that isn't scrollable with Left<>Right, clip NavRect accordingly (#2221, #8816)
|
|
|
+ ImRect nav_bb = g.LastItemData.NavRect;
|
|
|
if (window->DC.NavIsScrollPushableX == false)
|
|
|
{
|
|
|
- g.LastItemData.NavRect.Min.x = ImClamp(g.LastItemData.NavRect.Min.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
|
|
|
- g.LastItemData.NavRect.Max.x = ImClamp(g.LastItemData.NavRect.Max.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
|
|
|
+ nav_bb.Min.x = ImClamp(nav_bb.Min.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
|
|
|
+ nav_bb.Max.x = ImClamp(nav_bb.Max.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
|
|
|
}
|
|
|
- const ImRect nav_bb = g.LastItemData.NavRect;
|
|
|
|
|
|
// Process Init Request
|
|
|
if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent && (item_flags & ImGuiItemFlags_Disabled) == 0)
|
|
@@ -13083,14 +13083,14 @@ static void ImGui::NavProcessItem()
|
|
|
else if (g.NavId != id || (g.NavMoveFlags & ImGuiNavMoveFlags_AllowCurrentNavId))
|
|
|
{
|
|
|
ImGuiNavItemData* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
|
|
|
- if (NavScoreItem(result))
|
|
|
+ if (NavScoreItem(result, nav_bb))
|
|
|
NavApplyItemToResult(result);
|
|
|
|
|
|
// 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))
|
|
|
+ if (NavScoreItem(&g.NavMoveResultLocalVisible, nav_bb))
|
|
|
NavApplyItemToResult(&g.NavMoveResultLocalVisible);
|
|
|
}
|
|
|
}
|