MCPcopy Create free account
hub / github.com/IppClub/Dora-SSR / NavUpdateWindowing

Method NavUpdateWindowing

Source/3rdParty/imgui/imgui.cpp:14544–14738  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

14542// Keyboard: Ctrl+Tab (change focus/move/resize), Alt (toggle menu layer)
14543// Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer)
14544static void ImGui::NavUpdateWindowing()
14545{
14546 ImGuiContext& g = *GImGui;
14547 ImGuiIO& io = g.IO;
14548
14549 ImGuiWindow* apply_focus_window = NULL;
14550 bool apply_toggle_layer = false;
14551
14552 ImGuiWindow* modal_window = GetTopMostPopupModal();
14553 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.
14554 if (!allow_windowing)
14555 g.NavWindowingTarget = NULL;
14556
14557 // Fade out
14558 if (g.NavWindowingTargetAnim && g.NavWindowingTarget == NULL)
14559 {
14560 g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha - io.DeltaTime * 10.0f, 0.0f);
14561 if (g.DimBgRatio <= 0.0f && g.NavWindowingHighlightAlpha <= 0.0f)
14562 g.NavWindowingTargetAnim = NULL;
14563 }
14564
14565 // Start Ctrl+Tab or Square+L/R window selection
14566 // (g.ConfigNavWindowingKeyNext/g.ConfigNavWindowingKeyPrev defaults are ImGuiMod_Ctrl|ImGuiKey_Tab and ImGuiMod_Ctrl|ImGuiMod_Shift|ImGuiKey_Tab)
14567 const ImGuiID owner_id = ImHashStr("##NavUpdateWindowing");
14568 const bool nav_gamepad_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableGamepad) != 0 && (io.BackendFlags & ImGuiBackendFlags_HasGamepad) != 0;
14569 const bool nav_keyboard_active = (io.ConfigFlags & ImGuiConfigFlags_NavEnableKeyboard) != 0;
14570 const bool keyboard_next_window = allow_windowing && g.ConfigNavWindowingKeyNext && Shortcut(g.ConfigNavWindowingKeyNext, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways, owner_id);
14571 const bool keyboard_prev_window = allow_windowing && g.ConfigNavWindowingKeyPrev && Shortcut(g.ConfigNavWindowingKeyPrev, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways, owner_id);
14572 const bool start_toggling_with_gamepad = nav_gamepad_active && !g.NavWindowingTarget && Shortcut(ImGuiKey_NavGamepadMenu, ImGuiInputFlags_RouteAlways, owner_id);
14573 const bool start_windowing_with_gamepad = allow_windowing && start_toggling_with_gamepad;
14574 const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && (keyboard_next_window || keyboard_prev_window); // Note: enabled even without NavEnableKeyboard!
14575 bool just_started_windowing_from_null_focus = false;
14576 if (start_toggling_with_gamepad)
14577 {
14578 g.NavWindowingToggleLayer = true; // Gamepad starts toggling layer
14579 g.NavWindowingToggleKey = ImGuiKey_NavGamepadMenu;
14580 g.NavWindowingInputSource = g.NavInputSource = ImGuiInputSource_Gamepad;
14581 }
14582 if (start_windowing_with_gamepad || start_windowing_with_keyboard)
14583 if (ImGuiWindow* window = (g.NavWindow && IsWindowNavFocusable(g.NavWindow)) ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
14584 {
14585 if (start_windowing_with_keyboard || g.ConfigNavWindowingWithGamepad)
14586 g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; // Current location
14587 g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
14588 g.NavWindowingAccumDeltaPos = g.NavWindowingAccumDeltaSize = ImVec2(0.0f, 0.0f);
14589 g.NavWindowingInputSource = g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_Keyboard : ImGuiInputSource_Gamepad;
14590 if (g.NavWindow == NULL)
14591 just_started_windowing_from_null_focus = true;
14592
14593 // Manually register ownership of our mods. Using a global route in the Shortcut() calls instead would probably be correct but may have more side-effects.
14594 if (keyboard_next_window || keyboard_prev_window)
14595 SetKeyOwnersForKeyChord((g.ConfigNavWindowingKeyNext | g.ConfigNavWindowingKeyPrev) & ImGuiMod_Mask_, owner_id);
14596 }
14597
14598 // Gamepad update
14599 if ((g.NavWindowingTarget || g.NavWindowingToggleLayer) && g.NavWindowingInputSource == ImGuiInputSource_Gamepad)
14600 {
14601 if (g.NavWindowingTarget != NULL)

Callers

nothing calls this directly

Calls 10

ImMaxFunction · 0.85
ImHashStrFunction · 0.85
ShortcutClass · 0.85
FindWindowNavFocusableFunction · 0.85
ImVec2Function · 0.85
ImSaturateFunction · 0.85
NavUpdateWindowingTargetFunction · 0.85
GetScaleFunction · 0.85
ImTruncFunction · 0.85
SetWindowPosFunction · 0.85

Tested by

no test coverage detected