mirror of
https://github.com/ocornut/imgui.git
synced 2024-11-23 23:31:08 +01:00
Nav: fixed Ctrl+Tab so when starting with no focused window it starts from the top-most window. (#3200)
This commit is contained in:
parent
b001038901
commit
626d358e55
@ -68,8 +68,10 @@ Other changes:
|
||||
- IO: WantCaptureKeyboard is never set when ImGuiConfigFlags_NoKeyboard is enabled. (#4921)
|
||||
- Error Handling: turned a few more functions into recoverable errors. (#1651)
|
||||
- Nav: added io.ConfigNavEscapeClearFocusWindow to clear focused window on Escape. (#3200)
|
||||
- Nav: pressing escape to hide nav highlight doesn't clear location from when ctrl+tabbing back
|
||||
into same window later.
|
||||
- Nav: pressing escape to hide nav highlight doesn't clear location from when ctrl+tabbing
|
||||
back into same window later.
|
||||
- Nav: fixed Ctrl+Tab so when starting with no focused window it starts from the top-most
|
||||
window. (#3200)
|
||||
- DrawList: AddCallback() added an optional size parameter allowing to copy and
|
||||
store any amount of user data for usage by callbacks: (#6969, #4770, #7665)
|
||||
- If userdata_size == 0: we copy/store the 'userdata' argument as-is (existing behavior).
|
||||
|
15
imgui.cpp
15
imgui.cpp
@ -13540,7 +13540,7 @@ static ImGuiWindow* FindWindowNavFocusable(int i_start, int i_stop, int dir) //
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void NavUpdateWindowingHighlightWindow(int focus_change_dir)
|
||||
static void NavUpdateWindowingTarget(int focus_change_dir)
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
IM_ASSERT(g.NavWindowingTarget);
|
||||
@ -13592,14 +13592,17 @@ static void ImGui::NavUpdateWindowing()
|
||||
const bool keyboard_prev_window = allow_windowing && g.ConfigNavWindowingKeyPrev && Shortcut(g.ConfigNavWindowingKeyPrev, ImGuiInputFlags_Repeat | ImGuiInputFlags_RouteAlways, owner_id);
|
||||
const bool start_windowing_with_gamepad = allow_windowing && nav_gamepad_active && !g.NavWindowingTarget && IsKeyPressed(ImGuiKey_NavGamepadMenu, ImGuiInputFlags_None);
|
||||
const bool start_windowing_with_keyboard = allow_windowing && !g.NavWindowingTarget && (keyboard_next_window || keyboard_prev_window); // Note: enabled even without NavEnableKeyboard!
|
||||
bool just_started_windowing_from_null_focus = false;
|
||||
if (start_windowing_with_gamepad || start_windowing_with_keyboard)
|
||||
if (ImGuiWindow* window = g.NavWindow ? g.NavWindow : FindWindowNavFocusable(g.WindowsFocusOrder.Size - 1, -INT_MAX, -1))
|
||||
{
|
||||
g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow;
|
||||
g.NavWindowingTarget = g.NavWindowingTargetAnim = window->RootWindow; // Current location
|
||||
g.NavWindowingTimer = g.NavWindowingHighlightAlpha = 0.0f;
|
||||
g.NavWindowingAccumDeltaPos = g.NavWindowingAccumDeltaSize = ImVec2(0.0f, 0.0f);
|
||||
g.NavWindowingToggleLayer = start_windowing_with_gamepad ? true : false; // Gamepad starts toggling layer
|
||||
g.NavInputSource = start_windowing_with_keyboard ? ImGuiInputSource_Keyboard : ImGuiInputSource_Gamepad;
|
||||
if (g.NavWindow == NULL)
|
||||
just_started_windowing_from_null_focus = true;
|
||||
|
||||
// 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.
|
||||
if (keyboard_next_window || keyboard_prev_window)
|
||||
@ -13615,9 +13618,9 @@ static void ImGui::NavUpdateWindowing()
|
||||
|
||||
// Select window to focus
|
||||
const int focus_change_dir = (int)IsKeyPressed(ImGuiKey_GamepadL1) - (int)IsKeyPressed(ImGuiKey_GamepadR1);
|
||||
if (focus_change_dir != 0)
|
||||
if (focus_change_dir != 0 && !just_started_windowing_from_null_focus)
|
||||
{
|
||||
NavUpdateWindowingHighlightWindow(focus_change_dir);
|
||||
NavUpdateWindowingTarget(focus_change_dir);
|
||||
g.NavWindowingHighlightAlpha = 1.0f;
|
||||
}
|
||||
|
||||
@ -13640,8 +13643,8 @@ static void ImGui::NavUpdateWindowing()
|
||||
ImGuiKeyChord shared_mods = ((g.ConfigNavWindowingKeyNext ? g.ConfigNavWindowingKeyNext : ImGuiMod_Mask_) & (g.ConfigNavWindowingKeyPrev ? g.ConfigNavWindowingKeyPrev : ImGuiMod_Mask_)) & ImGuiMod_Mask_;
|
||||
IM_ASSERT(shared_mods != 0); // Next/Prev shortcut currently needs a shared modifier to "hold", otherwise Prev actions would keep cycling between two windows.
|
||||
g.NavWindowingHighlightAlpha = ImMax(g.NavWindowingHighlightAlpha, ImSaturate((g.NavWindowingTimer - NAV_WINDOWING_HIGHLIGHT_DELAY) / 0.05f)); // 1.0f
|
||||
if (keyboard_next_window || keyboard_prev_window)
|
||||
NavUpdateWindowingHighlightWindow(keyboard_next_window ? -1 : +1);
|
||||
if ((keyboard_next_window || keyboard_prev_window) && !just_started_windowing_from_null_focus)
|
||||
NavUpdateWindowingTarget(keyboard_next_window ? -1 : +1);
|
||||
else if ((io.KeyMods & shared_mods) != shared_mods)
|
||||
apply_focus_window = g.NavWindowingTarget;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user