From bbb43549a68967e8ae6d63a7b342feca187b9792 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Mon, 29 Jun 2026 16:16:02 +0200 Subject: [PATCH] Move playback "copy from" to a button with a popup menu. --- profiler/src/profiler/TracyView_Playback.cpp | 70 +++++++++++--------- 1 file changed, 39 insertions(+), 31 deletions(-) diff --git a/profiler/src/profiler/TracyView_Playback.cpp b/profiler/src/profiler/TracyView_Playback.cpp index 64fe56cd..07502289 100644 --- a/profiler/src/profiler/TracyView_Playback.cpp +++ b/profiler/src/profiler/TracyView_Playback.cpp @@ -246,6 +246,45 @@ void View::DrawPlayback() { if( m_playback.range.first < 0 ) m_playback.range = { 0, m_worker.GetFrameImageCount() - 1 }; + ImGui::SameLine(); + if( ImGui::SmallButton( ICON_FA_COPY " Copy from" ) ) ImGui::OpenPopup( "playbackCopyFrom" ); + if( ImGui::BeginPopup( "playbackCopyFrom" ) ) + { + if( m_annotations.empty() ) + { + TextDisabledUnformatted( ICON_FA_NOTE_STICKY " Annotation" ); + } + else if( ImGui::BeginMenu( ICON_FA_NOTE_STICKY " Annotation" ) ) + { + for( auto& v : m_annotations ) + { + SmallColorBox( v->color ); + ImGui::SameLine(); + if( ImGui::MenuItem( v->text.empty() ? "" : v->text.c_str() ) ) + { + m_playback.range = GetPlaybackFrameRangeFromTime( v->range.min, v->range.max ); + limitChanged = true; + } + ImGui::SameLine(); + ImGui::TextDisabled( "%s - %s (%s)", TimeToStringExact( v->range.min ), TimeToStringExact( v->range.max ), TimeToString( v->range.max - v->range.min ) ); + } + ImGui::EndMenu(); + } + for( auto& r : m_ranges ) + { + if( r.range->min == 0 && r.range->max == 0 ) + { + TextDisabledUnformatted( r.name ); + } + else if( ImGui::MenuItem( r.name ) ) + { + m_playback.range = GetPlaybackFrameRangeFromTime( r.range->min, r.range->max ); + limitChanged = true; + } + } + ImGui::EndPopup(); + } + ImGui::Indent(); int r0 = m_playback.range.first + 1; int r1 = m_playback.range.second + 1; @@ -254,37 +293,6 @@ void View::DrawPlayback() m_playback.range = { r0 - 1, r1 - 1 }; limitChanged = true; } - - ImGui::TextDisabled( ICON_FA_COPY " Copy from:" ); - ImGui::SameLine(); - if( SmallButtonDisablable( ICON_FA_NOTE_STICKY " Annotation", m_annotations.empty() ) ) ImGui::OpenPopup( "PlaybackRangeAnnotation" ); - if( ImGui::BeginPopup( "PlaybackRangeAnnotation" ) ) - { - for( auto& v : m_annotations ) - { - SmallColorBox( v->color ); - ImGui::SameLine(); - if( ImGui::Selectable( v->text.empty() ? "" : v->text.c_str() ) ) - { - m_playback.range = GetPlaybackFrameRangeFromTime( v->range.min, v->range.max ); - limitChanged = true; - } - ImGui::SameLine(); - ImGui::Spacing(); - ImGui::SameLine(); - ImGui::TextDisabled( "%s - %s (%s)", TimeToStringExact( v->range.min ), TimeToStringExact( v->range.max ), TimeToString( v->range.max - v->range.min ) ); - } - ImGui::EndPopup(); - } - for( auto& r : m_ranges ) - { - ImGui::SameLine(); - if( SmallButtonDisablable( r.name, r.range->min == 0 && r.range->max == 0 ) ) - { - m_playback.range = GetPlaybackFrameRangeFromTime( r.range->min, r.range->max ); - limitChanged = true; - } - } ImGui::Unindent(); if( limitChanged )