diff --git a/imgui.cpp b/imgui.cpp index 3728a890e..82dc2d6ef 100644 --- a/imgui.cpp +++ b/imgui.cpp @@ -1929,7 +1929,14 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window) ImGuiContext& g = *GImGui; g.ActiveIdIsJustActivated = (g.ActiveId != id); if (g.ActiveIdIsJustActivated) + { g.ActiveIdTimer = 0.0f; + if (id != 0) + { + g.LastActiveId = id; + g.LastActiveIdTimer = 0.0f; + } + } g.ActiveId = id; g.ActiveIdAllowOverlap = false; g.ActiveIdIsAlive |= (id != 0); @@ -2308,6 +2315,7 @@ void ImGui::NewFrame() ClearActiveID(); if (g.ActiveId) g.ActiveIdTimer += g.IO.DeltaTime; + g.LastActiveIdTimer += g.IO.DeltaTime; g.ActiveIdPreviousFrame = g.ActiveId; g.ActiveIdIsAlive = false; g.ActiveIdIsJustActivated = false; diff --git a/imgui_internal.h b/imgui_internal.h index c80970250..cfc84437f 100644 --- a/imgui_internal.h +++ b/imgui_internal.h @@ -533,6 +533,8 @@ struct ImGuiContext bool ActiveIdAllowOverlap; // Active widget allows another widget to steal active id (generally for overlapping widgets, but not always) ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior) ImGuiWindow* ActiveIdWindow; + ImGuiID LastActiveId; // Store the last non-zero ActiveID, useful for animation. + float LastActiveIdTimer; ImGuiWindow* MovingWindow; // Track the child window we clicked on to move a window. ImGuiID MovingWindowMoveId; // == MovingWindow->MoveId ImVector ColorModifiers; // Stack for PushStyleColor()/PopStyleColor() @@ -629,6 +631,8 @@ struct ImGuiContext ActiveIdAllowOverlap = false; ActiveIdClickOffset = ImVec2(-1,-1); ActiveIdWindow = NULL; + LastActiveId = 0; + LastActiveIdTimer = 0.0f; MovingWindow = NULL; MovingWindowMoveId = 0;