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

Display annotation text on timeline.

This commit is contained in:
Bartosz Taudul 2019-10-13 15:59:48 +02:00
parent 1527e7bc10
commit f9e860f559

View File

@ -2577,7 +2577,8 @@ void View::DrawZones()
TextFocused( "Annotation length:", TimeToString( ann->end - ann->start ) );
ImGui::EndTooltip();
}
if( ( ann->end - ann->start ) * pxns > th * 4 )
const auto aw = ( ann->end - ann->start ) * pxns;
if( aw > th * 4 )
{
draw->AddCircleFilled( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns + th * 2, th * 2 ), th, 0x88AABB22 );
draw->AddCircle( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns + th * 2, th * 2 ), th, 0xAAAABB22 );
@ -2585,6 +2586,21 @@ void View::DrawZones()
{
m_selectedAnnotation = ann.get();
}
if( !ann->text.empty() )
{
const auto tw = ImGui::CalcTextSize( ann->text.c_str() ).x;
if( aw - th*4 > tw )
{
draw->AddText( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns + th * 4, th * 0.5 ), 0xFFFFFFFF, ann->text.c_str() );
}
else
{
draw->PushClipRect( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->end - m_vd.zvStart ) * pxns, lineh ), true );
draw->AddText( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns + th * 4, th * 0.5 ), 0xFFFFFFFF, ann->text.c_str() );
draw->PopClipRect();
}
}
}
}
}