MCPcopy Create free account
hub / github.com/RenderKit/embree / NavUpdateCreateMoveRequest

Method NavUpdateCreateMoveRequest

tutorials/common/imgui/imgui.cpp:11030–11137  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

11028}
11029
11030void ImGui::NavUpdateCreateMoveRequest()
11031{
11032 ImGuiContext& g = *GImGui;
11033 ImGuiIO& io = g.IO;
11034 ImGuiWindow* window = g.NavWindow;
11035 const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
11036 const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
11037
11038 if (g.NavMoveForwardToNextFrame && window != NULL)
11039 {
11040 // 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)
11041 // (preserve most state, which were already set by the NavMoveRequestForward() function)
11042 IM_ASSERT(g.NavMoveDir != ImGuiDir_None && g.NavMoveClipDir != ImGuiDir_None);
11043 IM_ASSERT(g.NavMoveFlags & ImGuiNavMoveFlags_Forwarded);
11044 IMGUI_DEBUG_LOG_NAV("[nav] NavMoveRequestForward %d\n", g.NavMoveDir);
11045 }
11046 else
11047 {
11048 // Initiate directional inputs request
11049 g.NavMoveDir = ImGuiDir_None;
11050 g.NavMoveFlags = ImGuiNavMoveFlags_None;
11051 g.NavMoveScrollFlags = ImGuiScrollFlags_None;
11052 if (window && !g.NavWindowingTarget && !(window->Flags & ImGuiWindowFlags_NoNavInputs))
11053 {
11054 const ImGuiInputFlags repeat_mode = ImGuiInputFlags_Repeat | ImGuiInputFlags_RepeatRateNavMove;
11055 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; }
11056 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; }
11057 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; }
11058 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; }
11059 }
11060 g.NavMoveClipDir = g.NavMoveDir;
11061 g.NavScoringNoClipRect = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX);
11062 }
11063
11064 // Update PageUp/PageDown/Home/End scroll
11065 // FIXME-NAV: Consider enabling those keys even without the master ImGuiConfigFlags_NavEnableKeyboard flag?
11066 float scoring_rect_offset_y = 0.0f;
11067 if (window && g.NavMoveDir == ImGuiDir_None && nav_keyboard_active)
11068 scoring_rect_offset_y = NavUpdatePageUpPageDown();
11069 if (scoring_rect_offset_y != 0.0f)
11070 {
11071 g.NavScoringNoClipRect = window->InnerRect;
11072 g.NavScoringNoClipRect.TranslateY(scoring_rect_offset_y);
11073 }
11074
11075 // [DEBUG] Always send a request
11076#if IMGUI_DEBUG_NAV_SCORING
11077 if (io.KeyCtrl && IsKeyPressed(ImGuiKey_C))
11078 g.NavMoveDirForDebug = (ImGuiDir)((g.NavMoveDirForDebug + 1) & 3);
11079 if (io.KeyCtrl && g.NavMoveDir == ImGuiDir_None)
11080 {
11081 g.NavMoveDir = g.NavMoveDirForDebug;
11082 g.NavMoveFlags |= ImGuiNavMoveFlags_DebugNoResult;
11083 }
11084#endif
11085
11086 // Submit
11087 g.NavMoveForwardToNextFrame = false;

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected