Skip to content

Commit 08e20ae

Browse files
committed
Internals: Reintroducing LastActiveIdTimer because it is useful and to reduce merge conflicts. (#1537)
1 parent d4b1510 commit 08e20ae

2 files changed

Lines changed: 12 additions & 0 deletions

File tree

‎imgui.cpp‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2115,7 +2115,14 @@ void ImGui::SetActiveID(ImGuiID id, ImGuiWindow* window)
21152115
ImGuiContext& g = *GImGui;
21162116
g.ActiveIdIsJustActivated = (g.ActiveId != id);
21172117
if (g.ActiveIdIsJustActivated)
2118+
{
21182119
g.ActiveIdTimer = 0.0f;
2120+
if (id != 0)
2121+
{
2122+
g.LastActiveId = id;
2123+
g.LastActiveIdTimer = 0.0f;
2124+
}
2125+
}
21192126
g.ActiveId = id;
21202127
g.ActiveIdAllowNavDirFlags = 0;
21212128
g.ActiveIdAllowOverlap = false;
@@ -3568,6 +3575,7 @@ void ImGui::NewFrame()
35683575
ClearActiveID();
35693576
if (g.ActiveId)
35703577
g.ActiveIdTimer += g.IO.DeltaTime;
3578+
g.LastActiveIdTimer += g.IO.DeltaTime;
35713579
g.ActiveIdPreviousFrame = g.ActiveId;
35723580
g.ActiveIdIsAlive = false;
35733581
g.ActiveIdIsJustActivated = false;

‎imgui_internal.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,8 @@ struct ImGuiContext
627627
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
628628
ImGuiWindow* ActiveIdWindow;
629629
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
630+
ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
631+
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
630632
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
631633
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
632634
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
@@ -762,6 +764,8 @@ struct ImGuiContext
762764
ActiveIdClickOffset = ImVec2(-1,-1);
763765
ActiveIdWindow = NULL;
764766
ActiveIdSource = ImGuiInputSource_None;
767+
LastActiveId = 0;
768+
LastActiveIdTimer = 0.0f;
765769
MovingWindow = NULL;
766770
NextTreeNodeOpenVal = false;
767771
NextTreeNodeOpenCond = 0;

0 commit comments

Comments
 (0)
⌂ 换网址