ported seekablewidget to timebasedview

Cuts down on a lot of code duplication and opens up usage of the new TimelineViewSelectionManager framework
This commit is contained in:
itsmattkc
2022-05-01 15:45:20 -07:00
parent f04ff5f1ff
commit cdcd83c09a
32 changed files with 425 additions and 1213 deletions
+15 -10
View File
@@ -38,6 +38,13 @@ AudioWaveformView::AudioWaveformView(QWidget *parent) :
{
setAutoFillBackground(true);
setBackgroundRole(QPalette::Base);
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
// NOTE: At some point it might make sense for this to be AlignCenter since the waveform
// originates from the center. But we're leaving it top/left for now since it was just
// ported from a QWidget's paintEvent.
setAlignment(Qt::AlignLeft | Qt::AlignTop);
}
void AudioWaveformView::SetViewer(AudioPlaybackCache *playback)
@@ -60,9 +67,9 @@ void AudioWaveformView::SetViewer(AudioPlaybackCache *playback)
}
}
void AudioWaveformView::paintEvent(QPaintEvent *event)
void AudioWaveformView::drawForeground(QPainter *p, const QRectF &rect)
{
super::paintEvent(event);
super::drawForeground(p, rect);
if (!playback_) {
return;
@@ -74,20 +81,18 @@ void AudioWaveformView::paintEvent(QPaintEvent *event)
return;
}
QPainter p(this);
// Draw in/out points
DrawTimelinePoints(&p);
DrawTimelinePoints(p);
// Draw waveform
p.setPen(QColor(64, 255, 160)); // FIXME: Hardcoded color
AudioVisualWaveform::DrawWaveform(&p, rect(), GetScale(), playback_->visual(), SceneToTime(GetScroll()));
p->setPen(QColor(64, 255, 160)); // FIXME: Hardcoded color
AudioVisualWaveform::DrawWaveform(p, rect.toRect(), GetScale(), playback_->visual(), SceneToTime(GetScroll()));
// Draw playhead
p.setPen(PLAYHEAD_COLOR);
p->setPen(PLAYHEAD_COLOR);
int playhead_x = TimeToScreen(GetTime());
p.drawLine(playhead_x, 0, playhead_x, height());
int playhead_x = TimeToScene(GetTime());
p->drawLine(playhead_x, 0, playhead_x, height());
}
}