From 85f54499fef23b516aa48ddafd28e67cb867817d Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 9 Aug 2020 21:11:18 +0200 Subject: [PATCH] Add range limit UI to symbol view. --- server/TracySourceView.cpp | 40 +++++++++++++++++++++++++++++++++++++- server/TracyView.hpp | 8 +++++--- 2 files changed, 44 insertions(+), 4 deletions(-) diff --git a/server/TracySourceView.cpp b/server/TracySourceView.cpp index ee385563..eb52c45c 100644 --- a/server/TracySourceView.cpp +++ b/server/TracySourceView.cpp @@ -1106,7 +1106,6 @@ void SourceView::RenderSymbolView( const Worker& worker, View& view ) { ImGui::RadioButton( "Assembly", &m_displayMode, DisplayAsm ); } - ImGui::PopStyleVar(); if( !m_asm.empty() ) { @@ -1148,8 +1147,47 @@ void SourceView::RenderSymbolView( const Worker& worker, View& view ) ImGui::Spacing(); ImGui::SameLine(); TextFocused( ICON_FA_EYE_DROPPER " Samples:", RealToString( iptotalAsm ) ); + ImGui::SameLine(); + ImGui::Spacing(); + ImGui::SameLine(); + if( !worker.AreSymbolSamplesReady() ) + { + view.m_statRange.active = false; + bool val = false; + ImGui::PushItemFlag( ImGuiItemFlags_Disabled, true ); + ImGui::PushStyleVar( ImGuiStyleVar_Alpha, ImGui::GetStyle().Alpha * 0.5f ); + ImGui::Checkbox( "Limit range", &val ); + ImGui::PopItemFlag(); + ImGui::PopStyleVar(); + if( ImGui::IsItemHovered() ) + { + ImGui::BeginTooltip(); + ImGui::TextUnformatted( "Waiting for background tasks to finish" ); + ImGui::EndTooltip(); + } + } + else + { + if( ImGui::Checkbox( "Limit range", &view.m_statRange.active ) ) + { + if( view.m_statRange.active && view.m_statRange.min == 0 && view.m_statRange.max == 0 ) + { + const auto& vd = view.GetViewData(); + view.m_statRange.min = vd.zvStart; + view.m_statRange.max = vd.zvEnd; + } + } + if( view.m_statRange.active ) + { + ImGui::SameLine(); + TextColoredUnformatted( 0xFF00FFFF, ICON_FA_EXCLAMATION_TRIANGLE ); + ImGui::SameLine(); + ToggleButton( ICON_FA_RULER " Limits", view.m_showRanges ); + } + } } + ImGui::PopStyleVar(); ImGui::Separator(); uint64_t jumpOut = 0; diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 3520c0bb..0011c8eb 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -94,6 +94,11 @@ public: const char* SourceSubstitution( const char* srcFile ) const; void ShowSampleParents( uint64_t symAddr ) { m_sampleParents.symAddr = symAddr; m_sampleParents.sel = 0; } + const ViewData& GetViewData() const { return m_vd; } + + + bool m_showRanges = false; + Range m_statRange; private: enum class Namespace : uint8_t @@ -341,8 +346,6 @@ private: bool m_reactToCrash = false; ImGuiTextFilter m_statisticsFilter; - Range m_statRange; - RangeSlim m_statRangeSlim; Region m_highlight; Region m_highlightZoom; @@ -359,7 +362,6 @@ private: bool m_showPlayback = false; bool m_showCpuDataWindow = false; bool m_showAnnotationList = false; - bool m_showRanges = false; enum class CpuDataSortBy {