Push item visibility to Preprocess().

This commit is contained in:
Bartosz Taudul 2023-03-25 15:10:58 +01:00
parent 8c1b519fa1
commit 7ec68f8b52
No known key found for this signature in database
GPG Key ID: B7FE2008B7575DF3
4 changed files with 9 additions and 6 deletions

View File

@ -133,17 +133,20 @@ void TimelineController::End( double pxns, const ImVec2& wpos, bool hover, bool
ctx.wpos = wpos; ctx.wpos = wpos;
ctx.hover = hover; ctx.hover = hover;
int yOffset = 0;
for( auto& item : m_items ) for( auto& item : m_items )
{ {
if( item->WantPreprocess() && item->IsVisible() ) if( item->WantPreprocess() && item->IsVisible() )
{ {
item->Preprocess( ctx, m_td ); const auto yPos = wpos.y + yOffset;
const bool visible = m_firstFrame || ( yPos < yMax && yPos + item->GetNextFrameHeight() >= yMin );
item->Preprocess( ctx, m_td, visible );
} }
yOffset += m_firstFrame ? 0 : item->GetNextFrameHeight();
} }
m_td.Sync(); m_td.Sync();
int yOffset = 0; yOffset = 0;
for( auto& item : m_items ) for( auto& item : m_items )
{ {
auto currentFrameItemHeight = item->GetNextFrameHeight(); auto currentFrameItemHeight = item->GetNextFrameHeight();

View File

@ -24,7 +24,7 @@ public:
void Draw( bool firstFrame, const TimelineContext& ctx, int yOffset ); void Draw( bool firstFrame, const TimelineContext& ctx, int yOffset );
bool WantPreprocess() const { return m_wantPreprocess; } bool WantPreprocess() const { return m_wantPreprocess; }
virtual void Preprocess( const TimelineContext& ctx, TaskDispatch& td ) { assert( false ); } virtual void Preprocess( const TimelineContext& ctx, TaskDispatch& td, bool visible ) { assert( false ); }
void VisibilityCheckbox(); void VisibilityCheckbox();
virtual void SetVisible( bool visible ) { m_visible = visible; } virtual void SetVisible( bool visible ) { m_visible = visible; }

View File

@ -281,7 +281,7 @@ void TimelineItemThread::DrawFinished()
m_msgDraw.clear(); m_msgDraw.clear();
} }
void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& td ) void TimelineItemThread::Preprocess( const TimelineContext& ctx, TaskDispatch& td, bool visible )
{ {
assert( m_samplesDraw.empty() ); assert( m_samplesDraw.empty() );
assert( m_ctxDraw.empty() ); assert( m_ctxDraw.empty() );

View File

@ -31,7 +31,7 @@ protected:
bool IsEmpty() const override; bool IsEmpty() const override;
void Preprocess( const TimelineContext& ctx, TaskDispatch& td ) override; void Preprocess( const TimelineContext& ctx, TaskDispatch& td, bool visible ) override;
private: private:
#ifndef TRACY_NO_STATISTICS #ifndef TRACY_NO_STATISTICS