timebasedwidget: added infrastructure of passing scroll wheel signals to the scrollbar

This commit is contained in:
itsmattkc
2020-11-29 10:08:37 +11:00
parent ee2deb1365
commit 90edc4f933
3 changed files with 24 additions and 0 deletions
+17
View File
@@ -45,6 +45,8 @@ TimeBasedWidget::TimeBasedWidget(bool ruler_text_visible, bool ruler_cache_statu
scrollbar_ = new ResizableScrollBar(Qt::Horizontal, this);
connect(scrollbar_, &ResizableScrollBar::RequestScale, this, &TimeBasedWidget::ScrollBarResized);
PassWheelEventsToScrollBar(ruler_);
}
void TimeBasedWidget::SetScaleAndCenterOnPlayhead(const double &scale)
@@ -237,6 +239,12 @@ void TimeBasedWidget::ConnectTimelineView(TimelineViewBase *base)
timeline_views_.append(base);
}
void TimeBasedWidget::PassWheelEventsToScrollBar(QObject *object)
{
wheel_passthrough_objects_.append(object);
object->installEventFilter(this);
}
void TimeBasedWidget::SetTimestamp(int64_t timestamp)
{
ruler_->SetTime(timestamp);
@@ -570,4 +578,13 @@ void TimeBasedWidget::MarkerAddCommand::undo_internal()
marker_list_->RemoveMarker(added_marker_);
}
bool TimeBasedWidget::eventFilter(QObject *object, QEvent *event)
{
if (wheel_passthrough_objects_.contains(object) && event->type() == QEvent::Wheel) {
QCoreApplication::sendEvent(scrollbar(), event);
}
return false;
}
}