MCPcopy Create free account
hub / github.com/VictorGordan/opengl-tutorials / NavUpdate

Method NavUpdate

ImGUI GLFW Tutorial/imgui/imgui.cpp:9022–9301  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 14

IsNavInputTestFunction · 0.70
IsActiveIdUsingNavInputFunction · 0.70
ImRectFunction · 0.70
IsNavInputDownFunction · 0.70
IsActiveIdUsingNavDirFunction · 0.70
ImFloorFunction · 0.70
ImVec2Function · 0.70
ImMinFunction · 0.70
GetForegroundDrawListFunction · 0.70
ImFormatStringFunction · 0.70
ClearMethod · 0.45
AddRectMethod · 0.45

Tested by

no test coverage detected