Skip to content

Commit

Permalink
timebasedwidget: added infrastructure of passing scroll wheel signals…
Browse files Browse the repository at this point in the history
… to the scrollbar
  • Loading branch information
itsmattkc committed Nov 28, 2020
1 parent ee2deb1 commit 90edc4f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
17 changes: 17 additions & 0 deletions app/widget/timebased/timebased.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 changes: 6 additions & 0 deletions app/widget/timebased/timebased.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ class TimeBasedWidget : public TimelineScaledWidget

TimeRuler* ruler() const;

virtual bool eventFilter(QObject* object, QEvent* event) override;

public slots:
void SetTimestamp(int64_t timestamp);

Expand Down Expand Up @@ -121,6 +123,8 @@ protected slots:

void ConnectTimelineView(TimelineViewBase* base);

void PassWheelEventsToScrollBar(QObject* object);

protected slots:
/**
* @brief Slot to center the horizontal scroll bar on the playhead's current position
Expand Down Expand Up @@ -199,6 +203,8 @@ protected slots:

bool auto_set_timebase_;

QVector<QObject*> wheel_passthrough_objects_;

private slots:
void UpdateMaximumScroll();

Expand Down
1 change: 1 addition & 0 deletions app/widget/viewer/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 90edc4f

Please sign in to comment.