shift timelineview scroll code into base classes

Fixes #2060
This commit is contained in:
itsmattkc
2022-10-24 12:01:47 -07:00
parent f81445527f
commit bdbfb56879
8 changed files with 61 additions and 84 deletions
+3 -19
View File
@@ -51,9 +51,6 @@ TimeBasedWidget::TimeBasedWidget(bool ruler_text_visible, bool ruler_cache_statu
ConnectTimelineView(ruler_, true);
ruler()->SetSnapService(this);
connect(ruler(), &TimeRuler::DragReleased, this, static_cast<void(TimeBasedWidget::*)()>(&TimeBasedWidget::StopCatchUpScrollTimer));
connect(scrollbar(), &QScrollBar::valueChanged, ruler(), &TimeRuler::SetScroll);
PassWheelEventsToScrollBar(ruler_);
catchup_scroll_timer_ = new QTimer(this);
catchup_scroll_timer_->setInterval(250); // Hardcoded 1/4 scroll limit value
@@ -307,12 +304,14 @@ void TimeBasedWidget::ConnectTimelineView(TimeBasedView *base, bool connect_time
connect(base, &TimeBasedView::TimeChanged, this, &TimeBasedWidget::SetTimeAndSignal);
}
// Connect scale
connect(base, &TimeBasedView::ScaleChanged, this, &TimeBasedWidget::SetScale);
// Main scrollbar to view scrollbar and vice versa
connect(scrollbar(), &QScrollBar::valueChanged, base->horizontalScrollBar(), &QScrollBar::setValue);
connect(base->horizontalScrollBar(), &QScrollBar::valueChanged, scrollbar(), &QScrollBar::setValue);
connect(base->horizontalScrollBar(), &QScrollBar::valueChanged, ruler(), &TimeRuler::SetScroll);
// Connect scrollbar to other scrollbars
for (TimeBasedView *other : qAsConst(timeline_views_)) {
connect(other->horizontalScrollBar(), &QScrollBar::valueChanged, base->horizontalScrollBar(), &QScrollBar::setValue);
connect(base->horizontalScrollBar(), &QScrollBar::valueChanged, other->horizontalScrollBar(), &QScrollBar::setValue);
@@ -321,12 +320,6 @@ void TimeBasedWidget::ConnectTimelineView(TimeBasedView *base, bool connect_time
timeline_views_.append(base);
}
void TimeBasedWidget::PassWheelEventsToScrollBar(QObject *object)
{
wheel_passthrough_objects_.append(object);
object->installEventFilter(this);
}
void TimeBasedWidget::SetCatchUpScrollValue(QScrollBar *b, int v, int maximum)
{
CatchUpScrollData &cudata = catchup_scroll_values_[b];
@@ -758,15 +751,6 @@ void TimeBasedWidget::DeleteSelected()
}
}
bool TimeBasedWidget::eventFilter(QObject *object, QEvent *event)
{
if (wheel_passthrough_objects_.contains(object) && event->type() == QEvent::Wheel) {
QCoreApplication::sendEvent(scrollbar(), event);
}
return false;
}
struct SnapData {
rational time;
rational movement;