From 81dcd2c7678f189d23fe77c4c3436e38620e0774 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 14 Nov 2020 16:23:35 +0100 Subject: [PATCH] Optional namespace shortening for ghost zones. --- server/TracyView.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 5ea7629d..9de7d947 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -4081,13 +4081,19 @@ int View::DrawGhostLevel( const Vector& vec, bool hover, double pxns, const auto& sym = frame->data[ghostKey.inlineFrame]; const auto isInline = ghostKey.inlineFrame != frame->size-1; const auto col = isInline ? DarkenColor( color ) : color; - const auto symName = m_worker.GetString( sym.name ); + auto symName = m_worker.GetString( sym.name ); uint32_t txtColor = symName[0] == '[' ? 0xFF999999 : 0xFFFFFFFF; - const auto tsz = ImGui::CalcTextSize( symName ); + auto tsz = ImGui::CalcTextSize( symName ); draw->AddRectFilled( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ), col ); draw->AddRect( wpos + ImVec2( px0, offset ), wpos + ImVec2( px1, offset + tsz.y ), outline, 0.f, -1 ); + if( tsz.x > zsz ) + { + symName = ShortenNamespace( symName ); + tsz = ImGui::CalcTextSize( symName ); + } + if( tsz.x < zsz ) { const auto x = ( ev.start.Val() - m_vd.zvStart ) * pxns + ( ( end - ev.start.Val() ) * pxns - tsz.x ) / 2;