mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-29 22:58:39 +02:00
Don't create placeholder clips in Duplicate command ...
... when there is no clip at the right edge of the selection.
This commit is contained in:
parent
65c722bfe5
commit
25619fb46e
@ -2361,7 +2361,7 @@ Track::Holder LabelTrack::SplitCut(double t0, double t1)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Track::Holder LabelTrack::Copy(double t0, double t1) const
|
Track::Holder LabelTrack::Copy(double t0, double t1, bool) const
|
||||||
{
|
{
|
||||||
auto tmp = std::make_unique<LabelTrack>(GetDirManager());
|
auto tmp = std::make_unique<LabelTrack>(GetDirManager());
|
||||||
const auto lt = static_cast<LabelTrack*>(tmp.get());
|
const auto lt = static_cast<LabelTrack*>(tmp.get());
|
||||||
|
@ -155,11 +155,7 @@ class AUDACITY_DLL_API LabelTrack final : public Track
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
Track::Holder Cut (double t0, double t1) override;
|
Track::Holder Cut (double t0, double t1) override;
|
||||||
// JKC Do not add the const modifier to Copy(), Clear()
|
Track::Holder Copy (double t0, double t1, bool forClipboard = true) const override;
|
||||||
// or Paste() because then it
|
|
||||||
// is no longer recognised as a virtual function matching the
|
|
||||||
// one in Track.
|
|
||||||
Track::Holder Copy (double t0, double t1) const override;
|
|
||||||
bool Clear(double t0, double t1) override;
|
bool Clear(double t0, double t1) override;
|
||||||
bool Paste(double t, const Track * src) override;
|
bool Paste(double t, const Track * src) override;
|
||||||
bool Repeat(double t0, double t1, int n);
|
bool Repeat(double t0, double t1, int n);
|
||||||
|
@ -4789,8 +4789,9 @@ void AudacityProject::OnDuplicate()
|
|||||||
|
|
||||||
while (n) {
|
while (n) {
|
||||||
if (n->GetSelected()) {
|
if (n->GetSelected()) {
|
||||||
|
// Make copies not for clipboard but for direct addition to the project
|
||||||
auto dest = n->Copy(mViewInfo.selectedRegion.t0(),
|
auto dest = n->Copy(mViewInfo.selectedRegion.t0(),
|
||||||
mViewInfo.selectedRegion.t1());
|
mViewInfo.selectedRegion.t1(), false);
|
||||||
if (dest) {
|
if (dest) {
|
||||||
dest->Init(*n);
|
dest->Init(*n);
|
||||||
dest->SetOffset(wxMax(mViewInfo.selectedRegion.t0(), n->GetOffset()));
|
dest->SetOffset(wxMax(mViewInfo.selectedRegion.t0(), n->GetOffset()));
|
||||||
|
@ -454,7 +454,7 @@ Track::Holder NoteTrack::Cut(double t0, double t1)
|
|||||||
return std::move(newTrack);
|
return std::move(newTrack);
|
||||||
}
|
}
|
||||||
|
|
||||||
Track::Holder NoteTrack::Copy(double t0, double t1) const
|
Track::Holder NoteTrack::Copy(double t0, double t1, bool) const
|
||||||
{
|
{
|
||||||
if (t1 <= t0)
|
if (t1 <= t0)
|
||||||
return{};
|
return{};
|
||||||
|
@ -91,7 +91,7 @@ class AUDACITY_DLL_API NoteTrack final : public Track {
|
|||||||
|
|
||||||
// High-level editing
|
// High-level editing
|
||||||
Track::Holder Cut (double t0, double t1) override;
|
Track::Holder Cut (double t0, double t1) override;
|
||||||
Track::Holder Copy (double t0, double t1) const override;
|
Track::Holder Copy (double t0, double t1, bool forClipboard = true) const override;
|
||||||
bool Trim (double t0, double t1) /* not override */;
|
bool Trim (double t0, double t1) /* not override */;
|
||||||
bool Clear(double t0, double t1) override;
|
bool Clear(double t0, double t1) override;
|
||||||
bool Paste(double t, const Track *src) override;
|
bool Paste(double t, const Track *src) override;
|
||||||
|
@ -4905,6 +4905,7 @@ void AudacityProject::EditClipboardByLabel( EditDestFunction action )
|
|||||||
if( n->GetKind() == Track::Wave && ( allTracks || n->GetSelected() ) )
|
if( n->GetKind() == Track::Wave && ( allTracks || n->GetSelected() ) )
|
||||||
{
|
{
|
||||||
WaveTrack *wt = ( WaveTrack* )n;
|
WaveTrack *wt = ( WaveTrack* )n;
|
||||||
|
// This track accumulates the needed clips, right to left:
|
||||||
Track::Holder merged;
|
Track::Holder merged;
|
||||||
for( int i = (int)regions.size() - 1; i >= 0; i-- )
|
for( int i = (int)regions.size() - 1; i >= 0; i-- )
|
||||||
{
|
{
|
||||||
@ -4923,6 +4924,11 @@ void AudacityProject::EditClipboardByLabel( EditDestFunction action )
|
|||||||
merged->Offset(
|
merged->Offset(
|
||||||
regions.at(i + 1).start - region.end);
|
regions.at(i + 1).start - region.end);
|
||||||
|
|
||||||
|
// dest may have a placeholder clip at the end that is
|
||||||
|
// removed when pasting, which is okay because we proceed
|
||||||
|
// right to left. Any placeholder already in merged is kept.
|
||||||
|
// Only the rightmost placeholder is important in the final
|
||||||
|
// result.
|
||||||
bool bResult = merged->Paste( 0.0 , dest.get() );
|
bool bResult = merged->Paste( 0.0 , dest.get() );
|
||||||
wxASSERT(bResult); // TO DO: Actually handle this.
|
wxASSERT(bResult); // TO DO: Actually handle this.
|
||||||
wxUnusedVar(bResult);
|
wxUnusedVar(bResult);
|
||||||
|
@ -216,7 +216,11 @@ class AUDACITY_DLL_API Track /* not final */ : public XMLTagHandler
|
|||||||
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1)) { return{}; }
|
virtual Holder Cut(double WXUNUSED(t0), double WXUNUSED(t1)) { return{}; }
|
||||||
|
|
||||||
// Create a NEW track and don't modify this track (or return null for failure)
|
// Create a NEW track and don't modify this track (or return null for failure)
|
||||||
virtual Holder Copy(double WXUNUSED(t0), double WXUNUSED(t1)) const { return{}; }
|
// Note that subclasses may want to distinguish tracks stored in a clipboard
|
||||||
|
// from those stored in a project
|
||||||
|
virtual Holder Copy
|
||||||
|
(double WXUNUSED(t0), double WXUNUSED(t1), bool forClipboard = true) const
|
||||||
|
{ return{}; }
|
||||||
|
|
||||||
// Return true for success
|
// Return true for success
|
||||||
virtual bool Clear(double WXUNUSED(t0), double WXUNUSED(t1)) {return false;}
|
virtual bool Clear(double WXUNUSED(t0), double WXUNUSED(t1)) {return false;}
|
||||||
|
@ -630,7 +630,7 @@ bool WaveTrack::Trim (double t0, double t1)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
Track::Holder WaveTrack::Copy(double t0, double t1) const
|
Track::Holder WaveTrack::Copy(double t0, double t1, bool forClipboard) const
|
||||||
{
|
{
|
||||||
if (t1 <= t0)
|
if (t1 <= t0)
|
||||||
return{};
|
return{};
|
||||||
@ -695,7 +695,10 @@ Track::Holder WaveTrack::Copy(double t0, double t1) const
|
|||||||
|
|
||||||
// AWD, Oct 2009: If the selection ends in whitespace, create a placeholder
|
// AWD, Oct 2009: If the selection ends in whitespace, create a placeholder
|
||||||
// clip representing that whitespace
|
// clip representing that whitespace
|
||||||
if (newTrack->GetEndTime() + 1.0 / newTrack->GetRate() < t1 - t0)
|
// PRL: Only if we want the track for pasting into other tracks. Not if it
|
||||||
|
// goes directly into a project as in the Duplicate command.
|
||||||
|
if (forClipboard &&
|
||||||
|
newTrack->GetEndTime() + 1.0 / newTrack->GetRate() < t1 - t0)
|
||||||
{
|
{
|
||||||
auto placeholder = make_movable<WaveClip>(mDirManager,
|
auto placeholder = make_movable<WaveClip>(mDirManager,
|
||||||
newTrack->GetSampleFormat(),
|
newTrack->GetSampleFormat(),
|
||||||
|
@ -167,8 +167,14 @@ class AUDACITY_DLL_API WaveTrack final : public Track {
|
|||||||
//
|
//
|
||||||
|
|
||||||
Track::Holder Cut(double t0, double t1) override;
|
Track::Holder Cut(double t0, double t1) override;
|
||||||
Track::Holder Copy(double t0, double t1) const override;
|
|
||||||
|
// If forClipboard is true,
|
||||||
|
// and there is no clip at the end time of the selection, then the result
|
||||||
|
// will contain a "placeholder" clip whose only purpose is to make
|
||||||
|
// GetEndTime() correct. This clip is not re-copied when pasting.
|
||||||
|
Track::Holder Copy(double t0, double t1, bool forClipboard = true) const override;
|
||||||
Track::Holder CopyNonconst(double t0, double t1) /* not override */;
|
Track::Holder CopyNonconst(double t0, double t1) /* not override */;
|
||||||
|
|
||||||
bool Clear(double t0, double t1) override;
|
bool Clear(double t0, double t1) override;
|
||||||
bool Paste(double t0, const Track *src) override;
|
bool Paste(double t0, const Track *src) override;
|
||||||
bool ClearAndPaste(double t0, double t1,
|
bool ClearAndPaste(double t0, double t1,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user