Keep the message clicked on the timeline selected.

Clicking a message marker on the timeline now selects that message, in addition to opening the messages window and scrolling to it. The selection persists until another message is clicked, and is only shown while the messages window is open.

- The selected message is drawn in yellow, both as a row in the messages and zone info lists and as a bouncing marker on the timeline. Hover keeps its red color and takes priority.
- Clicking a row in the messages list or in the zone info message list also selects it.
This commit is contained in:
Clément Grégoire
2026-11-10 18:32:09 +01:00
parent 5aa31f077c
commit 0e8cc9c865
6 changed files with 29 additions and 22 deletions
@@ -63,6 +63,7 @@ struct MessagesDraw
{
short_ptr<MessageData> msg;
bool highlight;
bool selected;
uint32_t num;
};
@@ -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;
}
}
+2
View File
@@ -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<const MessageData*> m_msgHighlight = nullptr;
DecayValue<uint32_t> m_lockHoverHighlight = InvalidId;
DecayValue<const MessageData*> m_msgToFocus = nullptr;
const MessageData* m_msgSelected = nullptr;
const GpuEvent* m_gpuInfoWindow = nullptr;
const GpuEvent* m_gpuHighlight = nullptr;
uint64_t m_gpuInfoWindowThread;
+8 -1
View File
@@ -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;
+8 -1
View File
@@ -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;
@@ -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 ) )
{