1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Push timline context to Draw and DrawContents functions.

This commit is contained in:
Bartosz Taudul
2023-03-14 02:24:23 +01:00
parent b6b6e1edcf
commit c81ef177ab
11 changed files with 21 additions and 20 deletions
+6 -5
View File
@@ -19,7 +19,7 @@ TimelineItem::TimelineItem( View& view, Worker& worker, const void* key, bool wa
{
}
void TimelineItem::Draw( bool firstFrame, double pxns, int yOffset, const ImVec2& wpos, bool hover, float yMin, float yMax )
void TimelineItem::Draw( bool firstFrame, const TimelineContext& ctx, int yOffset, bool hover, float yMin, float yMax )
{
const auto yBegin = yOffset;
auto yEnd = yOffset;
@@ -31,9 +31,10 @@ void TimelineItem::Draw( bool firstFrame, double pxns, int yOffset, const ImVec2
}
if( IsEmpty() ) return;
const auto w = ImGui::GetContentRegionAvail().x - 1;
const auto ty = ImGui::GetTextLineHeight();
const auto w = ctx.w;
const auto ty = ctx.ty;
const auto ostep = ty + 1;
const auto& wpos = ctx.wpos;
const auto yPos = wpos.y + yBegin;
const auto dpos = wpos + ImVec2( 0.5f, 0.5f );
auto draw = ImGui::GetWindowDrawList();
@@ -44,7 +45,7 @@ void TimelineItem::Draw( bool firstFrame, double pxns, int yOffset, const ImVec2
yEnd += ostep;
if( m_showFull )
{
if( !DrawContents( pxns, yEnd, wpos, hover, yMin, yMax ) && !m_view.GetViewData().drawEmptyLabels )
if( !DrawContents( ctx, yEnd, hover, yMin, yMax ) && !m_view.GetViewData().drawEmptyLabels )
{
yEnd = yBegin;
AdjustThreadHeight( firstFrame, yBegin, yEnd );
@@ -79,7 +80,7 @@ void TimelineItem::Draw( bool firstFrame, double pxns, int yOffset, const ImVec2
if( m_showFull )
{
DrawLine( draw, dpos + ImVec2( 0, hdrOffset + ty - 1 ), dpos + ImVec2( w, hdrOffset + ty - 1 ), HeaderLineColor() );
HeaderExtraContents( hdrOffset, wpos, labelWidth, pxns, hover );
HeaderExtraContents( hdrOffset, wpos, labelWidth, ctx.pxns, hover );
}
if( hover && ImGui::IsMouseHoveringRect( wpos + ImVec2( 0, hdrOffset ), wpos + ImVec2( ty + labelWidth, hdrOffset + ty ) ) )