From 060cd90c81e66eecc02d858f2fd5fd1316d41ff3 Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 24 Sep 2017 00:12:26 +0200 Subject: [PATCH] Draw nested zones. --- server/TracyView.cpp | 16 +++++++++++++--- server/TracyView.hpp | 2 +- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/server/TracyView.cpp b/server/TracyView.cpp index ad7862b8..1f915a98 100755 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -918,17 +918,20 @@ void View::DrawZones() draw->AddText( wpos + ImVec2( 0, offset ), 0xFFFFFFFF, GetThreadString( v.id ) ); offset += ostep; - DrawZoneLevel( v.timeline, hover, pxns, wpos, offset ); + const auto depth = DrawZoneLevel( v.timeline, hover, pxns, wpos, offset, 0 ); - offset += ostep * 1.2f; + offset += ostep * ( depth + 1.2f ); } } -void View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, const ImVec2& wpos, int offset ) +int View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, const ImVec2& wpos, int _offset, int depth ) { + int maxdepth = depth; auto it = std::lower_bound( vec.begin(), vec.end(), m_zvStart, [] ( const auto& l, const auto& r ) { return l->end < r; } ); if( it != vec.end() ) { + const auto ostep = ImGui::GetFontSize(); + const auto offset = _offset + ostep * depth; auto draw = ImGui::GetWindowDrawList(); const auto zitend = std::lower_bound( vec.begin(), vec.end(), m_zvEnd, [] ( const auto& l, const auto& r ) { return l->start < r; } ); @@ -962,9 +965,16 @@ void View::DrawZoneLevel( const Vector& vec, bool hover, double pxns, co ImGui::EndTooltip(); } + if( !ev.child.empty() ) + { + const auto d = DrawZoneLevel( ev.child, hover, pxns, wpos, _offset, depth+1 ); + if( d > maxdepth ) maxdepth = d; + } + it++; } } + return maxdepth; } } diff --git a/server/TracyView.hpp b/server/TracyView.hpp index ff37c8a1..0d43bc23 100755 --- a/server/TracyView.hpp +++ b/server/TracyView.hpp @@ -73,7 +73,7 @@ private: void DrawImpl(); void DrawFrames(); void DrawZones(); - void DrawZoneLevel( const Vector& vec, bool hover, double pxns, const ImVec2& wpos, int offset ); + int DrawZoneLevel( const Vector& vec, bool hover, double pxns, const ImVec2& wpos, int offset, int depth ); std::string m_addr;