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

Method NavMoveRequestApplyResult

src/imgui/imgui.cpp:13845–13958  ·  view source on GitHub ↗

Apply result from previous frame navigation directional move request. Always called from NavUpdate()

Source from the content-addressed store, hash-verified

13843
13844// Apply result from previous frame navigation directional move request. Always called from NavUpdate()
13845void ImGui::NavMoveRequestApplyResult()
13846{
13847 ImGuiContext& g = *GImGui;
13848#if IMGUI_DEBUG_NAV_SCORING
13849 if (g.NavMoveFlags & ImGuiNavMoveFlags_DebugNoResult) // [DEBUG] Scoring all items in NavWindow at all times
13850 return;
13851#endif
13852
13853 // Select which result to use
13854 ImGuiNavItemData* result = (g.NavMoveResultLocal.ID != 0) ? &g.NavMoveResultLocal : (g.NavMoveResultOther.ID != 0) ? &g.NavMoveResultOther : NULL;
13855
13856 // Tabbing forward wrap
13857 if ((g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing) && result == NULL)
13858 if ((g.NavTabbingCounter == 1 || g.NavTabbingDir == 0) && g.NavTabbingResultFirst.ID)
13859 result = &g.NavTabbingResultFirst;
13860
13861 // In a situation when there are no results but NavId != 0, re-enable the Navigation highlight (because g.NavId is not considered as a possible result)
13862 const ImGuiAxis axis = (g.NavMoveDir == ImGuiDir_Up || g.NavMoveDir == ImGuiDir_Down) ? ImGuiAxis_Y : ImGuiAxis_X;
13863 if (result == NULL)
13864 {
13865 if (g.NavMoveFlags & ImGuiNavMoveFlags_IsTabbing)
13866 g.NavMoveFlags |= ImGuiNavMoveFlags_NoSetNavCursorVisible;
13867 if (g.NavId != 0 && (g.NavMoveFlags & ImGuiNavMoveFlags_NoSetNavCursorVisible) == 0)
13868 SetNavCursorVisibleAfterMove();
13869 NavClearPreferredPosForAxis(axis); // On a failed move, clear preferred pos for this axis.
13870 IMGUI_DEBUG_LOG_NAV("[nav] NavMoveSubmitted but not led to a result!\n");
13871 return;
13872 }
13873
13874 // PageUp/PageDown behavior first jumps to the bottom/top mostly visible item, _otherwise_ use the result from the previous/next page.
13875 if (g.NavMoveFlags & ImGuiNavMoveFlags_AlsoScoreVisibleSet)
13876 if (g.NavMoveResultLocalVisible.ID != 0 && g.NavMoveResultLocalVisible.ID != g.NavId)
13877 result = &g.NavMoveResultLocalVisible;
13878
13879 // Maybe entering a flattened child from the outside? In this case solve the tie using the regular scoring rules.
13880 if (result != &g.NavMoveResultOther && g.NavMoveResultOther.ID != 0 && g.NavMoveResultOther.Window->ParentWindow == g.NavWindow)
13881 if ((g.NavMoveResultOther.DistBox < result->DistBox) || (g.NavMoveResultOther.DistBox == result->DistBox && g.NavMoveResultOther.DistCenter < result->DistCenter))
13882 result = &g.NavMoveResultOther;
13883 IM_ASSERT(g.NavWindow && result->Window);
13884
13885 // Scroll to keep newly navigated item fully into view.
13886 if (g.NavLayer == ImGuiNavLayer_Main)
13887 {
13888 ImRect rect_abs = WindowRectRelToAbs(result->Window, result->RectRel);
13889 ScrollToRectEx(result->Window, rect_abs, g.NavMoveScrollFlags);
13890
13891 if (g.NavMoveFlags & ImGuiNavMoveFlags_ScrollToEdgeY)
13892 {
13893 // FIXME: Should remove this? Or make more precise: use ScrollToRectEx() with edge?
13894 float scroll_target = (g.NavMoveDir == ImGuiDir_Up) ? result->Window->ScrollMax.y : 0.0f;
13895 SetScrollY(result->Window, scroll_target);
13896 }
13897 }
13898
13899 if (g.NavWindow != result->Window)
13900 {
13901 IMGUI_DEBUG_LOG_FOCUS("[focus] NavMoveRequest: SetNavWindow(\"%s\")\n", result->Window->Name);
13902 g.NavWindow = result->Window;

Callers

nothing calls this directly

Calls 2

WindowRectRelToAbsFunction · 0.85
GetCenterMethod · 0.45

Tested by

no test coverage detected