From a5c16a39bae2defcf96b02bc8a7384ec298785ea Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Tue, 4 Aug 2020 17:23:12 +0200 Subject: [PATCH] Make annotations resizable. --- server/TracyUserData.cpp | 1 + server/TracyView.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/server/TracyUserData.cpp b/server/TracyUserData.cpp index 0af93261..d320c3a3 100644 --- a/server/TracyUserData.cpp +++ b/server/TracyUserData.cpp @@ -187,6 +187,7 @@ void UserData::LoadAnnotations( std::vector>& data ) fread( &ann->range.min, 1, sizeof( ann->range.min ), f ); fread( &ann->range.max, 1, sizeof( ann->range.max ), f ); fread( &ann->color, 1, sizeof( ann->color ), f ); + ann->range.active = true; data.emplace_back( std::move( ann ) ); } diff --git a/server/TracyView.cpp b/server/TracyView.cpp index 1180ffb2..63da838f 100644 --- a/server/TracyView.cpp +++ b/server/TracyView.cpp @@ -790,6 +790,7 @@ bool View::DrawImpl() auto ann = std::make_unique(); const auto s = std::min( m_setRangePopup.min, m_setRangePopup.max ); const auto e = std::max( m_setRangePopup.min, m_setRangePopup.max ); + ann->range.active = true; ann->range.min = s; ann->range.max = e; ann->color = 0x888888; @@ -2470,6 +2471,11 @@ void View::DrawZones() { HandleRange( m_findZone.range, timespan, ImGui::GetCursorScreenPos(), w ); HandleRange( m_statRange, timespan, ImGui::GetCursorScreenPos(), w ); + for( auto& v : m_annotations ) + { + v->range.StartFrame(); + HandleRange( v->range, timespan, ImGui::GetCursorScreenPos(), w ); + } HandleZoneViewMouse( timespan, ImGui::GetCursorScreenPos(), w, pxns ); } @@ -3149,8 +3155,10 @@ void View::DrawZones() { uint32_t c0 = ( ann->color & 0xFFFFFF ) | ( m_selectedAnnotation == ann.get() ? 0x44000000 : 0x22000000 ); uint32_t c1 = ( ann->color & 0xFFFFFF ) | ( m_selectedAnnotation == ann.get() ? 0x66000000 : 0x44000000 ); + uint32_t c2 = ( ann->color & 0xFFFFFF ) | ( m_selectedAnnotation == ann.get() ? 0xCC000000 : 0xAA000000 ); draw->AddRectFilled( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->range.max - m_vd.zvStart ) * pxns, lineh ), c0 ); - draw->AddRect( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->range.max - m_vd.zvStart ) * pxns, lineh ), c1 ); + draw->AddLine( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns, lineh ), ann->range.hiMin ? c2 : c1, ann->range.hiMin ? 2 : 1 ); + draw->AddLine( linepos + ImVec2( ( ann->range.max - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->range.max - m_vd.zvStart ) * pxns, lineh ), ann->range.hiMax ? c2 : c1, ann->range.hiMax ? 2 : 1 ); if( drawMouseLine && ImGui::IsMouseHoveringRect( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->range.max - m_vd.zvStart ) * pxns, lineh ) ) ) { ImGui::BeginTooltip();