| 11575 | } |
| 11576 | |
| 11577 | static void ImGui::NavUpdate() |
| 11578 | { |
| 11579 | ImGuiContext& g = *GImGui; |
| 11580 | ImGuiIO& io = g.IO; |
| 11581 | |
| 11582 | io.WantSetMousePos = false; |
| 11583 | //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); |
| 11584 | |
| 11585 | // Set input source based on which keys are last pressed (as some features differs when used with Gamepad vs Keyboard) |
| 11586 | // FIXME-NAV: Now that keys are separated maybe we can get rid of NavInputSource? |
| 11587 | const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; |
| 11588 | const ImGuiKey nav_gamepad_keys_to_change_source[] = { ImGuiKey_GamepadFaceRight, ImGuiKey_GamepadFaceLeft, ImGuiKey_GamepadFaceUp, ImGuiKey_GamepadFaceDown, ImGuiKey_GamepadDpadRight, ImGuiKey_GamepadDpadLeft, ImGuiKey_GamepadDpadUp, ImGuiKey_GamepadDpadDown }; |
| 11589 | if (nav_gamepad_active) |
| 11590 | for (ImGuiKey key : nav_gamepad_keys_to_change_source) |
| 11591 | if (IsKeyDown(key)) |
| 11592 | g.NavInputSource = ImGuiInputSource_Gamepad; |
| 11593 | const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; |
| 11594 | const ImGuiKey nav_keyboard_keys_to_change_source[] = { ImGuiKey_Space, ImGuiKey_Enter, ImGuiKey_Escape, ImGuiKey_RightArrow, ImGuiKey_LeftArrow, ImGuiKey_UpArrow, ImGuiKey_DownArrow }; |
| 11595 | if (nav_keyboard_active) |
| 11596 | for (ImGuiKey key : nav_keyboard_keys_to_change_source) |
| 11597 | if (IsKeyDown(key)) |
| 11598 | g.NavInputSource = ImGuiInputSource_Keyboard; |
| 11599 | |
| 11600 | // Process navigation init request (select first/default focus) |
| 11601 | if (g.NavInitResultId != 0) |
| 11602 | NavInitRequestApplyResult(); |
| 11603 | g.NavInitRequest = false; |
| 11604 | g.NavInitRequestFromMove = false; |
| 11605 | g.NavInitResultId = 0; |
| 11606 | g.NavJustMovedToId = 0; |
| 11607 | |
| 11608 | // Process navigation move request |
| 11609 | if (g.NavMoveSubmitted) |
| 11610 | NavMoveRequestApplyResult(); |
| 11611 | g.NavTabbingCounter = 0; |
| 11612 | g.NavMoveSubmitted = g.NavMoveScoringItems = false; |
| 11613 | |
| 11614 | // Schedule mouse position update (will be done at the bottom of this function, after 1) processing all move requests and 2) updating scrolling) |
| 11615 | bool set_mouse_pos = false; |
| 11616 | if (g.NavMousePosDirty && g.NavIdIsAlive) |
| 11617 | if (!g.NavDisableHighlight && g.NavDisableMouseHover && g.NavWindow) |
| 11618 | set_mouse_pos = true; |
| 11619 | g.NavMousePosDirty = false; |
| 11620 | IM_ASSERT(g.NavLayer == ImGuiNavLayer_Main || g.NavLayer == ImGuiNavLayer_Menu); |
| 11621 | |
| 11622 | // 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 |
| 11623 | if (g.NavWindow) |
| 11624 | NavSaveLastChildNavWindowIntoParent(g.NavWindow); |
| 11625 | if (g.NavWindow && g.NavWindow->NavLastChildNavWindow != NULL && g.NavLayer == ImGuiNavLayer_Main) |
| 11626 | g.NavWindow->NavLastChildNavWindow = NULL; |
| 11627 | |
| 11628 | // Update CTRL+TAB and Windowing features (hold Square to move/resize/etc.) |
| 11629 | NavUpdateWindowing(); |
| 11630 | |
| 11631 | // Set output flags for user application |
| 11632 | io.NavActive = (nav_keyboard_active || nav_gamepad_active) && g.NavWindow && !(g.NavWindow->Flags & ImGuiWindowFlags_NoNavInputs); |
| 11633 | io.NavVisible = (io.NavActive && g.NavId != 0 && !g.NavDisableHighlight) || (g.NavWindowingTarget != NULL); |
| 11634 |
nothing calls this directly
no test coverage detected