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:
@@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user