mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-23 14:54:34 +00:00
Animate thread position and height.
This commit is contained in:
parent
e945902f40
commit
f1dd4ef3d9
@ -1691,6 +1691,39 @@ bool View::DrawZoneFrames( const FrameData& frames )
|
|||||||
return hover;
|
return hover;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static float AdjustThreadPosition( View::VisData& vis, float wy, int& offset )
|
||||||
|
{
|
||||||
|
if( vis.offset < offset )
|
||||||
|
{
|
||||||
|
vis.offset = offset;
|
||||||
|
}
|
||||||
|
else if( vis.offset > offset )
|
||||||
|
{
|
||||||
|
const auto diff = vis.offset - offset;
|
||||||
|
const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
|
||||||
|
offset = vis.offset = int( std::max<double>( vis.offset - move, offset ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
return offset + wy;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void AdjustThreadHeight( View::VisData& vis, int oldOffset, int& offset )
|
||||||
|
{
|
||||||
|
const auto h = offset - oldOffset;
|
||||||
|
if( vis.height > h )
|
||||||
|
{
|
||||||
|
vis.height = h;
|
||||||
|
offset = oldOffset + vis.height;
|
||||||
|
}
|
||||||
|
else if( vis.height < h )
|
||||||
|
{
|
||||||
|
const auto diff = h - vis.height;
|
||||||
|
const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
|
||||||
|
vis.height = int( std::min<double>( vis.height + move, h ) );
|
||||||
|
offset = oldOffset + vis.height;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void View::DrawZones()
|
void View::DrawZones()
|
||||||
{
|
{
|
||||||
m_msgHighlight.Decay( nullptr );
|
m_msgHighlight.Decay( nullptr );
|
||||||
@ -1756,10 +1789,17 @@ void View::DrawZones()
|
|||||||
{
|
{
|
||||||
const auto& v = m_worker.GetGpuData()[i];
|
const auto& v = m_worker.GetGpuData()[i];
|
||||||
auto& vis = Vis( v );
|
auto& vis = Vis( v );
|
||||||
if( !vis.visible ) continue;
|
if( !vis.visible )
|
||||||
|
{
|
||||||
|
vis.height = 0;
|
||||||
|
vis.offset = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
bool& showFull = vis.showFull;
|
bool& showFull = vis.showFull;
|
||||||
|
|
||||||
const auto yPos = wpos.y + offset;
|
const auto yPos = AdjustThreadPosition( vis, wpos.y, offset );
|
||||||
|
const auto oldOffset = offset;
|
||||||
|
ImGui::PushClipRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( w, offset + vis.height ), true );
|
||||||
if( yPos + ostep >= yMin && yPos <= yMax )
|
if( yPos + ostep >= yMin && yPos <= yMax )
|
||||||
{
|
{
|
||||||
draw->AddLine( wpos + ImVec2( 0, offset + ostep - 1 ), wpos + ImVec2( w, offset + ostep - 1 ), 0x33FFFFFF );
|
draw->AddLine( wpos + ImVec2( 0, offset + ostep - 1 ), wpos + ImVec2( w, offset + ostep - 1 ), 0x33FFFFFF );
|
||||||
@ -1831,6 +1871,8 @@ void View::DrawZones()
|
|||||||
offset += ostep * depth;
|
offset += ostep * depth;
|
||||||
}
|
}
|
||||||
offset += ostep * 0.2f;
|
offset += ostep * 0.2f;
|
||||||
|
AdjustThreadHeight( vis, oldOffset, offset );
|
||||||
|
ImGui::PopClipRect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1840,10 +1882,17 @@ void View::DrawZones()
|
|||||||
for( const auto& v : m_worker.GetThreadData() )
|
for( const auto& v : m_worker.GetThreadData() )
|
||||||
{
|
{
|
||||||
auto& vis = Vis( v );
|
auto& vis = Vis( v );
|
||||||
if( !vis.visible ) continue;
|
if( !vis.visible )
|
||||||
|
{
|
||||||
|
vis.height = 0;
|
||||||
|
vis.offset = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
bool& showFull = vis.showFull;
|
bool& showFull = vis.showFull;
|
||||||
|
|
||||||
const auto yPos = wpos.y + offset;
|
const auto yPos = AdjustThreadPosition( vis, wpos.y, offset );
|
||||||
|
const auto oldOffset = offset;
|
||||||
|
ImGui::PushClipRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( w, offset + vis.height ), true );
|
||||||
if( yPos + ostep >= yMin && yPos <= yMax )
|
if( yPos + ostep >= yMin && yPos <= yMax )
|
||||||
{
|
{
|
||||||
draw->AddLine( wpos + ImVec2( 0, offset + ostep - 1 ), wpos + ImVec2( w, offset + ostep - 1 ), 0x33FFFFFF );
|
draw->AddLine( wpos + ImVec2( 0, offset + ostep - 1 ), wpos + ImVec2( w, offset + ostep - 1 ), 0x33FFFFFF );
|
||||||
@ -2009,6 +2058,8 @@ void View::DrawZones()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
offset += ostep * 0.2f;
|
offset += ostep * 0.2f;
|
||||||
|
AdjustThreadHeight( vis, oldOffset, offset );
|
||||||
|
ImGui::PopClipRect();
|
||||||
}
|
}
|
||||||
m_lockHighlight = nextLockHighlight;
|
m_lockHighlight = nextLockHighlight;
|
||||||
|
|
||||||
@ -3371,12 +3422,19 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
|||||||
for( const auto& v : m_worker.GetPlots() )
|
for( const auto& v : m_worker.GetPlots() )
|
||||||
{
|
{
|
||||||
auto& vis = Vis( v );
|
auto& vis = Vis( v );
|
||||||
if( !vis.visible ) continue;
|
if( !vis.visible )
|
||||||
|
{
|
||||||
|
vis.height = 0;
|
||||||
|
vis.offset = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
assert( !v->data.empty() );
|
assert( !v->data.empty() );
|
||||||
bool& showFull = vis.showFull;
|
bool& showFull = vis.showFull;
|
||||||
|
|
||||||
float txtx = 0;
|
float txtx = 0;
|
||||||
auto yPos = wpos.y + offset;
|
const auto yPos = AdjustThreadPosition( vis, wpos.y, offset );
|
||||||
|
const auto oldOffset = offset;
|
||||||
|
ImGui::PushClipRect( wpos + ImVec2( 0, offset ), wpos + ImVec2( w, offset + vis.height ), true );
|
||||||
if( yPos + ty >= yMin && yPos <= yMax )
|
if( yPos + ty >= yMin && yPos <= yMax )
|
||||||
{
|
{
|
||||||
if( showFull )
|
if( showFull )
|
||||||
@ -3597,6 +3655,8 @@ int View::DrawPlots( int offset, double pxns, const ImVec2& wpos, bool hover, fl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
offset += 0.2 * ty;
|
offset += 0.2 * ty;
|
||||||
|
AdjustThreadHeight( vis, oldOffset, offset );
|
||||||
|
ImGui::PopClipRect();
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
|
@ -43,6 +43,14 @@ class View
|
|||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
struct VisData
|
||||||
|
{
|
||||||
|
bool visible = true;
|
||||||
|
bool showFull = true;
|
||||||
|
int offset = 0;
|
||||||
|
int height = 0;
|
||||||
|
};
|
||||||
|
|
||||||
using SetTitleCallback = void(*)( const char* );
|
using SetTitleCallback = void(*)( const char* );
|
||||||
|
|
||||||
View( ImFont* fixedWidth = nullptr, SetTitleCallback stcb = nullptr ) : View( "127.0.0.1", fixedWidth, stcb ) {}
|
View( ImFont* fixedWidth = nullptr, SetTitleCallback stcb = nullptr ) : View( "127.0.0.1", fixedWidth, stcb ) {}
|
||||||
@ -77,12 +85,6 @@ private:
|
|||||||
uint64_t mem;
|
uint64_t mem;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct VisData
|
|
||||||
{
|
|
||||||
bool visible = true;
|
|
||||||
bool showFull = true;
|
|
||||||
};
|
|
||||||
|
|
||||||
void InitTextEditor();
|
void InitTextEditor();
|
||||||
|
|
||||||
const char* ShortenNamespace( const char* name ) const;
|
const char* ShortenNamespace( const char* name ) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user