From 4914ef6b14838f6e164dc59fdcc3b3421b5dba25 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 17 Mar 2019 16:33:18 +0100 Subject: [PATCH] Display zone messages in zone info window. --- server/TracyView.cpp | 66 +++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 65 insertions(+), 1 deletion(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 93f7e44e..7124bdc9 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -4335,7 +4335,9 @@ void View::DrawZoneInfoWindow() ImGui::Separator(); - const auto tid = GetZoneThread( ev ); + auto threadData = GetZoneThreadData( ev ); + assert( threadData ); + const auto tid = threadData->id; if( ev.name.active ) { TextFocused( "Zone name:", m_worker.GetString( ev.name ) ); @@ -4486,6 +4488,68 @@ void View::DrawZoneInfoWindow() } } + ImGui::Separator(); + { + if( threadData->messages.empty() ) + { + TextDisabledUnformatted( "No messages" ); + } + else + { + auto msgit = std::lower_bound( threadData->messages.begin(), threadData->messages.end(), ev.start, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } ); + auto msgend = std::lower_bound( msgit, threadData->messages.end(), end+1, [] ( const auto& lhs, const auto& rhs ) { return lhs->time < rhs; } ); + + const auto dist = std::distance( msgit, msgend ); + if( dist == 0 ) + { + TextDisabledUnformatted( "No messages" ); + } + else + { + bool expand = ImGui::TreeNode( "Messages" ); + ImGui::SameLine(); + ImGui::TextDisabled( "(%s)", RealToString( dist, true ) ); + if( expand ) + { + static bool widthSet = false; + ImGui::Columns( 2 ); + if( !widthSet ) + { + widthSet = true; + const auto w = ImGui::GetWindowWidth(); + ImGui::SetColumnWidth( 0, w * 0.2f ); + ImGui::SetColumnWidth( 1, w * 0.8f ); + } + TextDisabledUnformatted( "Time" ); + ImGui::NextColumn(); + TextDisabledUnformatted( "Message" ); + ImGui::NextColumn(); + ImGui::Separator(); + do + { + ImGui::PushID( *msgit ); + if( ImGui::Selectable( TimeToString( (*msgit)->time - ev.start ), m_msgHighlight == *msgit, ImGuiSelectableFlags_SpanAllColumns ) ) + { + CenterAtTime( (*msgit)->time ); + } + if( ImGui::IsItemHovered() ) + { + m_msgHighlight = *msgit; + } + ImGui::PopID(); + ImGui::NextColumn(); + ImGui::TextWrapped( "%s", m_worker.GetString( (*msgit)->ref ) ); + ImGui::NextColumn(); + } + while( ++msgit != msgend ); + ImGui::EndColumns(); + ImGui::TreePop(); + ImGui::Spacing(); + } + } + } + } + ImGui::Separator(); std::vector zoneTrace;