mirror of
https://github.com/Drezil/imgui.git
synced 2024-11-15 01:17:00 +00:00
Nav: Fixed handling of ImGuiNavInput_KeyMenu so it doesn't set g.NavWindowingTarget at all, reducing size effects + handling menu layer toggle on Alt Release (#787)
This commit is contained in:
parent
6f0aa766e1
commit
be12f8c55d
21
imgui.cpp
21
imgui.cpp
@ -2664,11 +2664,13 @@ static ImVec2 GetNavInputAmount2d(int stick_no, ImGuiNavReadMode mode, float slo
|
||||
return delta;
|
||||
}
|
||||
|
||||
// Window management mode (change focus, move/resize window, jump back and forth to menu layer)
|
||||
// Window management mode (change focus, move/resize window, toggle menu layer)
|
||||
static void ImGui::NavUpdateWindowing()
|
||||
{
|
||||
ImGuiContext& g = *GImGui;
|
||||
if (!g.NavWindowingTarget && (IsNavInputPressed(ImGuiNavInput_PadMenu, ImGuiNavReadMode_Pressed) || IsNavInputPressed(ImGuiNavInput_KeyMenu, ImGuiNavReadMode_Pressed)))
|
||||
bool toggle_layer = false;
|
||||
|
||||
if (!g.NavWindowingTarget && IsNavInputPressed(ImGuiNavInput_PadMenu, ImGuiNavReadMode_Pressed))
|
||||
{
|
||||
ImGuiWindow* window = g.NavWindow;
|
||||
if (!window)
|
||||
@ -2713,7 +2715,7 @@ static void ImGui::NavUpdateWindowing()
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsNavInputDown(ImGuiNavInput_PadMenu) && !IsNavInputDown(ImGuiNavInput_KeyMenu))
|
||||
if (!IsNavInputDown(ImGuiNavInput_PadMenu))
|
||||
{
|
||||
// Apply actual focus only when releasing the NavMenu button (until then the window was merely rendered front-most)
|
||||
if (g.NavWindowingTarget && !g.NavWindowingToggleLayer && (!g.NavWindow || g.NavWindowingTarget != g.NavWindow->RootNonPopupWindow))
|
||||
@ -2727,6 +2729,16 @@ static void ImGui::NavUpdateWindowing()
|
||||
|
||||
// Single press toggles NavLayer
|
||||
if (g.NavWindowingToggleLayer && g.NavWindow)
|
||||
toggle_layer = true;
|
||||
g.NavWindowingTarget = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
// Keyboard: Press and release ALT to toggle menu
|
||||
if ((g.ActiveId == 0 || g.ActiveIdAllowOverlap) && IsNavInputPressed(ImGuiNavInput_KeyMenu, ImGuiNavReadMode_Released))
|
||||
toggle_layer = true;
|
||||
|
||||
if (toggle_layer && g.NavWindow)
|
||||
{
|
||||
if ((g.NavWindow->DC.NavLayerActiveMask & (1 << 1)) == 0 && (g.NavWindow->RootWindow->DC.NavLayerActiveMask & (1 << 1)) != 0)
|
||||
FocusWindow(g.NavWindow->RootWindow);
|
||||
@ -2738,9 +2750,6 @@ static void ImGui::NavUpdateWindowing()
|
||||
else
|
||||
NavInitWindow(g.NavWindow, true);
|
||||
}
|
||||
g.NavWindowingTarget = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// NB: We modify rect_rel by the amount we scrolled for, so it is immediately updated.
|
||||
|
Loading…
Reference in New Issue
Block a user