Nav: extract code into a NavUpdateWindowingApplyFocus() so it may be reused elsewhere.
This commit is contained in:
@@ -1212,6 +1212,7 @@ static void UpdateWindowInFocusOrderList(ImGuiWindow* window, bool j
|
|||||||
// Navigation
|
// Navigation
|
||||||
static void NavUpdate();
|
static void NavUpdate();
|
||||||
static void NavUpdateWindowing();
|
static void NavUpdateWindowing();
|
||||||
|
static void NavUpdateWindowingApplyFocus(ImGuiWindow* window);
|
||||||
static void NavUpdateWindowingOverlay();
|
static void NavUpdateWindowingOverlay();
|
||||||
static void NavUpdateCancelRequest();
|
static void NavUpdateCancelRequest();
|
||||||
static void NavUpdateCreateMoveRequest();
|
static void NavUpdateCreateMoveRequest();
|
||||||
@@ -13651,6 +13652,33 @@ static void NavUpdateWindowingTarget(int focus_change_dir)
|
|||||||
g.NavWindowingToggleLayer = false;
|
g.NavWindowingToggleLayer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Apply focus and close overlay
|
||||||
|
static void ImGui::NavUpdateWindowingApplyFocus(ImGuiWindow* apply_focus_window)
|
||||||
|
{
|
||||||
|
ImGuiContext& g = *GImGui;
|
||||||
|
if (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow)
|
||||||
|
{
|
||||||
|
ClearActiveID();
|
||||||
|
SetNavCursorVisibleAfterMove();
|
||||||
|
ClosePopupsOverWindow(apply_focus_window, false);
|
||||||
|
FocusWindow(apply_focus_window, ImGuiFocusRequestFlags_RestoreFocusedChild);
|
||||||
|
apply_focus_window = g.NavWindow;
|
||||||
|
if (apply_focus_window->NavLastIds[0] == 0)
|
||||||
|
NavInitWindow(apply_focus_window, false);
|
||||||
|
|
||||||
|
// If the window has ONLY a menu layer (no main layer), select it directly
|
||||||
|
// Use NavLayersActiveMaskNext since windows didn't have a chance to be Begin()-ed on this frame,
|
||||||
|
// so CTRL+Tab where the keys are only held for 1 frame will be able to use correct layers mask since
|
||||||
|
// the target window as already been previewed once.
|
||||||
|
// FIXME-NAV: This should be done in NavInit.. or in FocusWindow... However in both of those cases,
|
||||||
|
// we won't have a guarantee that windows has been visible before and therefore NavLayersActiveMask*
|
||||||
|
// won't be valid.
|
||||||
|
if (apply_focus_window->DC.NavLayersActiveMaskNext == (1 << ImGuiNavLayer_Menu))
|
||||||
|
g.NavLayer = ImGuiNavLayer_Menu;
|
||||||
|
}
|
||||||
|
g.NavWindowingTarget = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// Windowing management mode
|
// Windowing management mode
|
||||||
// Keyboard: CTRL+Tab (change focus/move/resize), Alt (toggle menu layer)
|
// 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)
|
// Gamepad: Hold Menu/Square (change focus/move/resize), Tap Menu/Square (toggle menu layer)
|
||||||
@@ -13802,28 +13830,8 @@ static void ImGui::NavUpdateWindowing()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Apply final focus
|
// Apply final focus
|
||||||
if (apply_focus_window && (g.NavWindow == NULL || apply_focus_window != g.NavWindow->RootWindow))
|
|
||||||
{
|
|
||||||
ClearActiveID();
|
|
||||||
SetNavCursorVisibleAfterMove();
|
|
||||||
ClosePopupsOverWindow(apply_focus_window, false);
|
|
||||||
FocusWindow(apply_focus_window, ImGuiFocusRequestFlags_RestoreFocusedChild);
|
|
||||||
apply_focus_window = g.NavWindow;
|
|
||||||
if (apply_focus_window->NavLastIds[0] == 0)
|
|
||||||
NavInitWindow(apply_focus_window, false);
|
|
||||||
|
|
||||||
// If the window has ONLY a menu layer (no main layer), select it directly
|
|
||||||
// Use NavLayersActiveMaskNext since windows didn't have a chance to be Begin()-ed on this frame,
|
|
||||||
// so CTRL+Tab where the keys are only held for 1 frame will be able to use correct layers mask since
|
|
||||||
// the target window as already been previewed once.
|
|
||||||
// FIXME-NAV: This should be done in NavInit.. or in FocusWindow... However in both of those cases,
|
|
||||||
// we won't have a guarantee that windows has been visible before and therefore NavLayersActiveMask*
|
|
||||||
// won't be valid.
|
|
||||||
if (apply_focus_window->DC.NavLayersActiveMaskNext == (1 << ImGuiNavLayer_Menu))
|
|
||||||
g.NavLayer = ImGuiNavLayer_Menu;
|
|
||||||
}
|
|
||||||
if (apply_focus_window)
|
if (apply_focus_window)
|
||||||
g.NavWindowingTarget = NULL;
|
NavUpdateWindowingApplyFocus(apply_focus_window);
|
||||||
|
|
||||||
// Apply menu/layer toggle
|
// Apply menu/layer toggle
|
||||||
if (apply_toggle_layer && g.NavWindow)
|
if (apply_toggle_layer && g.NavWindow)
|
||||||
|
|||||||
Reference in New Issue
Block a user