diff --git a/data/themes/classic/clone_bb_track_pattern.png b/data/themes/classic/clone_bb_track_pattern.png new file mode 100644 index 000000000..bf4b3669d Binary files /dev/null and b/data/themes/classic/clone_bb_track_pattern.png differ diff --git a/data/themes/default/clone_bb_track_pattern.png b/data/themes/default/clone_bb_track_pattern.png new file mode 100644 index 000000000..ed7d40fa1 Binary files /dev/null and b/data/themes/default/clone_bb_track_pattern.png differ diff --git a/include/BBEditor.h b/include/BBEditor.h index ed54beaf1..311ed5704 100644 --- a/include/BBEditor.h +++ b/include/BBEditor.h @@ -86,6 +86,7 @@ public slots: void removeSteps(); void addSampleTrack(); void addAutomationTrack(); + void clonePattern(); protected slots: void dropEvent(QDropEvent * de ) override; diff --git a/src/gui/editors/BBEditor.cpp b/src/gui/editors/BBEditor.cpp index 56fe29856..bfc16df5b 100644 --- a/src/gui/editors/BBEditor.cpp +++ b/src/gui/editors/BBEditor.cpp @@ -29,6 +29,7 @@ #include #include "ComboBox.h" +#include "BBTrack.h" #include "BBTrackContainer.h" #include "embed.h" #include "MainWindow.h" @@ -86,6 +87,8 @@ BBEditor::BBEditor( BBTrackContainer* tc ) : trackAndStepActionsToolBar->addAction(embed::getIconPixmap("add_bb_track"), tr("Add beat/bassline"), Engine::getSong(), SLOT(addBBTrack())); + trackAndStepActionsToolBar->addAction(embed::getIconPixmap("clone_bb_track_pattern"), tr("Clone beat/bassline pattern"), + m_trackContainerView, SLOT(clonePattern())); trackAndStepActionsToolBar->addAction( embed::getIconPixmap("add_sample_track"), tr("Add sample-track"), m_trackContainerView, @@ -311,3 +314,22 @@ void BBTrackContainerView::makeSteps( bool clone ) } } } + +// Creates a clone of the current BB track with the same pattern, but no TCOs in the song editor +// TODO: Avoid repeated code from cloneTrack and clearTrack in TrackOperationsWidget somehow +void BBTrackContainerView::clonePattern() +{ + // Get the current BBTrack id + BBTrackContainer *bbtc = static_cast(model()); + const int cur_bb = bbtc->currentBB(); + + BBTrack *bbt = BBTrack::findBBTrack(cur_bb); + + // Clone the track + Track *newTrack = bbt->clone(); + + // Track still have the TCOs which is undesirable in this case, clear the track + newTrack->lock(); + newTrack->deleteTCOs(); + newTrack->unlock(); +}