We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above) This is called after LastItemData is set.
| 11003 | // We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above) |
| 11004 | // This is called after LastItemData is set. |
| 11005 | static void ImGui::NavProcessItem() |
| 11006 | { |
| 11007 | ImGuiContext& g = *GImGui; |
| 11008 | ImGuiWindow* window = g.CurrentWindow; |
| 11009 | const ImGuiID id = g.LastItemData.ID; |
| 11010 | const ImGuiItemFlags item_flags = g.LastItemData.InFlags; |
| 11011 | |
| 11012 | // When inside a container that isn't scrollable with Left<>Right, clip NavRect accordingly (#2221) |
| 11013 | if (window->DC.NavIsScrollPushableX == false) |
| 11014 | { |
| 11015 | g.LastItemData.NavRect.Min.x = ImClamp(g.LastItemData.NavRect.Min.x, window->ClipRect.Min.x, window->ClipRect.Max.x); |
| 11016 | g.LastItemData.NavRect.Max.x = ImClamp(g.LastItemData.NavRect.Max.x, window->ClipRect.Min.x, window->ClipRect.Max.x); |
| 11017 | } |
| 11018 | const ImRect nav_bb = g.LastItemData.NavRect; |
| 11019 | |
| 11020 | // Process Init Request |
| 11021 | if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent && (item_flags & ImGuiItemFlags_Disabled) == 0) |
| 11022 | { |
| 11023 | // Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback |
| 11024 | const bool candidate_for_nav_default_focus = (item_flags & ImGuiItemFlags_NoNavDefaultFocus) == 0; |
| 11025 | if (candidate_for_nav_default_focus || g.NavInitResult.ID == 0) |
| 11026 | { |
| 11027 | NavApplyItemToResult(&g.NavInitResult); |
| 11028 | } |
| 11029 | if (candidate_for_nav_default_focus) |
| 11030 | { |
| 11031 | g.NavInitRequest = false; // Found a match, clear request |
| 11032 | NavUpdateAnyRequestFlag(); |
| 11033 | } |
| 11034 | } |
| 11035 | |
| 11036 | // Process Move Request (scoring for navigation) |
| 11037 | // FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRect + scoring from a rect wrapped according to current wrapping policy) |
| 11038 | if (g.NavMoveScoringItems && (item_flags & ImGuiItemFlags_Disabled) == 0) |
| 11039 | { |
| 11040 | const bool is_tabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) != 0; |
| 11041 | if (is_tabbing) |
| 11042 | { |
| 11043 | NavProcessItemForTabbingRequest(id, item_flags, g.NavMoveFlags); |
| 11044 | } |
| 11045 | else if (g.NavId != id || (g.NavMoveFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) |
| 11046 | { |
| 11047 | ImGuiNavItemData* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther; |
| 11048 | if (NavScoreItem(result)) |
| 11049 | NavApplyItemToResult(result); |
| 11050 | |
| 11051 | // Features like PageUp/PageDown need to maintain a separate score for the visible set of items. |
| 11052 | const float VISIBLE_RATIO = 0.70f; |
| 11053 | if ((g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb)) |
| 11054 | 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) |
| 11055 | if (NavScoreItem(&g.NavMoveResultLocalVisible)) |
| 11056 | NavApplyItemToResult(&g.NavMoveResultLocalVisible); |
| 11057 | } |
| 11058 | } |
| 11059 | |
| 11060 | // Update information for currently focused/navigated item |
| 11061 | if (g.NavId == id) |
| 11062 | { |
nothing calls this directly
no test coverage detected