From f9e860f559d03abe766d6ed9cd1d2e13a5944502 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 13 Oct 2019 15:59:48 +0200 Subject: [PATCH] Display annotation text on timeline. --- server/TracyView.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index f4fd0835..5de1ea4b 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -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(); + } + } } } }