1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Add message filtering.

This commit is contained in:
Bartosz Taudul 2019-07-13 01:48:43 +02:00
parent 4944efa51f
commit eceff55f5a
2 changed files with 45 additions and 32 deletions

View File

@ -5686,6 +5686,8 @@ void View::DrawMessages()
size_t tsz = 0; size_t tsz = 0;
for( const auto& t : m_threadOrder ) if( !t->messages.empty() ) tsz++; for( const auto& t : m_threadOrder ) if( !t->messages.empty() ) tsz++;
m_messageFilter.Draw( "Filter messages", 200 );
#ifdef TRACY_EXTENDED_FONT #ifdef TRACY_EXTENDED_FONT
auto expand = ImGui::TreeNode( ICON_FA_RANDOM " Visible threads:" ); auto expand = ImGui::TreeNode( ICON_FA_RANDOM " Visible threads:" );
#else #else
@ -5758,10 +5760,14 @@ void View::DrawMessages()
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Separator(); ImGui::Separator();
const auto filterActive = m_messageFilter.IsActive();
const auto& msgs = m_worker.GetMessages(); const auto& msgs = m_worker.GetMessages();
for( const auto& v : msgs ) for( const auto& v : msgs )
{ {
if( VisibleMsgThread( v->thread ) ) if( VisibleMsgThread( v->thread ) )
{
const auto text = m_worker.GetString( v->ref );
if( !filterActive || m_messageFilter.PassFilter( text ) )
{ {
ImGui::PushID( v ); ImGui::PushID( v );
if( ImGui::Selectable( TimeToString( v->time - m_worker.GetTimeBegin() ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) ) if( ImGui::Selectable( TimeToString( v->time - m_worker.GetTimeBegin() ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) )
@ -5784,17 +5790,20 @@ void View::DrawMessages()
ImGui::TextDisabled( "(0x%" PRIX64 ")", v->thread ); ImGui::TextDisabled( "(0x%" PRIX64 ")", v->thread );
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::PushStyleColor( ImGuiCol_Text, v->color ); ImGui::PushStyleColor( ImGuiCol_Text, v->color );
ImGui::TextWrapped( "%s", m_worker.GetString( v->ref ) ); ImGui::TextWrapped( "%s", text );
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::NextColumn(); ImGui::NextColumn();
} }
} }
}
if( !filterActive )
{
const auto maxScroll = ImGui::GetScrollMaxY(); const auto maxScroll = ImGui::GetScrollMaxY();
if( maxScroll != 0 ) if( maxScroll != 0 )
{ {
const auto msgssize = msgs.size(); const auto msgssize = msgs.size();
if( m_prevMessages == msgssize ) if( m_prevMessages == msgssize && !m_messageFilterWasActive )
{ {
m_messagesScrollBottom = ImGui::GetScrollY() == maxScroll; m_messagesScrollBottom = ImGui::GetScrollY() == maxScroll;
} }
@ -5804,6 +5813,8 @@ void View::DrawMessages()
if( m_messagesScrollBottom ) ImGui::SetScrollHereY(); if( m_messagesScrollBottom ) ImGui::SetScrollHereY();
} }
} }
}
m_messageFilterWasActive = filterActive;
ImGui::EndColumns(); ImGui::EndColumns();
ImGui::EndChild(); ImGui::EndChild();

View File

@ -267,6 +267,8 @@ private:
int m_frameHover = -1; int m_frameHover = -1;
bool m_messagesScrollBottom; bool m_messagesScrollBottom;
size_t m_prevMessages = 0; size_t m_prevMessages = 0;
ImGuiTextFilter m_messageFilter;
bool m_messageFilterWasActive = false;
Region m_highlight; Region m_highlight;
Region m_highlightZoom; Region m_highlightZoom;