From 42636cfe898d5ff2b5b2c3248b1f5e566f63c070 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sat, 18 Aug 2018 20:35:25 +0200 Subject: [PATCH] Allow viewing source files from within find zone menu. --- server/TracyView.cpp | 26 ++++++++++++++++++++++++-- server/TracyView.hpp | 1 + 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index e4472a25..5754b6d5 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -704,6 +704,7 @@ bool View::DrawImpl() m_callstackBuzzAnim.Update( io.DeltaTime ); m_callstackTreeBuzzAnim.Update( io.DeltaTime ); m_zoneinfoBuzzAnim.Update( io.DeltaTime ); + m_findZoneBuzzAnim.Update( io.DeltaTime ); return keepOpen; } @@ -4487,8 +4488,29 @@ void View::DrawFindZone() auto& zones = m_worker.GetZonesForSourceLocation( v ).zones; ImGui::PushID( idx ); ImGui::RadioButton( m_worker.GetString( srcloc.name.active ? srcloc.name : srcloc.function ), &m_findZone.selMatch, idx++ ); - ImGui::SameLine(); - ImGui::TextColored( ImVec4( 0.5, 0.5, 0.5, 1 ), "(%s) %s:%i", RealToString( zones.size(), true ), m_worker.GetString( srcloc.file ), srcloc.line ); + if( m_findZoneBuzzAnim.Match( idx ) ) + { + const auto time = m_findZoneBuzzAnim.Time(); + const auto indentVal = sin( time * 60.f ) * 10.f * time; + ImGui::SameLine( 0, ImGui::GetStyle().ItemSpacing.x + indentVal ); + } + else + { + ImGui::SameLine(); + } + const auto fileName = m_worker.GetString( srcloc.file ); + ImGui::TextColored( ImVec4( 0.5, 0.5, 0.5, 1 ), "(%s) %s:%i", RealToString( zones.size(), true ), fileName, srcloc.line ); + if( ImGui::IsItemClicked( 1 ) ) + { + if( FileExists( fileName ) ) + { + SetTextEditorFile( fileName, srcloc.line ); + } + else + { + m_findZoneBuzzAnim.Enable( idx, 0.5f ); + } + } ImGui::PopID(); } ImGui::TreePop(); diff --git a/server/TracyView.hpp b/server/TracyView.hpp index 45c6175e..977448d2 100644 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -251,6 +251,7 @@ private: BuzzAnim m_callstackBuzzAnim; BuzzAnim m_callstackTreeBuzzAnim; BuzzAnim m_zoneinfoBuzzAnim; + BuzzAnim m_findZoneBuzzAnim; Vector m_zoneInfoStack; Vector m_gpuInfoStack;