moved visual waveforms to block

This should be nicer, however it has a bug that I need to fix
This commit is contained in:
itsmattkc
2021-08-01 16:43:53 -07:00
parent 6995ffe015
commit be4a18d7de
13 changed files with 95 additions and 54 deletions
+2 -2
View File
@@ -893,6 +893,7 @@ void TimelineWidget::AddBlock(Block *block)
connect(block, &Block::LabelChanged, this, &TimelineWidget::BlockUpdated);
connect(block, &Block::ColorChanged, this, &TimelineWidget::BlockUpdated);
connect(block, &Block::EnabledChanged, this, &TimelineWidget::BlockUpdated);
connect(block, &Block::PreviewChanged, this, &TimelineWidget::BlockUpdated);
added_blocks_.append(block);
}
@@ -905,6 +906,7 @@ void TimelineWidget::RemoveBlock(Block *block)
disconnect(block, &Block::LabelChanged, this, &TimelineWidget::BlockUpdated);
disconnect(block, &Block::ColorChanged, this, &TimelineWidget::BlockUpdated);
disconnect(block, &Block::EnabledChanged, this, &TimelineWidget::BlockUpdated);
disconnect(block, &Block::PreviewChanged, this, &TimelineWidget::BlockUpdated);
// Take item from map
added_blocks_.removeOne(block);
@@ -927,7 +929,6 @@ void TimelineWidget::AddTrack(Track *track)
connect(track, &Track::IndexChanged, this, &TimelineWidget::TrackUpdated);
connect(track, &Track::IndexChanged, this, &TimelineWidget::TrackIndexChanged);
connect(track, &Track::PreviewChanged, this, &TimelineWidget::TrackUpdated);
connect(track, &Track::BlocksRefreshed, this, &TimelineWidget::TrackUpdated);
connect(track, &Track::TrackHeightChangedInPixels, this, &TimelineWidget::TrackUpdated);
connect(track, &Track::BlockAdded, this, &TimelineWidget::AddBlock);
@@ -938,7 +939,6 @@ void TimelineWidget::RemoveTrack(Track *track)
{
disconnect(track, &Track::IndexChanged, this, &TimelineWidget::TrackUpdated);
disconnect(track, &Track::IndexChanged, this, &TimelineWidget::TrackIndexChanged);
disconnect(track, &Track::PreviewChanged, this, &TimelineWidget::TrackUpdated);
disconnect(track, &Track::BlocksRefreshed, this, &TimelineWidget::TrackUpdated);
disconnect(track, &Track::TrackHeightChangedInPixels, this, &TimelineWidget::TrackUpdated);
disconnect(track, &Track::BlockAdded, this, &TimelineWidget::AddBlock);
@@ -403,7 +403,9 @@ void TimelineView::DrawBlocks(QPainter *painter, bool foreground)
while (block) {
if (dynamic_cast<ClipBlock*>(block) || dynamic_cast<TransitionBlock*>(block)) {
qreal block_left = qMax(left_bound, TimeToScene(block->in()));
qreal block_in = TimeToScene(block->in());
qreal block_left = qMax(left_bound, block_in);
qreal block_right = qMin(right_bound, TimeToScene(block->out())) - 1;
qreal block_top = GetTrackY(track->Index());
qreal block_height = GetTrackHeight(track->Index());
@@ -454,15 +456,16 @@ void TimelineView::DrawBlocks(QPainter *painter, bool foreground)
// Draw waveform
if (show_waveforms_) {
QRect waveform_rect = r.adjusted(0, text_total_height, 0, 0).toRect();
painter->setPen(shadow_color);
AudioVisualWaveform::DrawWaveform(painter, waveform_rect, this->GetScale(), track->waveform(),
SceneToTime(block_left, GetScale(), connected_track_list_->parent()->GetAudioParams().sample_rate_as_time_base()));
if (ClipBlock *clip = dynamic_cast<ClipBlock*>(block)) {
QRect waveform_rect = r.adjusted(0, text_total_height, 0, 0).toRect();
painter->setPen(shadow_color);
AudioVisualWaveform::DrawWaveform(painter, waveform_rect, this->GetScale(), clip->waveform(),
SceneToTime(block_left - block_in, GetScale(), connected_track_list_->parent()->GetAudioParams().sample_rate_as_time_base()));
}
}
// For transitions, show lines representing a transition
TransitionBlock* transition = dynamic_cast<TransitionBlock*>(block);
if (transition) {
if (TransitionBlock* transition = dynamic_cast<TransitionBlock*>(block)) {
QVector<QLineF> lines;
if (transition->connected_in_block()) {