From 526e41b5dceb9416e7979d43970a52a02a37652f Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 7 Feb 2025 02:43:32 +0100 Subject: [PATCH] Don't show image tooltip, if there's no shortening and it fits the space. --- profiler/src/profiler/TracyView_Samples.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/profiler/src/profiler/TracyView_Samples.cpp b/profiler/src/profiler/TracyView_Samples.cpp index 7abe45ec..72bb95ad 100644 --- a/profiler/src/profiler/TracyView_Samples.cpp +++ b/profiler/src/profiler/TracyView_Samples.cpp @@ -524,11 +524,14 @@ void View::DrawSamplesStatistics( Vector& data, int64_t timeRange, Accu ImGui::TableNextColumn(); if( m_shortImageNames ) { - const char* end = imageName + strlen( imageName ) - 1; - while( end > imageName && *end != '/' && *end != '\\' ) end--; - if( *end == '/' || *end == '\\' ) end++; - TextDisabledUnformatted( end ); - TooltipIfHovered( imageName ); + const char* end = imageName + strlen( imageName ); + const char* ptr = end - 1; + while( ptr > imageName && *ptr != '/' && *ptr != '\\' ) ptr--; + if( *ptr == '/' || *ptr == '\\' ) ptr++; + const auto cw = ImGui::GetContentRegionAvail().x; + const auto tw = ImGui::CalcTextSize( imageName, end ).x; + TextDisabledUnformatted( ptr ); + if( ptr != imageName || tw > cw ) TooltipIfHovered( imageName ); } else {