MCPcopy Create free account
hub / github.com/AlexandreRouma/SDRPlusPlus / NavUpdate

Method NavUpdate

core/src/imgui/imgui.cpp:9021–9300  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9019}
9020
9021static void ImGui::NavUpdate()
9022{
9023 ImGuiContext& g = *GImGui;
9024 ImGuiIO& io = g.IO;
9025
9026 io.WantSetMousePos = false;
9027 g.NavWrapRequestWindow = NULL;
9028 g.NavWrapRequestFlags = ImGuiNavMoveFlags_None;
9029#if 0
9030 if (g.NavScoringCount > 0) IMGUI_DEBUG_LOG("NavScoringCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.FrameCount, g.NavScoringCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
9031#endif
9032
9033 // Set input source as Gamepad when buttons are pressed (as some features differs when used with Gamepad vs Keyboard)
9034 // (do it before we map Keyboard input!)
9035 bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
9036 bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
9037 if (nav_gamepad_active && g.NavInputSource != ImGuiInputSource_Gamepad)
9038 {
9039 if (io.NavInputs[ImGuiNavInput_Activate] > 0.0f || io.NavInputs[ImGuiNavInput_Input] > 0.0f || io.NavInputs[ImGuiNavInput_Cancel] > 0.0f || io.NavInputs[ImGuiNavInput_Menu] > 0.0f
9040 || io.NavInputs[ImGuiNavInput_DpadLeft] > 0.0f || io.NavInputs[ImGuiNavInput_DpadRight] > 0.0f || io.NavInputs[ImGuiNavInput_DpadUp] > 0.0f || io.NavInputs[ImGuiNavInput_DpadDown] > 0.0f)
9041 g.NavInputSource = ImGuiInputSource_Gamepad;
9042 }
9043
9044 // Update Keyboard->Nav inputs mapping
9045 if (nav_keyboard_active)
9046 {
9047 #define NAV_MAP_KEY(_KEY, _NAV_INPUT) do { if (IsKeyDown(io.KeyMap[_KEY])) { io.NavInputs[_NAV_INPUT] = 1.0f; g.NavInputSource = ImGuiInputSource_Keyboard; } } while (0)
9048 NAV_MAP_KEY(ImGuiKey_Space, ImGuiNavInput_Activate );
9049 NAV_MAP_KEY(ImGuiKey_Enter, ImGuiNavInput_Input );
9050 NAV_MAP_KEY(ImGuiKey_Escape, ImGuiNavInput_Cancel );
9051 NAV_MAP_KEY(ImGuiKey_LeftArrow, ImGuiNavInput_KeyLeft_ );
9052 NAV_MAP_KEY(ImGuiKey_RightArrow,ImGuiNavInput_KeyRight_);
9053 NAV_MAP_KEY(ImGuiKey_UpArrow, ImGuiNavInput_KeyUp_ );
9054 NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_ );
9055 if (io.KeyCtrl)
9056 io.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f;
9057 if (io.KeyShift)
9058 io.NavInputs[ImGuiNavInput_TweakFast] = 1.0f;
9059
9060 // AltGR is normally Alt+Ctrl but we can't reliably detect it (not all backends/systems/layout emit it as Alt+Ctrl)
9061 // But also even on keyboards without AltGR we don't want Alt+Ctrl to open menu anyway.
9062 if (io.KeyAlt && !io.KeyCtrl)
9063 io.NavInputs[ImGuiNavInput_KeyMenu_] = 1.0f;
9064
9065 // We automatically cancel toggling nav layer when any text has been typed while holding Alt. (See #370)
9066 if (io.KeyAlt && !io.KeyCtrl && g.NavWindowingToggleLayer && io.InputQueueCharacters.Size > 0)
9067 g.NavWindowingToggleLayer = false;
9068
9069 #undef NAV_MAP_KEY
9070 }
9071 memcpy(io.NavInputsDownDurationPrev, io.NavInputsDownDuration, sizeof(io.NavInputsDownDuration));
9072 for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++)
9073 io.NavInputsDownDuration[i] = (io.NavInputs[i] > 0.0f) ? (io.NavInputsDownDuration[i] < 0.0f ? 0.0f : io.NavInputsDownDuration[i] + io.DeltaTime) : -1.0f;
9074
9075 // Process navigation init request (select first/default focus)
9076 if (g.NavInitResultId != 0)
9077 NavUpdateInitResult();
9078 g.NavInitRequest = false;

Callers

nothing calls this directly

Calls 15

IsNavInputTestFunction · 0.85
IsActiveIdUsingNavInputFunction · 0.85
IsNavInputDownFunction · 0.85
IsActiveIdUsingNavDirFunction · 0.85
ImFloorFunction · 0.85
ImVec2Function · 0.85
ImMinFunction · 0.85
GetForegroundDrawListFunction · 0.85
ImFormatStringFunction · 0.85
ExpandMethod · 0.80
AddRectMethod · 0.80
AddCircleFilledMethod · 0.80

Tested by

no test coverage detected