Show trace description/filename on titlebar.

This commit is contained in:
Bartosz Taudul 2023-06-29 23:53:37 +02:00
parent 0cb6d8588b
commit 57bd63dab6
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
5 changed files with 30 additions and 1 deletions

1
NEWS
View File

@ -40,6 +40,7 @@ v0.x.x (xxxx-xx-xx)
a kind.
- Fixed compatibility problems with FreeBSD.
- Added support for dynamically loaded Vulkan symbols.
- Trace description or filename is now displayed on the window title bar.
v0.9.1 (2023-02-26)

View File

@ -671,7 +671,7 @@ bool View::DrawImpl()
if( !m_titleSet && m_stcb )
{
m_titleSet = true;
m_stcb( m_worker.GetCaptureName().c_str() );
UpdateTitle();
}
ImGuiViewport* viewport = ImGui::GetMainViewport();

View File

@ -363,6 +363,7 @@ private:
bool Save( const char* fn, FileWrite::Compression comp, int zlevel, bool buildDict );
void Attention( bool& alreadyDone );
void UpdateTitle();
unordered_flat_map<uint64_t, bool> m_visibleMsgThread;
unordered_flat_map<uint64_t, bool> m_waitStackThread;

View File

@ -61,6 +61,7 @@ void View::DrawInfo()
if( ImGui::InputTextWithHint( "##traceDesc", "Enter description of the trace", buf, 256 ) )
{
m_userData.SetDescription( buf );
if( m_stcb ) UpdateTitle();
}
}

View File

@ -870,4 +870,30 @@ void View::Attention( bool& alreadyDone )
}
}
void View::UpdateTitle()
{
auto captureName = m_worker.GetCaptureName().c_str();
const auto& desc = m_userData.GetDescription();
if( !desc.empty() )
{
char buf[1024];
snprintf( buf, 1024, "%s (%s)", captureName, desc.c_str() );
m_stcb( buf );
}
else if( !m_filename.empty() )
{
auto fptr = m_filename.c_str() + m_filename.size() - 1;
while( fptr > m_filename.c_str() && *fptr != '/' && *fptr != '\\' ) fptr--;
if( *fptr == '/' || *fptr == '\\' ) fptr++;
char buf[1024];
snprintf( buf, 1024, "%s (%s)", captureName, fptr );
m_stcb( buf );
}
else
{
m_stcb( captureName );
}
}
}