Use common functionality to get frame set name.

This commit is contained in:
Bartosz Taudul 2022-07-30 19:32:25 +02:00
parent 92871ba75a
commit b19f9e1f4d
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
8 changed files with 39 additions and 14 deletions

View File

@ -845,7 +845,7 @@ bool View::DrawImpl()
{
ImGui::PushStyleColor( ImGuiCol_Text, GImGui->Style.Colors[ImGuiCol_TextDisabled] );
}
ImGui::Text( "%s: %s", m_frames->name == 0 ? "Frames" : m_worker.GetString( m_frames->name ), RealToString( m_worker.GetFrameCount( *m_frames ) ) );
ImGui::Text( "%s: %s", GetFrameSetName( *m_frames ), RealToString( m_worker.GetFrameCount( *m_frames ) ) );
if( !vis )
{
ImGui::PopStyleColor();
@ -861,7 +861,7 @@ bool View::DrawImpl()
for( auto& fd : frames )
{
bool isSelected = m_frames == fd;
if( ImGui::Selectable( fd->name == 0 ? "Frames" : m_worker.GetString( fd->name ), isSelected ) )
if( ImGui::Selectable( GetFrameSetName( *fd ), isSelected ) )
{
m_frames = fd;
}

View File

@ -303,6 +303,8 @@ private:
const ZoneEvent* FindZoneAtTime( uint64_t thread, int64_t time ) const;
uint64_t GetFrameNumber( const FrameData& fd, int i, uint64_t offset ) const;
const char* GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint64_t offset ) const;
const char* GetFrameSetName( const FrameData& fd ) const;
static const char* GetFrameSetName( const FrameData& fd, const Worker& worker );
#ifndef TRACY_NO_STATISTICS
void FindZones();

View File

@ -405,7 +405,7 @@ void View::DrawCompare()
int idx = 0;
for( auto& v : f0 )
{
const auto name = m_worker.GetString( v->name );
const auto name = GetFrameSetName( *v );
ImGui::PushID( -1 - idx );
ImGui::RadioButton( name, &m_compare.selMatch[0], idx++ );
ImGui::SameLine();
@ -418,7 +418,7 @@ void View::DrawCompare()
idx = 0;
for( auto& v : f1 )
{
const auto name = m_compare.second->GetString( v->name );
const auto name = GetFrameSetName( *v, *m_compare.second );
ImGui::PushID( idx );
ImGui::RadioButton( name, &m_compare.selMatch[1], idx++ );
ImGui::SameLine();
@ -435,8 +435,8 @@ void View::DrawCompare()
if( m_compare.link )
{
auto string0 = m_worker.GetString( f0[m_compare.selMatch[0]]->name );
auto string1 = m_compare.second->GetString( f1[m_compare.selMatch[1]]->name );
auto string0 = GetFrameSetName( *f0[m_compare.selMatch[0]] );
auto string1 = GetFrameSetName( *f1[m_compare.selMatch[1]], *m_compare.second );
if( strcmp( string0, string1 ) != 0 )
{
@ -445,7 +445,7 @@ void View::DrawCompare()
{
for( auto& v : f1 )
{
auto string = m_compare.second->GetString( v->name );
auto string = GetFrameSetName( *v, *m_compare.second );
if( strcmp( string0, string ) == 0 )
{
m_compare.selMatch[1] = idx;
@ -459,7 +459,7 @@ void View::DrawCompare()
assert( prev1 != m_compare.selMatch[1] );
for( auto& v : f0 )
{
auto string = m_worker.GetString( v->name );
auto string = GetFrameSetName( *v );
if( strcmp( string1, string ) == 0 )
{
m_compare.selMatch[0] = idx;

View File

@ -185,7 +185,7 @@ void View::DrawFrames()
}
else
{
ImGui::TextDisabled( "%s:", m_worker.GetString( m_frames->name ) );
ImGui::TextDisabled( "%s:", GetFrameSetName( *m_frames ) );
ImGui::SameLine();
ImGui::TextUnformatted( RealToString( fnum ) );
ImGui::Separator();

View File

@ -320,7 +320,7 @@ void View::DrawTimelineFrames( const FrameData& frames )
ImGui::BeginTooltip();
TextDisabledUnformatted( "Frame set:" );
ImGui::SameLine();
ImGui::TextUnformatted( frames.name == 0 ? "Frames" : m_worker.GetString( frames.name ) );
ImGui::TextUnformatted( GetFrameSetName( frames ) );
ImGui::EndTooltip();
}
if( IsMouseClicked( 0 ) )

View File

@ -701,7 +701,7 @@ void View::DrawOptions()
for( const auto& fd : m_worker.GetFrames() )
{
ImGui::PushID( idx++ );
SmallCheckbox( fd->name == 0 ? "Frames" : m_worker.GetString( fd->name ), &Vis( fd ).visible );
SmallCheckbox( GetFrameSetName( *fd ), &Vis( fd ).visible );
ImGui::PopID();
ImGui::SameLine();
ImGui::TextDisabled( "%s %sframes", RealToString( fd->frames.size() ), fd->continuous ? "" : "discontinuous " );

View File

@ -188,7 +188,7 @@ void View::DrawInfo()
auto fsz = m_worker.GetFullFrameCount( *m_frames );
if( fsz != 0 )
{
TextFocused( "Frame set:", m_frames->name == 0 ? "Frames" : m_worker.GetString( m_frames->name ) );
TextFocused( "Frame set:", GetFrameSetName( *m_frames ) );
ImGui::SameLine();
ImGui::TextDisabled( "(%s)", m_frames->continuous ? "continuous" : "discontinuous" );
ImGui::SameLine();
@ -199,7 +199,7 @@ void View::DrawInfo()
for( auto& fd : frames )
{
bool isSelected = m_frames == fd;
if( ImGui::Selectable( fd->name == 0 ? "Frames" : m_worker.GetString( fd->name ), isSelected ) )
if( ImGui::Selectable( GetFrameSetName( *fd ), isSelected ) )
{
m_frames = fd;
fsz = m_worker.GetFullFrameCount( *m_frames );

View File

@ -1,3 +1,5 @@
#include <inttypes.h>
#include "TracyColor.hpp"
#include "TracyPrint.hpp"
#include "TracyView.hpp"
@ -791,11 +793,32 @@ const char* View::GetFrameText( const FrameData& fd, int i, uint64_t ftime, uint
}
else
{
sprintf( buf, "%s %s (%s)", m_worker.GetString( fd.name ), RealToString( fnum ), TimeToString( ftime ) );
sprintf( buf, "%s %s (%s)", GetFrameSetName( fd ), RealToString( fnum ), TimeToString( ftime ) );
}
return buf;
}
const char* View::GetFrameSetName( const FrameData& fd ) const
{
return GetFrameSetName( fd, m_worker );
}
const char* View::GetFrameSetName( const FrameData& fd, const Worker& worker )
{
enum { Pool = 4 };
static char bufpool[Pool][64];
static int bufsel = 0;
if( fd.name == 0 )
{
return "Frames";
}
else
{
return worker.GetString( fd.name );
}
}
const char* View::ShortenNamespace( const char* name ) const
{
if( m_namespace == Namespace::Full ) return name;