MCPcopy Create free account
hub / github.com/cinder/Cinder / NavUpdateCreateMoveRequest

Method NavUpdateCreateMoveRequest

src/imgui/imgui.cpp:13699–13815  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13697}
13698
13699void ImGui::NavUpdateCreateMoveRequest()
13700{
13701 ImGuiContext& g = *GImGui;
13702 ImGuiIO& io = g.IO;
13703 ImGuiWindow* window = g.NavWindow;
13704 const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
13705 const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
13706
13707 if (g.NavMoveForwardToNextFrame && window != NULL)
13708 {
13709 // 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)
13710 // (preserve most state, which were already set by the NavMoveRequestForward() function)
13711 IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None);
13712 IM_ASSERT(g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded);
13713 IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequestForward %d\n", g.NavMoveDir);
13714 }
13715 else
13716 {
13717 // Initiate directional inputs request
13718 g.NavMoveDir = ImGuiDir_None;
13719 g.NavMoveFlags = ImGuiNavMoveFlags_None;
13720 g.NavMoveScrollFlags = ImGuiScrollFlags_None;
13721 if (window && !g.NavWindowingTarget && !(window->Flags & ImGuiWindowFlags_NoNavInputs))
13722 {
13723 const ImGuiInputFlags repeat_mode = ImGuiInputFlags_Repeat | (ImGuiInputFlags)ImGuiInputFlags_RepeatRateNavMove;
13724 if (!IsActiveIdUsingNavDir(ImGuiDir_Left) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadLeft, repeat_mode, ImGuiKeyOwner_NoOwner)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_LeftArrow, repeat_mode, ImGuiKeyOwner_NoOwner)))) { g.NavMoveDir = ImGuiDir_Left; }
13725 if (!IsActiveIdUsingNavDir(ImGuiDir_Right) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadRight, repeat_mode, ImGuiKeyOwner_NoOwner)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_RightArrow, repeat_mode, ImGuiKeyOwner_NoOwner)))) { g.NavMoveDir = ImGuiDir_Right; }
13726 if (!IsActiveIdUsingNavDir(ImGuiDir_Up) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadUp, repeat_mode, ImGuiKeyOwner_NoOwner)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_UpArrow, repeat_mode, ImGuiKeyOwner_NoOwner)))) { g.NavMoveDir = ImGuiDir_Up; }
13727 if (!IsActiveIdUsingNavDir(ImGuiDir_Down) && ((nav_gamepad_active && IsKeyPressed(ImGuiKey_GamepadDpadDown, repeat_mode, ImGuiKeyOwner_NoOwner)) || (nav_keyboard_active && IsKeyPressed(ImGuiKey_DownArrow, repeat_mode, ImGuiKeyOwner_NoOwner)))) { g.NavMoveDir = ImGuiDir_Down; }
13728 }
13729 g.NavMoveClipDir = g.NavMoveDir;
13730 g.NavScoringNoClipRect = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX);
13731 }
13732
13733 // Update PageUp/PageDown/Home/End scroll
13734 // FIXME-NAV: Consider enabling those keys even without the master ImGuiConfigFlags_NavEnableKeyboard flag?
13735 float scoring_rect_offset_y = 0.0f;
13736 if (window && g.NavMoveDir == ImGuiDir_None && nav_keyboard_active)
13737 scoring_rect_offset_y = NavUpdatePageUpPageDown();
13738 if (scoring_rect_offset_y != 0.0f)
13739 {
13740 g.NavScoringNoClipRect = window->InnerRect;
13741 g.NavScoringNoClipRect.TranslateY(scoring_rect_offset_y);
13742 }
13743
13744 // [DEBUG] Always send a request when holding CTRL. Hold CTRL + Arrow change the direction.
13745#if IMGUI_DEBUG_NAV_SCORING
13746 //if (io.KeyCtrl && IsKeyPressed(ImGuiKey_C))
13747 // g.NavMoveDirForDebug = (ImGuiDir)((g.NavMoveDirForDebug + 1) & 3);
13748 if (io.KeyCtrl)
13749 {
13750 if (g.NavMoveDir == ImGuiDir_None)
13751 g.NavMoveDir = g.NavMoveDirForDebug;
13752 g.NavMoveClipDir = g.NavMoveDir;
13753 g.NavMoveFlags |= ImGuiNavMoveFlags_DebugNoResult;
13754 }
13755#endif
13756

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
GetHeightMethod · 0.80
ImRectFunction · 0.50
ContainsMethod · 0.45

Tested by

no test coverage detected