Use tables in messages list.

This commit is contained in:
Bartosz Taudul 2020-12-08 02:15:50 +01:00
parent 45078cd99d
commit b4860bbe4d

View File

@ -9214,69 +9214,51 @@ void View::DrawMessages()
bool hasCallstack = m_worker.GetCallstackFrameCount() != 0; bool hasCallstack = m_worker.GetCallstackFrameCount() != 0;
ImGui::Separator(); ImGui::Separator();
ImGui::BeginChild( "##messages" ); ImGui::BeginChild( "##messages" );
const auto w = ImGui::GetWindowWidth();
static int widthSet = 0;
const int colNum = hasCallstack ? 4 : 3; const int colNum = hasCallstack ? 4 : 3;
ImGui::Columns( colNum ); if( ImGui::BeginTable( "##messages", colNum, ImGuiTableFlags_Resizable | ImGuiTableFlags_Reorderable | ImGuiTableFlags_ScrollY ) )
if( widthSet != colNum )
{ {
widthSet = colNum; ImGui::TableSetupScrollFreeze( 0, 1 );
ImGui::SetColumnWidth( 0, w * 0.1f ); ImGui::TableSetupColumn( "Time", ImGuiTableColumnFlags_WidthAutoResize );
ImGui::SetColumnWidth( 1, w * 0.13f ); ImGui::TableSetupColumn( "Thread" );
ImGui::SetColumnWidth( 2, w * ( hasCallstack ? 0.57f : 0.77f ) ); ImGui::TableSetupColumn( "Message" );
if( hasCallstack ) if( hasCallstack ) ImGui::TableSetupColumn( "Call stack" );
{ ImGui::TableHeadersRow();
ImGui::SetColumnWidth( 3, w * 0.2f );
}
}
ImGui::TextUnformatted( "Time" );
ImGui::SameLine();
DrawHelpMarker( "Click on message to center timeline on it." );
ImGui::NextColumn();
ImGui::TextUnformatted( "Thread" );
ImGui::NextColumn();
ImGui::TextUnformatted( "Message" );
ImGui::NextColumn();
if( hasCallstack )
{
ImGui::TextUnformatted( "Call stack" );
ImGui::NextColumn();
}
ImGui::Separator();
int idx = 0; int idx = 0;
if( m_msgToFocus ) if( m_msgToFocus )
{
for( const auto& msgIdx : m_msgList )
{ {
DrawMessageLine( *msgs[msgIdx], hasCallstack, idx ); for( const auto& msgIdx : m_msgList )
}
}
else
{
ImGuiListClipper clipper;
clipper.Begin( m_msgList.size() );
while( clipper.Step() )
{
for( auto i=clipper.DisplayStart; i<clipper.DisplayEnd; i++ )
{ {
DrawMessageLine( *msgs[m_msgList[i]], hasCallstack, idx ); DrawMessageLine( *msgs[msgIdx], hasCallstack, idx );
}
}
else
{
ImGuiListClipper clipper;
clipper.Begin( m_msgList.size() );
while( clipper.Step() )
{
for( auto i=clipper.DisplayStart; i<clipper.DisplayEnd; i++ )
{
DrawMessageLine( *msgs[m_msgList[i]], hasCallstack, idx );
}
} }
} }
}
if( m_worker.IsConnected() && ImGui::GetScrollY() >= ImGui::GetScrollMaxY() ) if( m_worker.IsConnected() && ImGui::GetScrollY() >= ImGui::GetScrollMaxY() )
{ {
ImGui::SetScrollHereY( 1.f ); ImGui::SetScrollHereY( 1.f );
}
ImGui::EndTable();
} }
ImGui::EndColumns();
ImGui::EndChild(); ImGui::EndChild();
ImGui::End(); ImGui::End();
} }
void View::DrawMessageLine( const MessageData& msg, bool hasCallstack, int& idx ) void View::DrawMessageLine( const MessageData& msg, bool hasCallstack, int& idx )
{ {
ImGui::TableNextRow();
ImGui::TableNextColumn();
const auto text = m_worker.GetString( msg.ref ); const auto text = m_worker.GetString( msg.ref );
const auto tid = m_worker.DecompressThread( msg.thread ); const auto tid = m_worker.DecompressThread( msg.thread );
ImGui::PushID( &msg ); ImGui::PushID( &msg );
@ -9320,13 +9302,13 @@ void View::DrawMessageLine( const MessageData& msg, bool hasCallstack, int& idx
m_messagesScrollBottom = false; m_messagesScrollBottom = false;
} }
ImGui::PopID(); ImGui::PopID();
ImGui::NextColumn(); ImGui::TableNextColumn();
SmallColorBox( GetThreadColor( tid, 0 ) ); SmallColorBox( GetThreadColor( tid, 0 ) );
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextUnformatted( m_worker.GetThreadName( tid ) ); ImGui::TextUnformatted( m_worker.GetThreadName( tid ) );
ImGui::SameLine(); ImGui::SameLine();
ImGui::TextDisabled( "(%s)", RealToString( tid ) ); ImGui::TextDisabled( "(%s)", RealToString( tid ) );
ImGui::NextColumn(); ImGui::TableNextColumn();
ImGui::PushStyleColor( ImGuiCol_Text, msg.color ); ImGui::PushStyleColor( ImGuiCol_Text, msg.color );
const auto cw = ImGui::GetContentRegionAvail().x; const auto cw = ImGui::GetContentRegionAvail().x;
const auto tw = ImGui::CalcTextSize( text ).x; const auto tw = ImGui::CalcTextSize( text ).x;
@ -9339,9 +9321,9 @@ void View::DrawMessageLine( const MessageData& msg, bool hasCallstack, int& idx
ImGui::EndTooltip(); ImGui::EndTooltip();
} }
ImGui::PopStyleColor(); ImGui::PopStyleColor();
ImGui::NextColumn();
if( hasCallstack ) if( hasCallstack )
{ {
ImGui::TableNextColumn();
const auto cs = msg.callstack.Val(); const auto cs = msg.callstack.Val();
if( cs != 0 ) if( cs != 0 )
{ {
@ -9349,7 +9331,6 @@ void View::DrawMessageLine( const MessageData& msg, bool hasCallstack, int& idx
ImGui::SameLine(); ImGui::SameLine();
DrawCallstackCalls( cs, 4 ); DrawCallstackCalls( cs, 4 );
} }
ImGui::NextColumn();
} }
} }