MCPcopy Create free account
hub / github.com/DISTRHO/Cardinal / NavUpdate

Method NavUpdate

plugins/Cardinal/src/DearImGui/imgui.cpp:9571–9747  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9569}
9570
9571static void ImGui::NavUpdate()
9572{
9573 ImGuiContext& g = *GImGui;
9574 ImGuiIO& io = g.IO;
9575
9576 io.WantSetMousePos = false;
9577 //if (g.NavScoringDebugCount > 0) IMGUI_DEBUG_LOG("NavScoringDebugCount %d for '%s' layer %d (Init:%d, Move:%d)\n", g.NavScoringDebugCount, g.NavWindow ? g.NavWindow->Name : "NULL", g.NavLayer, g.NavInitRequest || g.NavInitResultId != 0, g.NavMoveRequest);
9578
9579 // Set input source as Gamepad when buttons are pressed (as some features differs when used with Gamepad vs Keyboard)
9580 // (do it before we map Keyboard input!)
9581 const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
9582 const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
9583 if (nav_gamepad_active && g.NavInputSource != ImGuiInputSource_Gamepad)
9584 {
9585 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
9586 || io.NavInputs[ImGuiNavInput_DpadLeft] > 0.0f || io.NavInputs[ImGuiNavInput_DpadRight] > 0.0f || io.NavInputs[ImGuiNavInput_DpadUp] > 0.0f || io.NavInputs[ImGuiNavInput_DpadDown] > 0.0f)
9587 g.NavInputSource = ImGuiInputSource_Gamepad;
9588 }
9589
9590 // Update Keyboard->Nav inputs mapping
9591 if (nav_keyboard_active)
9592 {
9593 #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)
9594 NAV_MAP_KEY(ImGuiKey_Space, ImGuiNavInput_Activate );
9595 NAV_MAP_KEY(ImGuiKey_Enter, ImGuiNavInput_Input );
9596 NAV_MAP_KEY(ImGuiKey_Escape, ImGuiNavInput_Cancel );
9597 NAV_MAP_KEY(ImGuiKey_LeftArrow, ImGuiNavInput_KeyLeft_ );
9598 NAV_MAP_KEY(ImGuiKey_RightArrow,ImGuiNavInput_KeyRight_);
9599 NAV_MAP_KEY(ImGuiKey_UpArrow, ImGuiNavInput_KeyUp_ );
9600 NAV_MAP_KEY(ImGuiKey_DownArrow, ImGuiNavInput_KeyDown_ );
9601 if (io.KeyCtrl)
9602 io.NavInputs[ImGuiNavInput_TweakSlow] = 1.0f;
9603 if (io.KeyShift)
9604 io.NavInputs[ImGuiNavInput_TweakFast] = 1.0f;
9605 #undef NAV_MAP_KEY
9606 }
9607 memcpy(io.NavInputsDownDurationPrev, io.NavInputsDownDuration, sizeof(io.NavInputsDownDuration));
9608 for (int i = 0; i < IM_ARRAYSIZE(io.NavInputs); i++)
9609 io.NavInputsDownDuration[i] = (io.NavInputs[i] > 0.0f) ? (io.NavInputsDownDuration[i] < 0.0f ? 0.0f : io.NavInputsDownDuration[i] + io.DeltaTime) : -1.0f;
9610
9611 // Process navigation init request (select first/default focus)
9612 if (g.NavInitResultId != 0)
9613 NavInitRequestApplyResult();
9614 g.NavInitRequest = false;
9615 g.NavInitRequestFromMove = false;
9616 g.NavInitResultId = 0;
9617 g.NavJustMovedToId = 0;
9618
9619 // Process navigation move request
9620 if (g.NavMoveSubmitted)
9621 NavMoveRequestApplyResult();
9622 g.NavTabbingCounter = 0;
9623 g.NavMoveSubmitted = g.NavMoveScoringItems = false;
9624
9625 // Schedule mouse position update (will be done at the bottom of this function, after 1) processing all move requests and 2) updating scrolling)
9626 bool set_mouse_pos = false;
9627 if (g.NavMousePosDirty && g.NavIdIsAlive)
9628 if (!g.NavDisableHighlight && g.NavDisableMouseHover && g.NavWindow)

Callers

nothing calls this directly

Calls 10

IsNavInputDownFunction · 0.85
IsNavInputTestFunction · 0.85
ImFloorFunction · 0.85
GetForegroundDrawListFunction · 0.85
WindowRectRelToAbsFunction · 0.85
ImFormatStringFunction · 0.85
ImVec2Function · 0.85
AddRectMethod · 0.80
AddCircleFilledMethod · 0.80
AddTextMethod · 0.80

Tested by

no test coverage detected