MCPcopy Create free account
hub / github.com/cinder/Cinder / NavProcessItem

Method NavProcessItem

src/imgui/imgui.cpp:13084–13158  ·  view source on GitHub ↗

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, but NextItemData is also still valid.

Source from the content-addressed store, hash-verified

13082// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above)
13083// This is called after LastItemData is set, but NextItemData is also still valid.
13084static void ImGui::NavProcessItem()
13085{
13086 ImGuiContext& g = *GImGui;
13087 ImGuiWindow* window = g.CurrentWindow;
13088 const ImGuiID id = g.LastItemData.ID;
13089 const ImGuiItemFlags item_flags = g.LastItemData.ItemFlags;
13090
13091 // When inside a container that isn't scrollable with Left<>Right, clip NavRect accordingly (#2221, #8816)
13092 ImRect nav_bb = g.LastItemData.NavRect;
13093 if (window->DC.NavIsScrollPushableX == false)
13094 {
13095 nav_bb.Min.x = ImClamp(nav_bb.Min.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
13096 nav_bb.Max.x = ImClamp(nav_bb.Max.x, window->ClipRect.Min.x, window->ClipRect.Max.x);
13097 }
13098
13099 // Process Init Request
13100 if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent && (item_flags & ImGuiItemFlags_Disabled) == 0)
13101 {
13102 // Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
13103 const bool candidate_for_nav_default_focus = (item_flags & ImGuiItemFlags_NoNavDefaultFocus) == 0;
13104 if (candidate_for_nav_default_focus || g.NavInitResult.ID == 0)
13105 {
13106 NavApplyItemToResult(&g.NavInitResult);
13107 }
13108 if (candidate_for_nav_default_focus)
13109 {
13110 g.NavInitRequest = false; // Found a match, clear request
13111 NavUpdateAnyRequestFlag();
13112 }
13113 }
13114
13115 // Process Move Request (scoring for navigation)
13116 // FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRect + scoring from a rect wrapped according to current wrapping policy)
13117 if (g.NavMoveScoringItems && (item_flags & ImGuiItemFlags_Disabled) == 0)
13118 {
13119 if ((g.NavMoveFlags & ImGuiNavMoveFlags_FocusApi) || (window->Flags & ImGuiWindowFlags_NoNavInputs) == 0)
13120 {
13121 const bool is_tabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) != 0;
13122 if (is_tabbing)
13123 {
13124 NavProcessItemForTabbingRequest(id, item_flags, g.NavMoveFlags);
13125 }
13126 else if (g.NavId != id || (g.NavMoveFlags & ImGuiNavMoveFlags_AllowCurrentNavId))
13127 {
13128 ImGuiNavItemData* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
13129 if (NavScoreItem(result, nav_bb))
13130 NavApplyItemToResult(result);
13131
13132 // Features like PageUp/PageDown need to maintain a separate score for the visible set of items.
13133 const float VISIBLE_RATIO = 0.70f;
13134 if ((g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
13135 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)
13136 if (NavScoreItem(&g.NavMoveResultLocalVisible, nav_bb))
13137 NavApplyItemToResult(&g.NavMoveResultLocalVisible);
13138 }
13139 }
13140 }
13141

Callers

nothing calls this directly

Calls 2

ImClampFunction · 0.85
WindowRectAbsToRelFunction · 0.85

Tested by

no test coverage detected