From 7dab9484343eb299b2a944ca0686540f1e5dd0b8 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 14 Jul 2026 16:54:41 +0200 Subject: [PATCH] List sections and categories in range limits window. --- profiler/src/profiler/TracyView_Ranges.cpp | 39 +++++++++++++++------- 1 file changed, 27 insertions(+), 12 deletions(-) diff --git a/profiler/src/profiler/TracyView_Ranges.cpp b/profiler/src/profiler/TracyView_Ranges.cpp index 43fbf070..9f899354 100644 --- a/profiler/src/profiler/TracyView_Ranges.cpp +++ b/profiler/src/profiler/TracyView_Ranges.cpp @@ -119,23 +119,38 @@ void View::DrawRangeEntry( Range& range, const char* label, uint32_t color, int } else if( ImGui::BeginMenu( "Sections" ) ) { - /* - int id = 0; - for( auto& v : sections ) + RangeSlim sel; + if( sections.size() == 1 ) { - ImGui::PushID( id++ ); - const auto end = v.end.IsNonNegative() ? v.end.Val() : m_worker.GetLastTime(); - if( ImGui::MenuItem( m_worker.GetString( v.text ) ) ) + sel = ListSections( sections.begin()->second, m_worker ); + } + else + { + std::vector*>> s; + s.reserve( sections.size() ); + for( auto& v : sections ) s.emplace_back( v.first, &v.second ); + pdqsort_branchless( s.begin(), s.end(), []( const auto& lhs, const auto& rhs ) { return lhs.first < rhs.first; } ); + + int id = 0; + for( auto& v : s ) { - range.min = v.start.Val(); - range.max = end; + ImGui::PushID( id++ ); + auto desc = m_worker.GetSectionCategoryDescription( v.first ); + if( ImGui::BeginMenu( desc ) ) + { + auto out = ListSections( *v.second, m_worker ); + if( out.active ) sel = out; + ImGui::EndMenu(); + } + ImGui::PopID(); } - ImGui::PopID(); - ImGui::SameLine(); - ImGui::TextDisabled( "%s - %s (%s)", TimeToStringExact( v.start.Val() ), TimeToStringExact( end ), TimeToString( end - v.start.Val() ) ); } - */ ImGui::EndMenu(); + if( sel.active ) + { + range.min = sel.min; + range.max = sel.max; + } } int idx = 0;