Skip to content

Commit

Permalink
Internals: Reintroducing LastActiveIdTimer because it is useful and t…
Browse files Browse the repository at this point in the history
…o reduce merge conflicts. (#1537)
  • Loading branch information
ocornut committed May 28, 2018
1 parent d4b1510 commit 08e20ae
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2115,7 +2115,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.ActiveIdAllowNavDirFlags = 0;
g.ActiveIdAllowOverlap = false;
Expand Down Expand Up @@ -3568,6 +3575,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;
Expand Down
4 changes: 4 additions & 0 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -627,6 +627,8 @@ struct ImGuiContext
ImVec2 ActiveIdClickOffset; // Clicked offset from upper-left corner, if applicable (currently only set by ButtonBehavior)
ImGuiWindow* ActiveIdWindow;
ImGuiInputSource ActiveIdSource; // Activating with mouse or nav (gamepad/keyboard)
ImGuiID LastActiveId; // Store the last non-zero ActiveId, useful for animation.
float LastActiveIdTimer; // Store the last non-zero ActiveId timer since the beginning of activation, useful for animation.
ImGuiWindow* MovingWindow; // Track the window we clicked on (in order to preserve focus). The actually window that is moved is generally MovingWindow->RootWindow.
ImVector<ImGuiColMod> ColorModifiers; // Stack for PushStyleColor()/PopStyleColor()
ImVector<ImGuiStyleMod> StyleModifiers; // Stack for PushStyleVar()/PopStyleVar()
Expand Down Expand Up @@ -762,6 +764,8 @@ struct ImGuiContext
ActiveIdClickOffset = ImVec2(-1,-1);
ActiveIdWindow = NULL;
ActiveIdSource = ImGuiInputSource_None;
LastActiveId = 0;
LastActiveIdTimer = 0.0f;
MovingWindow = NULL;
NextTreeNodeOpenVal = false;
NextTreeNodeOpenCond = 0;
Expand Down

0 comments on commit 08e20ae

Please sign in to comment.