moved autoscroll code to TimeBasedWidget rather than TimelineViewBase

Better place for it. Fixes #1406
This commit is contained in:
itsmattkc
2020-11-25 10:00:57 +11:00
parent bd2b3f7a7c
commit c7f5af9534
7 changed files with 37 additions and 41 deletions
@@ -25,7 +25,6 @@
#include <QScrollBar>
#include <QTimer>
#include "common/autoscroll.h"
#include "common/timecodefunctions.h"
#include "config/config.h"
@@ -115,18 +114,6 @@ void TimelineViewBase::SetTime(const int64_t time)
{
playhead_ = time;
switch (static_cast<AutoScroll::Method>(Config::Current()["Autoscroll"].toInt())) {
case AutoScroll::kNone:
// Do nothing
break;
case AutoScroll::kPage:
QMetaObject::invokeMethod(this, "PageScrollToPlayhead", Qt::QueuedConnection);
break;
case AutoScroll::kSmooth:
emit RequestCenterScrollOnPlayhead();
break;
}
// Force redraw for playhead
viewport()->update();
}
@@ -257,21 +244,6 @@ void TimelineViewBase::UpdateSceneRect()
}
}
void TimelineViewBase::PageScrollToPlayhead()
{
int playhead_pos = qRound(GetPlayheadX());
int viewport_padding = viewport()->width() / 16;
if (playhead_pos < horizontalScrollBar()->value()) {
// Anchor the playhead to the RIGHT of where we scroll to
horizontalScrollBar()->setValue(playhead_pos - viewport()->width() + viewport_padding);
} else if (playhead_pos > horizontalScrollBar()->value() + viewport()->width()) {
// Anchor the playhead to the LEFT of where we scroll to
horizontalScrollBar()->setValue(playhead_pos - viewport_padding);
}
}
void TimelineViewBase::resizeEvent(QResizeEvent *event)
{
QGraphicsView::resizeEvent(event);