Windowing management mode Keyboard: CTRL+Tab (change focus/move/resize), Alt (toggle menu layer) Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer)
| 12057 | // Keyboard: CTRL+Tab (change focus/move/resize), Alt (toggle menu layer) |
| 12058 | // Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer) |
| 12059 | static void ImGui::NavUpdateWindowing() |
| 12060 | { |
| 12061 | ImGuiContext& g = *GImGui; |
| 12062 | ImGuiIO& io = g.IO; |
| 12063 | |
| 12064 | ImGuiWindow* apply_focus_window = NULL; |
| 12065 | bool apply_toggle_layer = false; |
| 12066 | |
| 12067 | ImGuiWindow* modal_window = GetTopMostPopupModal(); |
| 12068 | bool allow_windowing = (modal_window == NULL); // FIXME: This prevent CTRL+TAB from being usable with windows that are inside the Begin-stack of that modal. |
| 12069 | if (!allow_windowing) |
| 12070 | g.NavWindowingTarget = NULL; |
| 12071 | |
| 12072 | // Fade out |
| 12073 | if (g.NavWindowingTargetAnim && g.NavWindowingTarget == NULL) |
| 12074 | { |
| 12075 | g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha - io.DeltaTime * 10.0f, 0.0f); |
| 12076 | if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f) |
| 12077 | g.NavWindowingTargetAnim = NULL; |
| 12078 | } |
| 12079 | |
| 12080 | // Start CTRL+Tab or Square+L/R window selection |
| 12081 | const ImGuiID owner_id = ImHashStr("###NavUpdateWindowing"); |
| 12082 | const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0; |
| 12083 | const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0; |
| 12084 | const bool keyboard_next_window = allow_windowing && g.ConfigNavWindowingKeyNext && Shortcut(g.ConfigNavWindowingKeyNext, owner_id, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways); |
| 12085 | const bool keyboard_prev_window = allow_windowing && g.ConfigNavWindowingKeyPrev && Shortcut(g.ConfigNavWindowingKeyPrev, owner_id, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways); |
| 12086 | const bool start_windowing_with_gamepad = allow_windowing && nav_gamepad_active && !g.NavWindowingTarget && IsKeyPressed(ImGuiKey_NavGamepadMenu, 0, ImGuiInputFlags_None); |
| 12087 | const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && (keyboard_next_window || keyboard_prev_window); // Note: enabled even without NavEnableKeyboard! |
| 12088 | if (start_windowing_with_gamepad || start_windowing_with_keyboard) |
| 12089 | if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1)) |
| 12090 | { |
| 12091 | g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; |
| 12092 | g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f; |
| 12093 | g.NavWindowingAccumDeltaPos = g.NavWindowingAccumDeltaSize = ImVec2(0.0f, 0.0f); |
| 12094 | g.NavWindowingToggleLayer = start_windowing_with_gamepad ? true : false; // Gamepad starts toggling layer |
| 12095 | g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_Keyboard : ImGuiInputSource_Gamepad; |
| 12096 | |
| 12097 | // Register ownership of our mods. Using ImGuiInputFlags_RouteGlobalHigh in the Shortcut() calls instead would probably be correct but may have more side-effects. |
| 12098 | if (keyboard_next_window || keyboard_prev_window) |
| 12099 | SetKeyOwnersForKeyChord((g.ConfigNavWindowingKeyNext | g.ConfigNavWindowingKeyPrev) & ImGuiMod_Mask_, owner_id); |
| 12100 | } |
| 12101 | |
| 12102 | // Gamepad update |
| 12103 | g.NavWindowingTimer += io.DeltaTime; |
| 12104 | if (g.NavWindowingTarget && g.NavInputSource == ImGuiInputSource_Gamepad) |
| 12105 | { |
| 12106 | // Highlight only appears after a brief time holding the button, so that a fast tap on PadMenu (to toggle NavLayer) doesn't add visual noise |
| 12107 | g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); |
| 12108 | |
| 12109 | // Select window to focus |
| 12110 | const int focus_change_dir = (int)IsKeyPressed(ImGuiKey_GamepadL1) - (int)IsKeyPressed(ImGuiKey_GamepadR1); |
| 12111 | if (focus_change_dir != 0) |
| 12112 | { |
| 12113 | NavUpdateWindowingHighlightWindow(focus_change_dir); |
| 12114 | g.NavWindowingHighlightAlpha = 1.0f; |
| 12115 | } |
| 12116 |
nothing calls this directly
no test coverage detected