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:
parent
4944efa51f
commit
eceff55f5a
@ -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,52 +5760,61 @@ 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 ) )
|
||||||
{
|
{
|
||||||
ImGui::PushID( v );
|
const auto text = m_worker.GetString( v->ref );
|
||||||
if( ImGui::Selectable( TimeToString( v->time - m_worker.GetTimeBegin() ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) )
|
if( !filterActive || m_messageFilter.PassFilter( text ) )
|
||||||
{
|
{
|
||||||
CenterAtTime( v->time );
|
ImGui::PushID( v );
|
||||||
|
if( ImGui::Selectable( TimeToString( v->time - m_worker.GetTimeBegin() ), m_msgHighlight == v, ImGuiSelectableFlags_SpanAllColumns ) )
|
||||||
|
{
|
||||||
|
CenterAtTime( v->time );
|
||||||
|
}
|
||||||
|
if( ImGui::IsItemHovered() )
|
||||||
|
{
|
||||||
|
m_msgHighlight = v;
|
||||||
|
}
|
||||||
|
if( m_msgToFocus == v )
|
||||||
|
{
|
||||||
|
ImGui::SetScrollHereY();
|
||||||
|
m_msgToFocus = nullptr;
|
||||||
|
}
|
||||||
|
ImGui::PopID();
|
||||||
|
ImGui::NextColumn();
|
||||||
|
ImGui::TextUnformatted( m_worker.GetThreadString( v->thread ) );
|
||||||
|
ImGui::SameLine();
|
||||||
|
ImGui::TextDisabled( "(0x%" PRIX64 ")", v->thread );
|
||||||
|
ImGui::NextColumn();
|
||||||
|
ImGui::PushStyleColor( ImGuiCol_Text, v->color );
|
||||||
|
ImGui::TextWrapped( "%s", text );
|
||||||
|
ImGui::PopStyleColor();
|
||||||
|
ImGui::NextColumn();
|
||||||
}
|
}
|
||||||
if( ImGui::IsItemHovered() )
|
|
||||||
{
|
|
||||||
m_msgHighlight = v;
|
|
||||||
}
|
|
||||||
if( m_msgToFocus == v )
|
|
||||||
{
|
|
||||||
ImGui::SetScrollHereY();
|
|
||||||
m_msgToFocus = nullptr;
|
|
||||||
}
|
|
||||||
ImGui::PopID();
|
|
||||||
ImGui::NextColumn();
|
|
||||||
ImGui::TextUnformatted( m_worker.GetThreadString( v->thread ) );
|
|
||||||
ImGui::SameLine();
|
|
||||||
ImGui::TextDisabled( "(0x%" PRIX64 ")", v->thread );
|
|
||||||
ImGui::NextColumn();
|
|
||||||
ImGui::PushStyleColor( ImGuiCol_Text, v->color );
|
|
||||||
ImGui::TextWrapped( "%s", m_worker.GetString( v->ref ) );
|
|
||||||
ImGui::PopStyleColor();
|
|
||||||
ImGui::NextColumn();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto maxScroll = ImGui::GetScrollMaxY();
|
if( !filterActive )
|
||||||
if( maxScroll != 0 )
|
|
||||||
{
|
{
|
||||||
const auto msgssize = msgs.size();
|
const auto maxScroll = ImGui::GetScrollMaxY();
|
||||||
if( m_prevMessages == msgssize )
|
if( maxScroll != 0 )
|
||||||
{
|
{
|
||||||
m_messagesScrollBottom = ImGui::GetScrollY() == maxScroll;
|
const auto msgssize = msgs.size();
|
||||||
}
|
if( m_prevMessages == msgssize && !m_messageFilterWasActive )
|
||||||
else
|
{
|
||||||
{
|
m_messagesScrollBottom = ImGui::GetScrollY() == maxScroll;
|
||||||
m_prevMessages = msgssize;
|
}
|
||||||
if( m_messagesScrollBottom ) ImGui::SetScrollHereY();
|
else
|
||||||
|
{
|
||||||
|
m_prevMessages = msgssize;
|
||||||
|
if( m_messagesScrollBottom ) ImGui::SetScrollHereY();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
m_messageFilterWasActive = filterActive;
|
||||||
|
|
||||||
ImGui::EndColumns();
|
ImGui::EndColumns();
|
||||||
ImGui::EndChild();
|
ImGui::EndChild();
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user