1
0
mirror of https://github.com/wolfpld/tracy.git synced 2025-03-20 07:40:02 +08:00

Allow adding annotations to timeline.

This commit is contained in:
Bartosz Taudul
2019-10-13 15:28:52 +02:00
parent 215dc8a804
commit 5fed86dae7
3 changed files with 46 additions and 1 deletions
+36 -1
View File
@@ -1418,8 +1418,17 @@ void View::HandleZoneViewMouse( int64_t timespan, const ImVec2& wpos, float w, d
{
m_highlight.end = m_vd.zvStart + ( io.MousePos.x - wpos.x ) * nspx;
}
else
else if( m_highlight.active )
{
if( ImGui::GetIO().KeyCtrl && m_highlight.start != m_highlight.end )
{
auto ann = std::make_unique<Annotation>();
const auto s = std::min( m_highlight.start, m_highlight.end );
const auto e = std::max( m_highlight.start, m_highlight.end );
ann->start = s;
ann->end = e;
m_annotations.emplace_back( std::move( ann ) );
}
m_highlight.active = false;
}
@@ -2543,6 +2552,32 @@ void View::DrawZones()
ImGui::EndChild();
for( auto& ann : m_annotations )
{
if( ann->start < m_vd.zvEnd && ann->end > m_vd.zvStart )
{
draw->AddRectFilled( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->end - m_vd.zvStart ) * pxns, lineh ), 0x22888888 );
draw->AddRect( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->end - m_vd.zvStart ) * pxns, lineh ), 0x44888888 );
if( ImGui::IsMouseHoveringRect( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->end - m_vd.zvStart ) * pxns, lineh ) ) )
{
ImGui::BeginTooltip();
if( ann->text.empty() )
{
TextDisabledUnformatted( "Empty annotation" );
}
else
{
ImGui::TextUnformatted( ann->text.c_str() );
}
ImGui::Separator();
TextFocused( "Annotation begin:", TimeToString( ann->start ) );
TextFocused( "Annotation end:", TimeToString( ann->end ) );
TextFocused( "Annotation length:", TimeToString( ann->end - ann->start ) );
ImGui::EndTooltip();
}
}
}
if( m_gpuStart != 0 && m_gpuEnd != 0 )
{
const auto px0 = ( m_gpuStart - m_vd.zvStart ) * pxns;