diff --git a/profiler/src/profiler/TracyUserData.cpp b/profiler/src/profiler/TracyUserData.cpp index e596fc4c..9794bff5 100644 --- a/profiler/src/profiler/TracyUserData.cpp +++ b/profiler/src/profiler/TracyUserData.cpp @@ -199,7 +199,8 @@ bool UserData::Save() { "text", v->text }, { "min", v->range.min }, { "max", v->range.max }, - { "color", v->color } + { "color", v->color }, + { "visible", v->visible }, } ); } } @@ -295,6 +296,7 @@ bool UserData::Load() LoadValue( v, "min", a->range.min ); LoadValue( v, "max", a->range.max ); LoadValue( v, "color", a->color ); + LoadValue( v, "visible", a->visible ); a->range.active = true; m_annotations.emplace_back( std::move( a ) ); } diff --git a/profiler/src/profiler/TracyViewData.hpp b/profiler/src/profiler/TracyViewData.hpp index 49cd8af5..fbcd5509 100644 --- a/profiler/src/profiler/TracyViewData.hpp +++ b/profiler/src/profiler/TracyViewData.hpp @@ -85,6 +85,7 @@ struct Annotation std::string text; Range range; uint32_t color; + bool visible = true; }; struct SourceRegex diff --git a/profiler/src/profiler/TracyView_Annotations.cpp b/profiler/src/profiler/TracyView_Annotations.cpp index d6eb00bc..6a583ffb 100644 --- a/profiler/src/profiler/TracyView_Annotations.cpp +++ b/profiler/src/profiler/TracyView_Annotations.cpp @@ -30,6 +30,8 @@ void View::DrawSelectedAnnotation() ImGui::Begin( "Annotation", &show, ImGuiWindowFlags_AlwaysAutoResize ); if( !ImGui::GetCurrentWindowRead()->SkipItems ) { + ImGui::Checkbox( "Visible", &m_selectedAnnotation->visible ); + ImGui::SameLine(); if( ImGui::Button( ICON_FA_MICROSCOPE " Zoom to annotation" ) ) { ZoomToRange( m_selectedAnnotation->range.min, m_selectedAnnotation->range.max ); @@ -127,6 +129,8 @@ void View::DrawAnnotationList() for( auto& ann : m_annotations ) { ImGui::PushID( idx ); + ImGui::Checkbox( "##visible", &ann->visible ); + ImGui::SameLine(); if( ImGui::Button( ICON_FA_PEN_TO_SQUARE ) ) { m_selectedAnnotation = ann.get(); diff --git a/profiler/src/profiler/TracyView_Timeline.cpp b/profiler/src/profiler/TracyView_Timeline.cpp index cfdec509..be41239a 100644 --- a/profiler/src/profiler/TracyView_Timeline.cpp +++ b/profiler/src/profiler/TracyView_Timeline.cpp @@ -288,6 +288,7 @@ void View::DrawTimeline() for( auto& r : m_ranges ) HandleRange( *r.range, timespan, ImGui::GetCursorScreenPos(), w ); for( auto& v : m_annotations ) { + if( !v->visible ) continue; v->range.StartFrame(); HandleRange( v->range, timespan, ImGui::GetCursorScreenPos(), w ); } @@ -296,7 +297,7 @@ void View::DrawTimeline() const auto ty = ImGui::GetTextLineHeight(); for( auto& ann : m_annotations ) { - if( ann->range.min >= m_vd.zvEnd || ann->range.max <= m_vd.zvStart ) continue; + if( !ann->visible || ann->range.min >= m_vd.zvEnd || ann->range.max <= m_vd.zvStart ) continue; const auto aMin = ( ann->range.min - m_vd.zvStart ) * pxns; const auto aMax = ( ann->range.max - m_vd.zvStart ) * pxns; if( ImGui::IsMouseHoveringRect( linepos + ImVec2( aMin, lineh - ty * 1.5f ), linepos + ImVec2( aMax, lineh ) ) ) @@ -411,7 +412,7 @@ void View::DrawTimeline() const auto iconSize = ImGui::CalcTextSize( ICON_FA_NOTE_STICKY ); for( auto& ann : m_annotations ) { - if( ann->range.min < m_vd.zvEnd && ann->range.max > m_vd.zvStart ) + if( ann->visible && ann->range.min < m_vd.zvEnd && ann->range.max > m_vd.zvStart ) { uint32_t c0 = ( ann->color & 0xFFFFFF ) | ( m_selectedAnnotation == ann.get() ? 0x22000000 : 0x11000000 ); uint32_t c1 = ( ann->color & 0xFFFFFF ) | ( m_selectedAnnotation == ann.get() ? 0x88000000 : 0x66000000 );