diff --git a/server/TracyTimelineController.cpp b/server/TracyTimelineController.cpp index a8ca0189..3546246e 100644 --- a/server/TracyTimelineController.cpp +++ b/server/TracyTimelineController.cpp @@ -1,7 +1,6 @@ #include -#include "imgui.h" - +#include "TracyImGui.hpp" #include "TracyTimelineController.hpp" namespace tracy @@ -107,11 +106,19 @@ void TimelineController::End( double pxns, const ImVec2& wpos, bool hover, bool UpdateCenterItem(); } + TimelineContext ctx; + ctx.w = ImGui::GetContentRegionAvail().x - 1; + ctx.ty = ImGui::GetTextLineHeight(); + ctx.scale = GetScale(); + ctx.pxns = pxns; + ctx.nspx = 1.0 / pxns; + ctx.wpos = wpos; + for( auto& item : m_items ) { if( item->WantPreprocess() && item->IsVisible() ) { - item->Preprocess(); + item->Preprocess( ctx ); } } diff --git a/server/TracyTimelineItem.hpp b/server/TracyTimelineItem.hpp index f5f53beb..310525c1 100644 --- a/server/TracyTimelineItem.hpp +++ b/server/TracyTimelineItem.hpp @@ -12,6 +12,13 @@ namespace tracy class View; class Worker; +struct TimelineContext +{ + float w, ty, scale; + double pxns, nspx; + ImVec2 wpos; +}; + class TimelineItem { public: @@ -22,7 +29,7 @@ public: void Draw( bool firstFrame, double pxns, int yOffset, const ImVec2& wpos, bool hover, float yMin, float yMax ); bool WantPreprocess() const { return m_wantPreprocess; } - virtual void Preprocess() { assert( false ); } + virtual void Preprocess( const TimelineContext& ctx ) { assert( false ); } void VisibilityCheckbox(); virtual void SetVisible( bool visible ) { m_visible = visible; }