From 7d142622028108314d174af8025dacb368ef5605 Mon Sep 17 00:00:00 2001 From: omar Date: Mon, 16 Oct 2017 00:33:30 +0200 Subject: [PATCH] Nav: SetFocusID() update NavWindow and NavRectRel just as we get them. Needed by upcoming commit, committing separately as I'm curious if it has any side-effect. (#787) --- imgui.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/imgui.cpp b/imgui.cpp index 4a1bf07d..39e55a57 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1980,14 +1980,20 @@ ImGuiID ImGui::GetActiveID() return g.ActiveId; } -// Assume that SetFocusID() is called in the context where its NavLayer is the current window nav layer. void ImGui::SetFocusID(ImGuiID id, ImGuiWindow* window) { IM_ASSERT(id != 0); ImGuiContext& g = *GImGui; + + // Assume that SetActiveID() is called in the context where its NavLayer is the current layer, which is the case everywhere we call it. + const int nav_layer = window->DC.NavLayerCurrent; g.NavId = id; - g.NavLayer = window->DC.NavLayerCurrent; - window->NavLastIds[window->DC.NavLayerCurrent] = id; + g.NavWindow = window; + g.NavLayer = nav_layer; + window->NavLastIds[nav_layer] = id; + if (window->DC.LastItemId == id) + window->NavRectRel[nav_layer] = ImRect(window->DC.LastItemRect.Min - window->Pos, window->DC.LastItemRect.Max - window->Pos); + if (g.ActiveIdSource == ImGuiInputSource_Nav) g.NavDisableMouseHover = true; else