timeline: vastly improve behavior when scrolling and zooming

This commit is contained in:
itsmattkc
2023-02-28 20:39:02 -08:00
parent 9ff6e689d6
commit d0f16ef88e
5 changed files with 87 additions and 52 deletions
@@ -867,6 +867,34 @@ Block *TimelineView::GetItemAtScenePos(const rational &time, int track_index) co
return nullptr;
}
QVector<Block *> TimelineView::GetItemsAtSceneRect(const QRectF &rect) const
{
QVector<Block *> list;
if (connected_track_list_) {
rational start = this->SceneToTime(rect.left());
rational end = this->SceneToTime(rect.right());
for (int i = 0; i < connected_track_list_->GetTrackCount(); i++) {
Track *track = connected_track_list_->GetTrackAt(i);
int track_top = GetTrackY(i);
int track_bottom = track_top + GetTrackHeight(i);
if (track) {
if (!(track_bottom < rect.top() || track_top > rect.bottom())) {
Block *b = track->NearestBlockBeforeOrAt(start);
while (b && b->in() < end) {
list.append(b);
b = b->next();
}
}
}
}
}
return list;
}
void TimelineView::TrackListChanged()
{
UpdateSceneRect();