mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-10 02:31:48 +00:00
Change resize logic such that TimelineItem instances "don't chase" each other anymore.
This commit is contained in:
parent
b80ede3ec6
commit
db6acfe9b5
@ -12,7 +12,6 @@ TimelineItem::TimelineItem( View& view, Worker& worker )
|
||||
: m_visible( true )
|
||||
, m_showFull( true )
|
||||
, m_height( 0 )
|
||||
, m_offset( 0 )
|
||||
, m_view( view )
|
||||
, m_worker( worker )
|
||||
{
|
||||
@ -22,8 +21,8 @@ void TimelineItem::Draw( bool firstFrame, double pxns, int& offset, const ImVec2
|
||||
{
|
||||
if( !IsVisible() )
|
||||
{
|
||||
m_height = 0;
|
||||
m_offset = 0;
|
||||
if( m_height != 0 )
|
||||
AdjustThreadHeight( firstFrame, offset, offset );
|
||||
return;
|
||||
}
|
||||
if( IsEmpty() ) return;
|
||||
@ -31,7 +30,7 @@ void TimelineItem::Draw( bool firstFrame, double pxns, int& offset, const ImVec2
|
||||
const auto w = ImGui::GetContentRegionAvail().x - 1;
|
||||
const auto ty = ImGui::GetTextLineHeight();
|
||||
const auto ostep = ty + 1;
|
||||
const auto yPos = AdjustThreadPosition( wpos.y, offset );
|
||||
const auto yPos = wpos.y + offset;
|
||||
const auto dpos = wpos + ImVec2( 0.5f, 0.5f );
|
||||
const auto oldOffset = offset;
|
||||
auto draw = ImGui::GetWindowDrawList();
|
||||
@ -44,9 +43,8 @@ void TimelineItem::Draw( bool firstFrame, double pxns, int& offset, const ImVec2
|
||||
{
|
||||
if( !DrawContents( pxns, offset, wpos, hover, yMin, yMax ) && !m_view.GetViewData().drawEmptyLabels )
|
||||
{
|
||||
m_height = 0;
|
||||
m_offset = 0;
|
||||
offset = oldOffset;
|
||||
AdjustThreadHeight( firstFrame, oldOffset, offset );
|
||||
ImGui::PopClipRect();
|
||||
ImGui::PopID();
|
||||
return;
|
||||
@ -123,44 +121,31 @@ void TimelineItem::Draw( bool firstFrame, double pxns, int& offset, const ImVec2
|
||||
|
||||
void TimelineItem::AdjustThreadHeight( bool firstFrame, int oldOffset, int& offset )
|
||||
{
|
||||
const auto speed = 10.0;
|
||||
const auto minMove = 2.0;
|
||||
|
||||
const auto h = offset - oldOffset;
|
||||
if( m_height > h )
|
||||
if( firstFrame )
|
||||
{
|
||||
m_height = h;
|
||||
offset = oldOffset + m_height;
|
||||
}
|
||||
else if( m_height < h )
|
||||
else if( m_height != h )
|
||||
{
|
||||
if( firstFrame )
|
||||
const auto diff = h - m_height;
|
||||
const auto preClampMove = diff * speed * ImGui::GetIO().DeltaTime;
|
||||
if( diff > 0 )
|
||||
{
|
||||
m_height = h;
|
||||
offset = oldOffset + h;
|
||||
const auto move = std::max( minMove, preClampMove );
|
||||
m_height = int( std::min<double>( m_height + move, h ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto diff = h - m_height;
|
||||
const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
|
||||
m_height = int( std::min<double>( m_height + move, h ) );
|
||||
offset = oldOffset + m_height;
|
||||
s_wasActive = true;
|
||||
const auto move = std::min( -minMove, preClampMove );
|
||||
m_height = int( std::max<double>( m_height + move, h ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float TimelineItem::AdjustThreadPosition( float wy, int& offset )
|
||||
{
|
||||
if( m_offset < offset )
|
||||
{
|
||||
m_offset = offset;
|
||||
}
|
||||
else if( m_offset > offset )
|
||||
{
|
||||
const auto diff = m_offset - offset;
|
||||
const auto move = std::max( 2.0, diff * 10.0 * ImGui::GetIO().DeltaTime );
|
||||
offset = m_offset = int( std::max<double>( m_offset - move, offset ) );
|
||||
s_wasActive = true;
|
||||
}
|
||||
return offset + wy;
|
||||
offset = oldOffset + m_height;
|
||||
}
|
||||
|
||||
void TimelineItem::VisibilityCheckbox()
|
||||
|
@ -47,10 +47,8 @@ protected:
|
||||
|
||||
private:
|
||||
void AdjustThreadHeight( bool firstFrame, int oldOffset, int& offset );
|
||||
float AdjustThreadPosition( float wy, int& offset );
|
||||
|
||||
int m_height;
|
||||
int m_offset;
|
||||
|
||||
protected:
|
||||
View& m_view;
|
||||
|
Loading…
Reference in New Issue
Block a user