mirror of
https://github.com/wolfpld/tracy.git
synced 2026-10-23 09:10:51 +00:00
Make it possible to hide annotation.
This commit is contained in:
@@ -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 ) );
|
||||
}
|
||||
|
||||
@@ -85,6 +85,7 @@ struct Annotation
|
||||
std::string text;
|
||||
Range range;
|
||||
uint32_t color;
|
||||
bool visible = true;
|
||||
};
|
||||
|
||||
struct SourceRegex
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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 );
|
||||
|
||||
Reference in New Issue
Block a user