| 13470 | } |
| 13471 | |
| 13472 | static void ImGui::NavUpdate() |
| 13473 | { |
| 13474 | ImGuiContext& g = *GImGui; |
| 13475 | ImGuiIO& io = g.IO; |
| 13476 | |
| 13477 | io.WantSetMousePos = false; |
| 13478 | //if (g.NavScoringDebugCount > 0) IMGUI_DEBUG_LOG_NAV("[nav] 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); |
| 13479 | |
| 13480 | // Set input source based on which keys are last pressed (as some features differs when used with Gamepad vs Keyboard) |
| 13481 | // FIXME-NAV: Now that keys are separated maybe we can get rid of NavInputSource? |
| 13482 | const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; |
| 13483 | const ImGuiKey nav_gamepad_keys_to_change_source[] = { ImGuiKey_GamepadFaceRight, ImGuiKey_GamepadFaceLeft, ImGuiKey_GamepadFaceUp, ImGuiKey_GamepadFaceDown, ImGuiKey_GamepadDpadRight, ImGuiKey_GamepadDpadLeft, ImGuiKey_GamepadDpadUp, ImGuiKey_GamepadDpadDown }; |
| 13484 | if (nav_gamepad_active) |
| 13485 | for (ImGuiKey key : nav_gamepad_keys_to_change_source) |
| 13486 | if (IsKeyDown(key)) |
| 13487 | g.NavInputSource = ImGuiInputSource_Gamepad; |
| 13488 | const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; |
| 13489 | const ImGuiKey nav_keyboard_keys_to_change_source[] = { ImGuiKey_Space, ImGuiKey_Enter, ImGuiKey_Escape, ImGuiKey_RightArrow, ImGuiKey_LeftArrow, ImGuiKey_UpArrow, ImGuiKey_DownArrow }; |
| 13490 | if (nav_keyboard_active) |
| 13491 | for (ImGuiKey key : nav_keyboard_keys_to_change_source) |
| 13492 | if (IsKeyDown(key)) |
| 13493 | g.NavInputSource = ImGuiInputSource_Keyboard; |
| 13494 | |
| 13495 | // Process navigation init request (select first/default focus) |
| 13496 | g.NavJustMovedToId = 0; |
| 13497 | g.NavJustMovedToFocusScopeId = g.NavJustMovedFromFocusScopeId = 0; |
| 13498 | if (g.NavInitResult.ID != 0) |
| 13499 | NavInitRequestApplyResult(); |
| 13500 | g.NavInitRequest = false; |
| 13501 | g.NavInitRequestFromMove = false; |
| 13502 | g.NavInitResult.ID = 0; |
| 13503 | |
| 13504 | // Process navigation move request |
| 13505 | if (g.NavMoveSubmitted) |
| 13506 | NavMoveRequestApplyResult(); |
| 13507 | g.NavTabbingCounter = 0; |
| 13508 | g.NavMoveSubmitted = g.NavMoveScoringItems = false; |
| 13509 | if (g.NavCursorHideFrames > 0) |
| 13510 | if (--g.NavCursorHideFrames == 0) |
| 13511 | g.NavCursorVisible = true; |
| 13512 | |
| 13513 | // Schedule mouse position update (will be done at the bottom of this function, after 1) processing all move requests and 2) updating scrolling) |
| 13514 | bool set_mouse_pos = false; |
| 13515 | if (g.NavMousePosDirty && g.NavIdIsAlive) |
| 13516 | if (g.NavCursorVisible && g.NavHighlightItemUnderNav && g.NavWindow) |
| 13517 | set_mouse_pos = true; |
| 13518 | g.NavMousePosDirty = false; |
| 13519 | IM_ASSERT(g.NavLayer == ImGuiNavLayer_Main || g.NavLayer == ImGuiNavLayer_Menu); |
| 13520 | |
| 13521 | // Store our return window (for returning from Menu Layer to Main Layer) and clear it as soon as we step back in our own Layer 0 |
| 13522 | if (g.NavWindow) |
| 13523 | NavSaveLastChildNavWindowIntoParent(g.NavWindow); |
| 13524 | if (g.NavWindow && g.NavWindow->NavLastChildNavWindow != NULL && g.NavLayer == ImGuiNavLayer_Main) |
| 13525 | g.NavWindow->NavLastChildNavWindow = NULL; |
| 13526 | |
| 13527 | // Update CTRL+TAB and Windowing features (hold Square to move/resize/etc.) |
| 13528 | NavUpdateWindowing(); |
| 13529 |
nothing calls this directly
no test coverage detected