timebasedwidget: rewrote scroll catchup code

Code is much better. Less hacky queuing, implements cooldowns to improve navigation, and introduces a framework so that subclasses can make use of catchup/cooldown code too with any scrollbar they want
This commit is contained in:
itsmattkc
2022-07-15 10:59:51 -07:00
parent 4b8febd10d
commit e4fd2d5d2c
11 changed files with 103 additions and 20 deletions
+6 -6
View File
@@ -103,6 +103,7 @@ CurveWidget::CurveWidget(QWidget *parent) :
connect(view_, &CurveView::SelectionChanged, this, &CurveWidget::SelectionChanged);
connect(view_, &CurveView::ScaleChanged, this, &CurveWidget::SetScale);
connect(view_, &CurveView::Dragged, this, &CurveWidget::KeyframeViewDragged);
connect(view_, &CurveView::Released, this, &CurveWidget::KeyframeViewReleased);
// TimeBasedWidget's scrollbar has extra functionality that we can take advantage of
view_->setHorizontalScrollBar(scrollbar());
@@ -379,15 +380,14 @@ void CurveWidget::InputSelectionChanged(const NodeKeyframeTrackReference& ref)
void CurveWidget::KeyframeViewDragged(int x, int y)
{
QMetaObject::invokeMethod(this, "CatchUpScrollToPoint", Qt::QueuedConnection,
Q_ARG(int, x));
QMetaObject::invokeMethod(this, "CatchUpYScrollToPoint", Qt::QueuedConnection,
Q_ARG(int, y));
SetCatchUpScrollValue(x);
SetCatchUpScrollValue(view_->verticalScrollBar(), y, view_->height());
}
void CurveWidget::CatchUpYScrollToPoint(int point)
void CurveWidget::KeyframeViewReleased()
{
PageScrollInternal(view_->verticalScrollBar(), view_->height(), point, false);
StopCatchUpScrollTimer();
StopCatchUpScrollTimer(view_->verticalScrollBar());
}
}