mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-26 16:04:34 +00:00
Use Range for annotation extent.
This commit is contained in:
parent
2acc1d9670
commit
f589fba274
@ -184,8 +184,8 @@ void UserData::LoadAnnotations( std::vector<std::unique_ptr<Annotation>>& data )
|
|||||||
fread( buf, 1, tsz, f );
|
fread( buf, 1, tsz, f );
|
||||||
ann->text.assign( buf, tsz );
|
ann->text.assign( buf, tsz );
|
||||||
}
|
}
|
||||||
fread( &ann->start, 1, sizeof( ann->start ), f );
|
fread( &ann->range.min, 1, sizeof( ann->range.min ), f );
|
||||||
fread( &ann->end, 1, sizeof( ann->end ), f );
|
fread( &ann->range.max, 1, sizeof( ann->range.max ), f );
|
||||||
fread( &ann->color, 1, sizeof( ann->color ), f );
|
fread( &ann->color, 1, sizeof( ann->color ), f );
|
||||||
|
|
||||||
data.emplace_back( std::move( ann ) );
|
data.emplace_back( std::move( ann ) );
|
||||||
@ -219,8 +219,8 @@ void UserData::SaveAnnotations( const std::vector<std::unique_ptr<Annotation>>&
|
|||||||
{
|
{
|
||||||
fwrite( ann->text.c_str(), 1, sz, f );
|
fwrite( ann->text.c_str(), 1, sz, f );
|
||||||
}
|
}
|
||||||
fwrite( &ann->start, 1, sizeof( ann->start ), f );
|
fwrite( &ann->range.min, 1, sizeof( ann->range.min ), f );
|
||||||
fwrite( &ann->end, 1, sizeof( ann->end ), f );
|
fwrite( &ann->range.max, 1, sizeof( ann->range.max ), f );
|
||||||
fwrite( &ann->color, 1, sizeof( ann->color ), f );
|
fwrite( &ann->color, 1, sizeof( ann->color ), f );
|
||||||
}
|
}
|
||||||
fclose( f );
|
fclose( f );
|
||||||
|
@ -790,12 +790,12 @@ bool View::DrawImpl()
|
|||||||
auto ann = std::make_unique<Annotation>();
|
auto ann = std::make_unique<Annotation>();
|
||||||
const auto s = std::min( m_setRangePopup.min, m_setRangePopup.max );
|
const auto s = std::min( m_setRangePopup.min, m_setRangePopup.max );
|
||||||
const auto e = std::max( m_setRangePopup.min, m_setRangePopup.max );
|
const auto e = std::max( m_setRangePopup.min, m_setRangePopup.max );
|
||||||
ann->start = s;
|
ann->range.min = s;
|
||||||
ann->end = e;
|
ann->range.max = e;
|
||||||
ann->color = 0x888888;
|
ann->color = 0x888888;
|
||||||
m_selectedAnnotation = ann.get();
|
m_selectedAnnotation = ann.get();
|
||||||
m_annotations.emplace_back( std::move( ann ) );
|
m_annotations.emplace_back( std::move( ann ) );
|
||||||
pdqsort_branchless( m_annotations.begin(), m_annotations.end(), []( const auto& lhs, const auto& rhs ) { return lhs->start < rhs->start; } );
|
pdqsort_branchless( m_annotations.begin(), m_annotations.end(), []( const auto& lhs, const auto& rhs ) { return lhs->range.min < rhs->range.min; } );
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
@ -3145,13 +3145,13 @@ void View::DrawZones()
|
|||||||
|
|
||||||
for( auto& ann : m_annotations )
|
for( auto& ann : m_annotations )
|
||||||
{
|
{
|
||||||
if( ann->start < m_vd.zvEnd && ann->end > m_vd.zvStart )
|
if( ann->range.min < m_vd.zvEnd && ann->range.max > m_vd.zvStart )
|
||||||
{
|
{
|
||||||
uint32_t c0 = ( ann->color & 0xFFFFFF ) | ( m_selectedAnnotation == ann.get() ? 0x44000000 : 0x22000000 );
|
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 c1 = ( ann->color & 0xFFFFFF ) | ( m_selectedAnnotation == ann.get() ? 0x66000000 : 0x44000000 );
|
||||||
draw->AddRectFilled( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->end - m_vd.zvStart ) * pxns, lineh ), c0 );
|
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->start - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->end - m_vd.zvStart ) * pxns, lineh ), c1 );
|
draw->AddRect( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->range.max - m_vd.zvStart ) * pxns, lineh ), c1 );
|
||||||
if( drawMouseLine && ImGui::IsMouseHoveringRect( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->end - m_vd.zvStart ) * pxns, lineh ) ) )
|
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();
|
ImGui::BeginTooltip();
|
||||||
if( ann->text.empty() )
|
if( ann->text.empty() )
|
||||||
@ -3163,17 +3163,17 @@ void View::DrawZones()
|
|||||||
ImGui::TextUnformatted( ann->text.c_str() );
|
ImGui::TextUnformatted( ann->text.c_str() );
|
||||||
}
|
}
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
TextFocused( "Annotation begin:", TimeToString( ann->start ) );
|
TextFocused( "Annotation begin:", TimeToString( ann->range.min ) );
|
||||||
TextFocused( "Annotation end:", TimeToString( ann->end ) );
|
TextFocused( "Annotation end:", TimeToString( ann->range.max ) );
|
||||||
TextFocused( "Annotation length:", TimeToString( ann->end - ann->start ) );
|
TextFocused( "Annotation length:", TimeToString( ann->range.max - ann->range.min ) );
|
||||||
ImGui::EndTooltip();
|
ImGui::EndTooltip();
|
||||||
}
|
}
|
||||||
const auto aw = ( ann->end - ann->start ) * pxns;
|
const auto aw = ( ann->range.max - ann->range.min ) * pxns;
|
||||||
if( aw > th * 4 )
|
if( aw > th * 4 )
|
||||||
{
|
{
|
||||||
draw->AddCircleFilled( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns + th * 2, th * 2 ), th, 0x88AABB22 );
|
draw->AddCircleFilled( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns + th * 2, th * 2 ), th, 0x88AABB22 );
|
||||||
draw->AddCircle( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns + th * 2, th * 2 ), th, 0xAAAABB22 );
|
draw->AddCircle( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns + th * 2, th * 2 ), th, 0xAAAABB22 );
|
||||||
if( drawMouseLine && IsMouseClicked( 0 ) && ImGui::IsMouseHoveringRect( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns + th, th ), linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns + th * 3, th * 3 ) ) )
|
if( drawMouseLine && IsMouseClicked( 0 ) && ImGui::IsMouseHoveringRect( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns + th, th ), linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns + th * 3, th * 3 ) ) )
|
||||||
{
|
{
|
||||||
m_selectedAnnotation = ann.get();
|
m_selectedAnnotation = ann.get();
|
||||||
}
|
}
|
||||||
@ -3183,12 +3183,12 @@ void View::DrawZones()
|
|||||||
const auto tw = ImGui::CalcTextSize( ann->text.c_str() ).x;
|
const auto tw = ImGui::CalcTextSize( ann->text.c_str() ).x;
|
||||||
if( aw - th*4 > tw )
|
if( aw - th*4 > tw )
|
||||||
{
|
{
|
||||||
draw->AddText( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns + th * 4, th * 0.5 ), 0xFFFFFFFF, ann->text.c_str() );
|
draw->AddText( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns + th * 4, th * 0.5 ), 0xFFFFFFFF, ann->text.c_str() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
draw->PushClipRect( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->end - m_vd.zvStart ) * pxns, lineh ), true );
|
draw->PushClipRect( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns, 0 ), linepos + ImVec2( ( ann->range.max - m_vd.zvStart ) * pxns, lineh ), true );
|
||||||
draw->AddText( linepos + ImVec2( ( ann->start - m_vd.zvStart ) * pxns + th * 4, th * 0.5 ), 0xFFFFFFFF, ann->text.c_str() );
|
draw->AddText( linepos + ImVec2( ( ann->range.min - m_vd.zvStart ) * pxns + th * 4, th * 0.5 ), 0xFFFFFFFF, ann->text.c_str() );
|
||||||
draw->PopClipRect();
|
draw->PopClipRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -14265,7 +14265,7 @@ void View::DrawSelectedAnnotation()
|
|||||||
ImGui::Begin( "Annotation", &show, ImGuiWindowFlags_AlwaysAutoResize );
|
ImGui::Begin( "Annotation", &show, ImGuiWindowFlags_AlwaysAutoResize );
|
||||||
if( ImGui::Button( ICON_FA_MICROSCOPE " Zoom to annotation" ) )
|
if( ImGui::Button( ICON_FA_MICROSCOPE " Zoom to annotation" ) )
|
||||||
{
|
{
|
||||||
ZoomToRange( m_selectedAnnotation->start, m_selectedAnnotation->end );
|
ZoomToRange( m_selectedAnnotation->range.min, m_selectedAnnotation->range.max );
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if( ImGui::Button( ICON_FA_TRASH_ALT " Remove" ) )
|
if( ImGui::Button( ICON_FA_TRASH_ALT " Remove" ) )
|
||||||
@ -14298,9 +14298,9 @@ void View::DrawSelectedAnnotation()
|
|||||||
ImGui::ColorEdit3( "Color", &col.x );
|
ImGui::ColorEdit3( "Color", &col.x );
|
||||||
m_selectedAnnotation->color = ImGui::ColorConvertFloat4ToU32( col );
|
m_selectedAnnotation->color = ImGui::ColorConvertFloat4ToU32( col );
|
||||||
ImGui::Separator();
|
ImGui::Separator();
|
||||||
TextFocused( "Annotation begin:", TimeToString( m_selectedAnnotation->start ) );
|
TextFocused( "Annotation begin:", TimeToString( m_selectedAnnotation->range.min ) );
|
||||||
TextFocused( "Annotation end:", TimeToString( m_selectedAnnotation->end ) );
|
TextFocused( "Annotation end:", TimeToString( m_selectedAnnotation->range.max ) );
|
||||||
TextFocused( "Annotation length:", TimeToString( m_selectedAnnotation->end - m_selectedAnnotation->start ) );
|
TextFocused( "Annotation length:", TimeToString( m_selectedAnnotation->range.max - m_selectedAnnotation->range.min ) );
|
||||||
ImGui::End();
|
ImGui::End();
|
||||||
if( !show ) m_selectedAnnotation = nullptr;
|
if( !show ) m_selectedAnnotation = nullptr;
|
||||||
}
|
}
|
||||||
@ -14334,7 +14334,7 @@ void View::DrawAnnotationList()
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if( ImGui::Button( ICON_FA_MICROSCOPE ) )
|
if( ImGui::Button( ICON_FA_MICROSCOPE ) )
|
||||||
{
|
{
|
||||||
ZoomToRange( ann->start, ann->end );
|
ZoomToRange( ann->range.min, ann->range.max );
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if( ButtonDisablable( ICON_FA_TRASH_ALT, !ctrl ) )
|
if( ButtonDisablable( ICON_FA_TRASH_ALT, !ctrl ) )
|
||||||
@ -14708,11 +14708,11 @@ void View::DrawRangeEntry( Range& range, const char* label, uint32_t color, cons
|
|||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
if( ImGui::Selectable( v->text.c_str() ) )
|
if( ImGui::Selectable( v->text.c_str() ) )
|
||||||
{
|
{
|
||||||
range.min = v->start;
|
range.min = v->range.min;
|
||||||
range.max = v->end;
|
range.max = v->range.max;
|
||||||
}
|
}
|
||||||
ImGui::SameLine();
|
ImGui::SameLine();
|
||||||
ImGui::TextDisabled( "%s - %s (%s)", TimeToStringExact( v->start ), TimeToStringExact( v->end ), TimeToString( v->end - v->start ) );
|
ImGui::TextDisabled( "%s - %s (%s)", TimeToStringExact( v->range.min ), TimeToStringExact( v->range.max ), TimeToString( v->range.max - v->range.min ) );
|
||||||
}
|
}
|
||||||
ImGui::EndPopup();
|
ImGui::EndPopup();
|
||||||
}
|
}
|
||||||
|
@ -58,8 +58,7 @@ struct ViewData
|
|||||||
struct Annotation
|
struct Annotation
|
||||||
{
|
{
|
||||||
std::string text;
|
std::string text;
|
||||||
int64_t start;
|
Range range;
|
||||||
int64_t end;
|
|
||||||
uint32_t color;
|
uint32_t color;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user