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;
}
}
+6
View File
@@ -54,6 +54,8 @@ public:
TimeRuler* ruler() const;
virtual bool eventFilter(QObject* object, QEvent* event) override;
public slots:
void SetTimestamp(int64_t timestamp);
@@ -121,6 +123,8 @@ protected:
void ConnectTimelineView(TimelineViewBase* base);
void PassWheelEventsToScrollBar(QObject* object);
protected slots:
/**
* @brief Slot to center the horizontal scroll bar on the playhead's current position
@@ -199,6 +203,8 @@ private:
bool auto_set_timebase_;
QVector<QObject*> wheel_passthrough_objects_;
private slots:
void UpdateMaximumScroll();
+1
View File
@@ -82,6 +82,7 @@ ViewerWidget::ViewerWidget(QWidget *parent) :
// Create waveform view when audio is connected and video isn't
waveform_view_ = new AudioWaveformView();
PassWheelEventsToScrollBar(waveform_view_);
stack_->addWidget(waveform_view_);
// Create time ruler