MCPcopy Create free account
hub / github.com/KebsCS/KBotExt / NavUpdateCreateMoveRequest

Method NavUpdateCreateMoveRequest

KBotExt/imgui/imgui.cpp:11570–11684  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11568}
11569
11570void ImGui::NavUpdateCreateMoveRequest()
11571{
11572 ImGuiContext& g = *GImGui;
11573 ImGuiIO& io = g.IO;
11574 ImGuiWindow* window = g.NavWindow;
11575 const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
11576 const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
11577
11578 if (g.NavMoveForwardToNextFrame && window != NULL)
11579 {
11580 // Forwarding previous request (which has been modified, e.g. wrap around menus rewrite the requests with a starting rectangle at the other side of the window)
11581 // (preserve most state, which were already set by the NavMoveRequestForward() function)
11582 IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None);
11583 IM_ASSERT(g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded);
11584 IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequestForward %d\n", g.NavMoveDir);
11585 }
11586 else
11587 {
11588 // Initiate directional inputs request
11589 g.NavMoveDir = ImGuiDir_None;
11590 g.NavMoveFlags = ImGuiNavMoveFlags_None;
11591 g.NavMoveScrollFlags = ImGuiScrollFlags_None;
11592 if (window && !g.NavWindowingTarget && !(window->Flags & ImGuiWindowFlags_NoNavInputs))
11593 {
11594 const ImGuiInputFlags repeat_mode = ImGuiInputFlags_Repeat | (ImGuiInputFlags)ImGuiInputFlags_RepeatRateNavMove;
11595 if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadLeft, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_LeftArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Left; }
11596 if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadRight, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_RightArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Right; }
11597 if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadUp, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_UpArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Up; }
11598 if (!IsActiveIdUsingNavDir(ImGuiDir_Down) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadDown, ImGuiKeyOwner_None, repeat_mode)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_DownArrow, ImGuiKeyOwner_None, repeat_mode)))) { g.NavMoveDir = ImGuiDir_Down; }
11599 }
11600 g.NavMoveClipDir = g.NavMoveDir;
11601 g.NavScoringNoClipRect = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX);
11602 }
11603
11604 // Update PageUp/PageDown/Home/End scroll
11605 // FIXME-NAV: Consider enabling those keys even without the master ImGuiConfigFlags_NavEnableKeyboard flag?
11606 float scoring_rect_offset_y = 0.0f;
11607 if (window && g.NavMoveDir == ImGuiDir_None && nav_keyboard_active)
11608 scoring_rect_offset_y = NavUpdatePageUpPageDown();
11609 if (scoring_rect_offset_y != 0.0f)
11610 {
11611 g.NavScoringNoClipRect = window->InnerRect;
11612 g.NavScoringNoClipRect.TranslateY(scoring_rect_offset_y);
11613 }
11614
11615 // [DEBUG] Always send a request when holding CTRL. Hold CTRL + Arrow change the direction.
11616#if IMGUI_DEBUG_NAV_SCORING
11617 //if (io.KeyCtrl && IsKeyPressed(ImGuiKey_C))
11618 // g.NavMoveDirForDebug = (ImGuiDir)((g.NavMoveDirForDebug + 1) & 3);
11619 if (io.KeyCtrl)
11620 {
11621 if (g.NavMoveDir == ImGuiDir_None)
11622 g.NavMoveDir = g.NavMoveDirForDebug;
11623 g.NavMoveClipDir = g.NavMoveDir;
11624 g.NavMoveFlags |= ImGuiNavMoveFlags_DebugNoResult;
11625 }
11626#endif
11627

Callers

nothing calls this directly

Calls 10

IsActiveIdUsingNavDirFunction · 0.85
WindowRectAbsToRelFunction · 0.85
ImVec2Function · 0.85
ImMinFunction · 0.85
WindowRectRelToAbsFunction · 0.85
NavBiasScoringRectFunction · 0.85
ContainsMethod · 0.80
AddMethod · 0.80
ImRectFunction · 0.70

Tested by

no test coverage detected