timeline: copy waveform when copying
This commit is contained in:
@@ -164,7 +164,7 @@ void AudioVisualWaveform::OverwriteSums(const AudioVisualWaveform &sums, const r
|
||||
copy_len * sizeof(SamplePerChannel));
|
||||
}
|
||||
|
||||
length_ = qMax(length_, dest + length);
|
||||
length_ = qMax(length_, dest + ((length.isNull()) ? sums.length() - offset : length));
|
||||
}
|
||||
|
||||
void AudioVisualWaveform::OverwriteSilence(const rational &start, const rational &length)
|
||||
@@ -233,7 +233,7 @@ void AudioVisualWaveform::Shift(const rational &from, const rational &to)
|
||||
}
|
||||
}
|
||||
|
||||
length_ += (to-from);
|
||||
length_ = qMax(rational(0), length_ + (to-from));
|
||||
}
|
||||
|
||||
void AudioVisualWaveform::TrimIn(const rational &length)
|
||||
@@ -256,7 +256,16 @@ void AudioVisualWaveform::TrimIn(const rational &length)
|
||||
}
|
||||
}
|
||||
|
||||
length_ -= length;
|
||||
length_ = qMax(rational(0), length_ - length);
|
||||
}
|
||||
|
||||
AudioVisualWaveform AudioVisualWaveform::Mid(const rational &offset) const
|
||||
{
|
||||
AudioVisualWaveform mid = *this;
|
||||
|
||||
mid.TrimIn(offset);
|
||||
|
||||
return mid;
|
||||
}
|
||||
|
||||
AudioVisualWaveform::Sample AudioVisualWaveform::GetSummaryFromTime(const rational &start, const rational &length) const
|
||||
|
||||
@@ -94,6 +94,8 @@ public:
|
||||
|
||||
void TrimIn(const rational &length);
|
||||
|
||||
AudioVisualWaveform Mid(const rational &offset) const;
|
||||
|
||||
Sample GetSummaryFromTime(const rational& start, const rational& length) const;
|
||||
|
||||
static Sample SumSamples(const float* samples, int nb_samples, int nb_channels);
|
||||
|
||||
@@ -605,6 +605,9 @@ void PointerTool::FinishDrag(TimelineViewMouseEvent *event)
|
||||
// Duplicate rather than move
|
||||
// Place the copy instead of the original block
|
||||
block = static_cast<Block*>(Node::CopyNodeInGraph(block, command));
|
||||
if (ClipBlock *new_clip = dynamic_cast<ClipBlock*>(block)) {
|
||||
new_clip->waveform() = static_cast<ClipBlock*>(p.block)->waveform();
|
||||
}
|
||||
}
|
||||
|
||||
const Track::Reference& track_ref = p.ghost->GetAdjustedTrack();
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "timelineundosplit.h"
|
||||
|
||||
#include "node/block/clip/clip.h"
|
||||
#include "node/block/transition/transition.h"
|
||||
#include "widget/nodeview/nodeviewundo.h"
|
||||
|
||||
@@ -37,6 +38,10 @@ void BlockSplitCommand::redo()
|
||||
if (!reconnect_tree_command_) {
|
||||
reconnect_tree_command_ = new MultiUndoCommand();
|
||||
new_block_ = static_cast<Block*>(Node::CopyNodeInGraph(block_, reconnect_tree_command_));
|
||||
if (ClipBlock *new_clip = dynamic_cast<ClipBlock*>(new_block_)) {
|
||||
ClipBlock *old_clip = static_cast<ClipBlock*>(block_);
|
||||
new_clip->waveform() = old_clip->waveform();
|
||||
}
|
||||
}
|
||||
|
||||
reconnect_tree_command_->redo_now();
|
||||
|
||||
Reference in New Issue
Block a user