diff --git a/profiler/src/profiler/TracyTimelineDraw.hpp b/profiler/src/profiler/TracyTimelineDraw.hpp index dd827bdf..6add8e9c 100644 --- a/profiler/src/profiler/TracyTimelineDraw.hpp +++ b/profiler/src/profiler/TracyTimelineDraw.hpp @@ -63,6 +63,7 @@ struct MessagesDraw { short_ptr msg; bool highlight; + bool selected; uint32_t num; }; diff --git a/profiler/src/profiler/TracyTimelineItemThread.cpp b/profiler/src/profiler/TracyTimelineItemThread.cpp index f7ba9e75..b7684f72 100644 --- a/profiler/src/profiler/TracyTimelineItemThread.cpp +++ b/profiler/src/profiler/TracyTimelineItemThread.cpp @@ -741,6 +741,8 @@ void TimelineItemThread::PreprocessMessages( const TimelineContext& ctx, const V const auto hMsg = m_view.GetMessageHighlight(); const auto hThread = hMsg ? m_worker.DecompressThread( hMsg->thread ) : 0; + const auto sMsg = m_view.GetMessageSelected(); + const auto sThread = sMsg ? m_worker.DecompressThread( sMsg->thread ) : 0; while( it < end ) { @@ -748,24 +750,11 @@ void TimelineItemThread::PreprocessMessages( const TimelineContext& ctx, const V const auto nextTime = msgTime + MinVisNs; const auto next = std::upper_bound( it, vec.end(), nextTime, [] ( const auto& lhs, const auto& rhs ) { return lhs < rhs->time; } ); const auto num = next - it; - bool hilite; - if( num == 1 ) - { - hilite = hMsg == *it; - } - else - { - if( hMsg && hThread == tid ) - { - const auto hTime = hMsg->time; - hilite = (*it)->time <= hTime && ( next == vec.end() || (*next)->time > hTime ); - } - else - { - hilite = false; - } - } - m_msgDraw.emplace_back( MessagesDraw { *it, hilite, uint32_t( num ) } ); + const auto contains = [&] ( const MessageData* msg, uint64_t thread ) { + if( num == 1 ) return msg == *it; + return msg && thread == tid && (*it)->time <= msg->time && ( next == vec.end() || (*next)->time > msg->time ); + }; + m_msgDraw.emplace_back( MessagesDraw { *it, contains( hMsg, hThread ), contains( sMsg, sThread ), uint32_t( num ) } ); it = next; } } diff --git a/profiler/src/profiler/TracyView.hpp b/profiler/src/profiler/TracyView.hpp index a2ce6c01..7f834ac4 100644 --- a/profiler/src/profiler/TracyView.hpp +++ b/profiler/src/profiler/TracyView.hpp @@ -189,6 +189,7 @@ public: int GetNextGpuIdx() { return m_gpuIdx++; } const MessageData* GetMessageHighlight() const { return m_msgHighlight; } + const MessageData* GetMessageSelected() const { return m_showMessages ? m_msgSelected : nullptr; } uint32_t GetLockInfoWindow() const { return m_lockInfoWindow; } const std::string& GetFilename() const { return m_filename; } @@ -583,6 +584,7 @@ private: DecayValue m_msgHighlight = nullptr; DecayValue m_lockHoverHighlight = InvalidId; DecayValue m_msgToFocus = nullptr; + const MessageData* m_msgSelected = nullptr; const GpuEvent* m_gpuInfoWindow = nullptr; const GpuEvent* m_gpuHighlight = nullptr; uint64_t m_gpuInfoWindowThread; diff --git a/profiler/src/profiler/TracyView_Messages.cpp b/profiler/src/profiler/TracyView_Messages.cpp index 670fc207..cedd6256 100644 --- a/profiler/src/profiler/TracyView_Messages.cpp +++ b/profiler/src/profiler/TracyView_Messages.cpp @@ -357,10 +357,17 @@ void View::DrawMessageLine( const MessageData& msg, bool hasCallstack, int& idx const auto text = m_worker.GetString( msg.ref ); const auto tid = m_worker.DecompressThread( msg.thread ); ImGui::PushID( &msg ); - if( ImGui::Selectable( TimeToStringExact( msg.time ), m_msgHighlight == &msg, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap ) ) + const bool highlight = m_msgHighlight == &msg; + const bool selected = highlight || m_msgSelected == &msg; + ImGui::PushStyleColor( ImGuiCol_Header, highlight ? 0x664444FF : 0x6644DDFF ); + ImGui::PushStyleColor( ImGuiCol_HeaderHovered, 0x664444FF ); + ImGui::PushStyleColor( ImGuiCol_HeaderActive, 0x664444FF ); + if( ImGui::Selectable( TimeToStringExact( msg.time ), selected, ImGuiSelectableFlags_SpanAllColumns | ImGuiSelectableFlags_AllowOverlap ) ) { + m_msgSelected = &msg; CenterAtTime( msg.time ); } + ImGui::PopStyleColor( 3 ); if( ImGui::IsItemHovered() ) { m_msgHighlight = &msg; diff --git a/profiler/src/profiler/TracyView_ZoneInfo.cpp b/profiler/src/profiler/TracyView_ZoneInfo.cpp index 91e25cd9..4ec9e119 100644 --- a/profiler/src/profiler/TracyView_ZoneInfo.cpp +++ b/profiler/src/profiler/TracyView_ZoneInfo.cpp @@ -924,10 +924,17 @@ void View::DrawZoneInfoWindow() ImGui::PushID( *msgit ); ImGui::TableNextRow(); ImGui::TableNextColumn(); - if( ImGui::Selectable( m_messageTimeRelativeToZone ? TimeToString( (*msgit)->time - ev.Start() ) : TimeToStringExact( (*msgit)->time ), m_msgHighlight == *msgit, ImGuiSelectableFlags_SpanAllColumns ) ) + const bool highlight = m_msgHighlight == *msgit; + const bool selected = highlight || GetMessageSelected() == *msgit; + ImGui::PushStyleColor( ImGuiCol_Header, highlight ? 0x664444FF : 0x6644DDFF ); + ImGui::PushStyleColor( ImGuiCol_HeaderHovered, 0x664444FF ); + ImGui::PushStyleColor( ImGuiCol_HeaderActive, 0x664444FF ); + if( ImGui::Selectable( m_messageTimeRelativeToZone ? TimeToString( (*msgit)->time - ev.Start() ) : TimeToStringExact( (*msgit)->time ), selected, ImGuiSelectableFlags_SpanAllColumns ) ) { + m_msgSelected = *msgit; CenterAtTime( (*msgit)->time ); } + ImGui::PopStyleColor( 3 ); if( ImGui::IsItemHovered() ) { m_msgHighlight = *msgit; diff --git a/profiler/src/profiler/TracyView_ZoneTimeline.cpp b/profiler/src/profiler/TracyView_ZoneTimeline.cpp index f8eb8f6e..1472acbb 100644 --- a/profiler/src/profiler/TracyView_ZoneTimeline.cpp +++ b/profiler/src/profiler/TracyView_ZoneTimeline.cpp @@ -124,9 +124,9 @@ void View::DrawThreadMessagesList( const TimelineContext& ctx, const std::vector unsigned int color = 0xFFDDDDDD; float animOff = 0; - if( v.highlight ) + if( v.highlight || v.selected ) { - color = 0xFF4444FF; + color = v.highlight ? 0xFF4444FF : 0xFF44DDFF; if( !isMsgHovered ) { animOff = -fabs( sin( s_time * 8 ) ) * th; @@ -165,6 +165,7 @@ void View::DrawThreadMessagesList( const TimelineContext& ctx, const std::vector { m_showMessages = true; m_msgToFocus = &msg; + m_msgSelected = &msg; } if( IsMouseClicked( ImGuiMouseButton_Middle ) ) {