mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 07:54:36 +00:00
Extract normalized name tooltip function.
This commit is contained in:
parent
63d074c5d8
commit
4d0591cf2f
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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 ); }
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user