Nav: Fixed NavRectRel being cleared for one frame when restoring layer 0 with Alt/Menu key or Escape. Maybe was inconsequential. (#787)

This commit is contained in:
omar 2018-01-30 18:34:32 +01:00
parent 1ed7bce3ed
commit 9fc6f5907b

View File

@ -2248,6 +2248,16 @@ static bool NavScoreItem(ImGuiNavMoveResult* result, ImRect cand)
return new_best; return new_best;
} }
static void NavRestoreLayer(int layer)
{
ImGuiContext& g = *GImGui;
g.NavLayer = layer;
if (layer == 0 && g.NavWindow->NavLastIds[0] != 0)
SetNavIDAndMoveMouse(g.NavWindow->NavLastIds[0], layer, g.NavWindow->NavRectRel[0]);
else
ImGui::NavInitWindow(g.NavWindow, true);
}
static inline void NavUpdateAnyRequestFlag() static inline void NavUpdateAnyRequestFlag()
{ {
ImGuiContext& g = *GImGui; ImGuiContext& g = *GImGui;
@ -2825,13 +2835,9 @@ static void ImGui::NavUpdateWindowing()
{ {
if ((g.NavWindow->DC.NavLayerActiveMask & (1 << 1)) == 0 && (g.NavWindow->RootWindow->DC.NavLayerActiveMask & (1 << 1)) != 0) if ((g.NavWindow->DC.NavLayerActiveMask & (1 << 1)) == 0 && (g.NavWindow->RootWindow->DC.NavLayerActiveMask & (1 << 1)) != 0)
FocusWindow(g.NavWindow->RootWindow); FocusWindow(g.NavWindow->RootWindow);
g.NavLayer = (g.NavWindow->DC.NavLayerActiveMask & (1 << 1)) ? (g.NavLayer ^ 1) : 0;
g.NavDisableHighlight = false; g.NavDisableHighlight = false;
g.NavDisableMouseHover = true; g.NavDisableMouseHover = true;
if (g.NavLayer == 0 && g.NavWindow->NavLastIds[0] != 0) NavRestoreLayer((g.NavWindow->DC.NavLayerActiveMask & (1 << 1)) ? (g.NavLayer ^ 1) : 0);
SetNavIDAndMoveMouse(g.NavWindow->NavLastIds[0], g.NavLayer, ImRect());
else
NavInitWindow(g.NavWindow, true);
} }
} }
@ -2971,11 +2977,7 @@ static void ImGui::NavUpdate()
else if (g.NavLayer != 0) else if (g.NavLayer != 0)
{ {
// Leave the "menu" layer // Leave the "menu" layer
g.NavLayer = 0; NavRestoreLayer(0);
if (g.NavWindow->NavLastIds[0])
SetNavIDAndMoveMouse(g.NavWindow->NavLastIds[0], g.NavLayer, ImRect());
else
NavInitWindow(g.NavWindow, true);
} }
else else
{ {