diff --git a/server/TracyUtility.cpp b/server/TracyUtility.cpp index 684637f5..0c230035 100644 --- a/server/TracyUtility.cpp +++ b/server/TracyUtility.cpp @@ -117,4 +117,24 @@ const char* ShortenZoneName( ShortenName type, const char* name, ImVec2& tsz, fl } } +void TooltipNormalizedName( const char* name, const char* normalized ) +{ + if( ImGui::IsItemHovered() && normalized != name && strcmp( normalized, name ) != 0 ) + { + const auto scale = ImGui::GetTextLineHeight() / 15.f; + if( ImGui::CalcTextSize( name ).x > 1400 * scale ) + { + ImGui::SetNextWindowSize( ImVec2( 1400 * scale, 0 ) ); + ImGui::BeginTooltip(); + ImGui::TextWrapped( "%s", name ); + } + else + { + ImGui::BeginTooltip(); + ImGui::TextUnformatted( name ); + } + ImGui::EndTooltip(); + } +} + } diff --git a/server/TracyUtility.hpp b/server/TracyUtility.hpp index b757b022..dae771f8 100644 --- a/server/TracyUtility.hpp +++ b/server/TracyUtility.hpp @@ -18,6 +18,7 @@ enum class ShortenName : uint8_t }; const char* ShortenZoneName( ShortenName type, const char* name, ImVec2& tsz, float zsz ); +void TooltipNormalizedName( const char* name, const char* normalized ); static inline const char* ShortenZoneName( ShortenName type, const char* name ) { ImVec2 tsz = {}; return ShortenZoneName( type, name, tsz, 0 ); } diff --git a/server/TracyView_Callstack.cpp b/server/TracyView_Callstack.cpp index ff02cd24..e3746f22 100644 --- a/server/TracyView_Callstack.cpp +++ b/server/TracyView_Callstack.cpp @@ -216,21 +216,7 @@ void View::DrawCallstackTable( uint32_t callstack, bool globalEntriesButton ) { const auto normalized = ShortenZoneName( ShortenName::OnlyNormalize, txt ); ImGui::TextUnformatted( normalized ); - if( ImGui::IsItemHovered() && normalized != txt && strcmp( normalized, txt ) != 0 ) - { - if( ImGui::CalcTextSize( txt ).x > 1400 * GetScale() ) - { - ImGui::SetNextWindowSize( ImVec2( 1400 * GetScale(), 0 ) ); - ImGui::BeginTooltip(); - ImGui::TextWrapped( "%s", txt ); - } - else - { - ImGui::BeginTooltip(); - ImGui::TextUnformatted( txt ); - } - ImGui::EndTooltip(); - } + TooltipNormalizedName( txt, normalized ); } ImGui::PopTextWrapPos(); }