Adds a button to clone the BB track pattern

Adds a button on the BBEditor that clones the current BB track pattern, but without also cloning the song editor TCOs. That can be useful when an user is editing drumlines and wants to make a section with a slight variation for example.
This commit is contained in:
IanCaio
2020-06-11 01:12:42 -03:00
parent 8c7e63b35b
commit 503006057c
4 changed files with 22 additions and 0 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 614 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 208 B

View File

@@ -86,6 +86,7 @@ public slots:
void removeSteps();
void addSampleTrack();
void addAutomationTrack();
void cloneBBTrackPattern();
protected slots:
void dropEvent(QDropEvent * de ) override;

View File

@@ -29,6 +29,7 @@
#include <QLayout>
#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(cloneBBTrackPattern()));
trackAndStepActionsToolBar->addAction(
embed::getIconPixmap("add_sample_track"),
tr("Add sample-track"), m_trackContainerView,
@@ -311,3 +314,21 @@ void BBTrackContainerView::makeSteps( bool clone )
}
}
}
// Creates a clone of the current BB track with the same pattern, but with no TCOs on the song editor
void BBTrackContainerView::cloneBBTrackPattern()
{
// Get the current BBTrack id
BBTrackContainer *bbtc = static_cast<BBTrackContainer*>(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();
}