From c5f6ca9656471bd3799f5c66c0b87e53ab927d36 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Fri, 29 Sep 2017 21:49:14 +0200 Subject: [PATCH] Add basic zone info window. --- server/TracyView.cpp | 27 +++++++++++++++++++++++++++ server/TracyView.hpp | 3 +++ 2 files changed, 30 insertions(+) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 200e41f6..24d70ffa 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -42,6 +42,7 @@ View::View( const char* addr ) , m_frameStart( 0 ) , m_zvStart( 0 ) , m_zvEnd( 0 ) + , m_zoneInfoWindow( nullptr ) { assert( s_instance == nullptr ); s_instance = this; @@ -742,6 +743,7 @@ void View::DrawImpl() ImGui::Text( "Frames: %-7" PRIu64 " Time span: %-10s View span: %-10s Zones: %-10" PRIu64" Queue delay: %s Timer resolution: %s", m_frames.size(), TimeToString( GetLastTime() - m_frames[0] ), TimeToString( m_zvEnd - m_zvStart ), m_zonesCnt, TimeToString( m_delay ), TimeToString( m_resolution ) ); DrawFrames(); DrawZones(); + DrawZoneInfoWindow(); ImGui::End(); } @@ -1243,6 +1245,10 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, con m_zvStartNext = ev.start; m_zvEndNext = ev.end; } + if( ImGui::IsMouseClicked( 0 ) ) + { + m_zoneInfoWindow = &ev; + } } if( !ev.child.empty() ) @@ -1258,4 +1264,25 @@ int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, con return maxdepth; } +void View::DrawZoneInfoWindow() +{ + if( !m_zoneInfoWindow ) return; + auto& ev = *m_zoneInfoWindow; + bool show = true; + ImGui::Begin( "Zone info", &show, ImGuiWindowFlags_AlwaysAutoResize | ImGuiWindowFlags_ShowBorders ); + if( ev.text && ev.text->zoneName ) + { + ImGui::Text( "Zone name: %s", GetString( ev.text->zoneName ) ); + } + auto& srcloc = GetSourceLocation( ev.srcloc ); + ImGui::Text( "Function: %s", GetString( srcloc.function ) ); + ImGui::Text( "Location: %s:%i", GetString( srcloc.file ), srcloc.line ); + if( ev.text && ev.text->userText ) + { + ImGui::Text( "User text: %s", ev.text->userText ); + } + ImGui::End(); + if( !show ) m_zoneInfoWindow = nullptr; +} + } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index e29f45ee..f9724746 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -85,6 +85,7 @@ private: void DrawFrames(); void DrawZones(); int DrawZoneLevel( const Vector& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth ); + void DrawZoneInfoWindow(); std::string m_addr; @@ -135,6 +136,8 @@ private: uint64_t m_delay; uint64_t m_resolution; double m_timerMul; + + const Event* m_zoneInfoWindow; }; }