mirror of
https://github.com/wolfpld/tracy.git
synced 2024-11-27 00:04:35 +00:00
Add zoom-to-range animation.
This commit is contained in:
parent
ba80b0c16a
commit
dd8694350e
@ -1597,11 +1597,22 @@ void View::DrawImpl()
|
||||
if( m_showOptions ) DrawOptions();
|
||||
if( m_showMessages ) DrawMessages();
|
||||
|
||||
if( m_zvStartNext != 0 )
|
||||
if( m_zoomAnim.active )
|
||||
{
|
||||
m_zvStart = m_zvStartNext;
|
||||
m_zvEnd = m_zvEndNext;
|
||||
m_pause = true;
|
||||
const auto& io = ImGui::GetIO();
|
||||
m_zoomAnim.progress += io.DeltaTime * m_zoomAnim.lenMod;
|
||||
if( m_zoomAnim.progress >= 1.f )
|
||||
{
|
||||
m_zoomAnim.active = false;
|
||||
m_zvStart = m_zoomAnim.start1;
|
||||
m_zvEnd = m_zoomAnim.end1;
|
||||
}
|
||||
else
|
||||
{
|
||||
const auto v = sqrt( sin( M_PI_2 * m_zoomAnim.progress ) );
|
||||
m_zvStart = int64_t( m_zoomAnim.start0 + ( m_zoomAnim.start1 - m_zoomAnim.start0 ) * v );
|
||||
m_zvEnd = int64_t( m_zoomAnim.end0 + ( m_zoomAnim.end1 - m_zoomAnim.end0 ) * v );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -2023,8 +2034,6 @@ bool View::DrawZoneFrames()
|
||||
}
|
||||
}
|
||||
|
||||
m_zvStartNext = 0;
|
||||
|
||||
const auto zitbegin = std::lower_bound( m_frames.begin(), m_frames.end(), m_zvStart );
|
||||
if( zitbegin == m_frames.end() ) return hover;
|
||||
const auto zitend = std::lower_bound( zitbegin, m_frames.end(), m_zvEnd );
|
||||
@ -2541,7 +2550,7 @@ int View::DrawZoneLevel( const Vector<ZoneEvent*>& vec, bool hover, double pxns,
|
||||
{
|
||||
ZoneTooltip( ev );
|
||||
|
||||
if( m_zvStartNext == 0 && ImGui::IsMouseClicked( 2 ) )
|
||||
if( !m_zoomAnim.active && ImGui::IsMouseClicked( 2 ) )
|
||||
{
|
||||
ZoomToZone( ev );
|
||||
}
|
||||
@ -2709,7 +2718,7 @@ int View::DrawGpuZoneLevel( const Vector<GpuEvent*>& vec, bool hover, double pxn
|
||||
{
|
||||
ZoneTooltip( ev );
|
||||
|
||||
if( m_zvStartNext == 0 && ImGui::IsMouseClicked( 2 ) )
|
||||
if( !m_zoomAnim.active && ImGui::IsMouseClicked( 2 ) )
|
||||
{
|
||||
ZoomToZone( ev );
|
||||
}
|
||||
@ -3732,8 +3741,18 @@ void View::ZoomToZone( const GpuEvent& ev )
|
||||
|
||||
void View::ZoomToRange( int64_t start, int64_t end )
|
||||
{
|
||||
m_zvStartNext = start;
|
||||
m_zvEndNext = end;
|
||||
m_pause = true;
|
||||
m_zoomAnim.active = true;
|
||||
m_zoomAnim.start0 = m_zvStart;
|
||||
m_zoomAnim.start1 = start;
|
||||
m_zoomAnim.end0 = m_zvEnd;
|
||||
m_zoomAnim.end1 = end;
|
||||
m_zoomAnim.progress = 0;
|
||||
|
||||
const auto d0 = double( m_zoomAnim.end0 - m_zoomAnim.start0 );
|
||||
const auto d1 = double( m_zoomAnim.end1 - m_zoomAnim.start1 );
|
||||
const auto diff = d0>d1 ? d0/d1 : d1/d0;
|
||||
m_zoomAnim.lenMod = 10.0 / log10( diff );
|
||||
}
|
||||
|
||||
void View::ZoneTooltip( const ZoneEvent& ev )
|
||||
|
@ -36,6 +36,15 @@ class View
|
||||
typedef tracy::power_of_two_hash_policy hash_policy;
|
||||
};
|
||||
|
||||
struct Animation
|
||||
{
|
||||
bool active = false;
|
||||
int64_t start0, start1;
|
||||
int64_t end0, end1;
|
||||
double progress;
|
||||
double lenMod;
|
||||
};
|
||||
|
||||
public:
|
||||
View() : View( "127.0.0.1" ) {}
|
||||
View( const char* addr );
|
||||
@ -228,9 +237,6 @@ private:
|
||||
int64_t m_zvStart;
|
||||
int64_t m_zvEnd;
|
||||
|
||||
int64_t m_zvStartNext;
|
||||
int64_t m_zvEndNext;
|
||||
|
||||
int64_t m_delay;
|
||||
int64_t m_resolution;
|
||||
double m_timerMul;
|
||||
@ -266,6 +272,7 @@ private:
|
||||
bool m_onlyContendedLocks;
|
||||
|
||||
Namespace m_namespace;
|
||||
Animation m_zoomAnim;
|
||||
|
||||
bool m_terminate;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user