From ad5615cda29550953429bf2be36f4f101b049d14 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 7 Feb 2025 17:28:55 +0100 Subject: [PATCH] Short image names in sample entry stacks window. --- profiler/src/profiler/TracyView_Samples.cpp | 25 ++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/profiler/src/profiler/TracyView_Samples.cpp b/profiler/src/profiler/TracyView_Samples.cpp index 99de8945..617a7b5f 100644 --- a/profiler/src/profiler/TracyView_Samples.cpp +++ b/profiler/src/profiler/TracyView_Samples.cpp @@ -959,6 +959,10 @@ void View::DrawSampleParents() ImGui::Spacing(); ImGui::SameLine(); ImGui::PushStyleVar( ImGuiStyleVar_FramePadding, ImVec2( 0, 0 ) ); + ImGui::Checkbox( ICON_FA_SCISSORS " Short images", &m_shortImageNames ); + ImGui::SameLine(); + ImGui::Spacing(); + ImGui::SameLine(); ImGui::TextUnformatted( ICON_FA_AT " Frame location:" ); ImGui::SameLine(); ImGui::RadioButton( "Source code", &m_showCallstackFrameAddress, 0 ); @@ -1181,7 +1185,26 @@ void View::DrawSampleParents() ImGui::TableNextColumn(); if( frameData->imageName.Active() ) { - TextDisabledUnformatted( m_worker.GetString( frameData->imageName ) ); + const char* imageName = m_worker.GetString( frameData->imageName ); + const char* end = imageName + strlen( imageName ); + + if( m_shortImageNames ) + { + 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 + { + const auto cw = ImGui::GetContentRegionAvail().x; + const auto tw = ImGui::CalcTextSize( imageName, end ).x; + TextDisabledUnformatted( imageName ); + if( tw > cw ) TooltipIfHovered( imageName ); + } } } }