mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-14 04:01:48 +00:00
Allow adding annotations to timeline.
This commit is contained in:
parent
215dc8a804
commit
5fed86dae7
@ -4,6 +4,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <limits>
|
#include <limits>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
#include <string>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "TracyCharUtil.hpp"
|
#include "TracyCharUtil.hpp"
|
||||||
@ -509,6 +510,14 @@ struct CpuThreadData
|
|||||||
|
|
||||||
enum { CpuThreadDataSize = sizeof( CpuThreadData ) };
|
enum { CpuThreadDataSize = sizeof( CpuThreadData ) };
|
||||||
|
|
||||||
|
|
||||||
|
struct Annotation
|
||||||
|
{
|
||||||
|
std::string text;
|
||||||
|
int64_t start;
|
||||||
|
int64_t end;
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -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;
|
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;
|
m_highlight.active = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2543,6 +2552,32 @@ void View::DrawZones()
|
|||||||
|
|
||||||
ImGui::EndChild();
|
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 )
|
if( m_gpuStart != 0 && m_gpuEnd != 0 )
|
||||||
{
|
{
|
||||||
const auto px0 = ( m_gpuStart - m_vd.zvStart ) * pxns;
|
const auto px0 = ( m_gpuStart - m_vd.zvStart ) * pxns;
|
||||||
|
@ -364,6 +364,7 @@ private:
|
|||||||
void* m_frameTexture = nullptr;
|
void* m_frameTexture = nullptr;
|
||||||
const void* m_frameTexturePtr = nullptr;
|
const void* m_frameTexturePtr = nullptr;
|
||||||
|
|
||||||
|
std::vector<std::unique_ptr<Annotation>> m_annotations;
|
||||||
UserData m_userData;
|
UserData m_userData;
|
||||||
|
|
||||||
struct FindZone {
|
struct FindZone {
|
||||||
|
Loading…
Reference in New Issue
Block a user