MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/SPlisHSPlasH / NavUpdateCreateMoveRequest

Method NavUpdateCreateMoveRequest

extern/imgui/imgui.cpp:11758–11865  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11756}
11757
11758void ImGui::NavUpdateCreateMoveRequest()
11759{
11760 ImGuiContext& g = *GImGui;
11761 ImGuiIO& io = g.IO;
11762 ImGuiWindow* window = g.NavWindow;
11763 const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
11764 const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
11765
11766 if (g.NavMoveForwardToNextFrame && window != NULL)
11767 {
11768 // Forwarding previous request (which has been modified, e.g. wrap around menus rewrite the requests with a starting rectangle at the other side of the window)
11769 // (preserve most state, which were already set by the NavMoveRequestForward() function)
11770 IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None);
11771 IM_ASSERT(g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded);
11772 IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequestForward %d\n", g.NavMoveDir);
11773 }
11774 else
11775 {
11776 // Initiate directional inputs request
11777 g.NavMoveDir = ImGuiDir_None;
11778 g.NavMoveFlags = ImGuiNavMoveFlags_None;
11779 g.NavMoveScrollFlags = ImGuiScrollFlags_None;
11780 if (window && !g.NavWindowingTarget && !(window->Flags & ImGuiWindowFlags_NoNavInputs))
11781 {
11782 const ImGuiInputFlags repeat_mode = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateNavMove;
11783 if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadLeft, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_LeftArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Left; }
11784 if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadRight, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_RightArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Right; }
11785 if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadUp, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_UpArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Up; }
11786 if (!IsActiveIdUsingNavDir(ImGuiDir_Down) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadDown, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_DownArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Down; }
11787 }
11788 g.NavMoveClipDir = g.NavMoveDir;
11789 g.NavScoringNoClipRect = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX);
11790 }
11791
11792 // Update PageUp/PageDown/Home/End scroll
11793 // FIXME-NAV: Consider enabling those keys even without the master ImGuiConfigFlags_NavEnableKeyboard flag?
11794 float scoring_rect_offset_y = 0.0f;
11795 if (window && g.NavMoveDir == ImGuiDir_None && nav_keyboard_active)
11796 scoring_rect_offset_y = NavUpdatePageUpPageDown();
11797 if (scoring_rect_offset_y != 0.0f)
11798 {
11799 g.NavScoringNoClipRect = window->InnerRect;
11800 g.NavScoringNoClipRect.TranslateY(scoring_rect_offset_y);
11801 }
11802
11803 // [DEBUG] Always send a request
11804#if IMGUI_DEBUG_NAV_SCORING
11805 if (io.KeyCtrl && IsKeyPressed(ImGuiKey_C))
11806 g.NavMoveDirForDebug = (ImGuiDir)((g.NavMoveDirForDebug + 1) & 3);
11807 if (io.KeyCtrl && g.NavMoveDir == ImGuiDir_None)
11808 {
11809 g.NavMoveDir = g.NavMoveDirForDebug;
11810 g.NavMoveFlags |= ImGuiNavMoveFlags_DebugNoResult;
11811 }
11812#endif
11813
11814 // Submit
11815 g.NavMoveForwardToNextFrame = false;

Callers

nothing calls this directly

Calls 8

IsActiveIdUsingNavDirFunction · 0.85
WindowRectAbsToRelFunction · 0.85
ImVec2Function · 0.85
ImMinFunction · 0.85
WindowRectRelToAbsFunction · 0.85
AddMethod · 0.80
ImRectFunction · 0.70
ContainsMethod · 0.45

Tested by

no test coverage detected