MCPcopy Create free account
hub / github.com/RenderKit/embree / NavProcessItem

Method NavProcessItem

tutorials/common/imgui/imgui.cpp:10525–10589  ·  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.

Source from the content-addressed store, hash-verified

10523// We get there when either NavId == id, or when g.NavAnyRequest is set (which is updated by NavUpdateAnyRequestFlag above)
10524// This is called after LastItemData is set.
10525static void ImGui::NavProcessItem()
10526{
10527 ImGuiContext& g = *GImGui;
10528 ImGuiWindow* window = g.CurrentWindow;
10529 const ImGuiID id = g.LastItemData.ID;
10530 const ImRect nav_bb = g.LastItemData.NavRect;
10531 const ImGuiItemFlags item_flags = g.LastItemData.InFlags;
10532
10533 // Process Init Request
10534 if (g.NavInitRequest && g.NavLayer == window->DC.NavLayerCurrent && (item_flags & ImGuiItemFlags_Disabled) == 0)
10535 {
10536 // Even if 'ImGuiItemFlags_NoNavDefaultFocus' is on (typically collapse/close button) we record the first ResultId so they can be used as a fallback
10537 const bool candidate_for_nav_default_focus = (item_flags & ImGuiItemFlags_NoNavDefaultFocus) == 0;
10538 if (candidate_for_nav_default_focus || g.NavInitResultId == 0)
10539 {
10540 g.NavInitResultId = id;
10541 g.NavInitResultRectRel = WindowRectAbsToRel(window, nav_bb);
10542 }
10543 if (candidate_for_nav_default_focus)
10544 {
10545 g.NavInitRequest = false; // Found a match, clear request
10546 NavUpdateAnyRequestFlag();
10547 }
10548 }
10549
10550 // Process Move Request (scoring for navigation)
10551 // FIXME-NAV: Consider policy for double scoring (scoring from NavScoringRect + scoring from a rect wrapped according to current wrapping policy)
10552 if (g.NavMoveScoringItems)
10553 {
10554 const bool is_tab_stop = (item_flags & ImGuiItemFlags_Inputable) && (item_flags & (ImGuiItemFlags_NoTabStop | ImGuiItemFlags_Disabled)) == 0;
10555 const bool is_tabbing = (g.NavMoveFlags & ImGuiNavMoveFlags_Tabbing) != 0;
10556 if (is_tabbing)
10557 {
10558 if (is_tab_stop || (g.NavMoveFlags & ImGuiNavMoveFlags_FocusApi))
10559 NavProcessItemForTabbingRequest(id);
10560 }
10561 else if ((g.NavId != id || (g.NavMoveFlags & ImGuiNavMoveFlags_AllowCurrentNavId)) && !(item_flags & ImGuiItemFlags_Disabled))
10562 {
10563 ImGuiNavItemData* result = (window == g.NavWindow) ? &g.NavMoveResultLocal : &g.NavMoveResultOther;
10564 if (!is_tabbing)
10565 {
10566 if (NavScoreItem(result))
10567 NavApplyItemToResult(result);
10568
10569 // Features like PageUp/PageDown need to maintain a separate score for the visible set of items.
10570 const float VISIBLE_RATIO = 0.70f;
10571 if ((g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet) && window->ClipRect.Overlaps(nav_bb))
10572 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)
10573 if (NavScoreItem(&g.NavMoveResultLocalVisible))
10574 NavApplyItemToResult(&g.NavMoveResultLocalVisible);
10575 }
10576 }
10577 }
10578
10579 // Update window-relative bounding box of navigated item
10580 if (g.NavId == id)
10581 {
10582 if (g.NavWindow != window)

Callers

nothing calls this directly

Calls 2

WindowRectAbsToRelFunction · 0.85
ImClampFunction · 0.85

Tested by

no test coverage detected