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(); + } + } } } }