Skip to content

Commit

Permalink
Merge pull request #5531 from IanCaio/feature/cloneBBTrackPattern
Browse files Browse the repository at this point in the history
Adds a button to clone the current BB track pattern inside the BB Editor
  • Loading branch information
Spekular committed Jun 15, 2020
2 parents 8c7e63b + b1c1d14 commit 733a411
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
Binary file added data/themes/classic/clone_bb_track_pattern.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/themes/default/clone_bb_track_pattern.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions include/BBEditor.h
Expand Up @@ -86,6 +86,7 @@ public slots:
void removeSteps();
void addSampleTrack();
void addAutomationTrack();
void clonePattern();

protected slots:
void dropEvent(QDropEvent * de ) override;
Expand Down
22 changes: 22 additions & 0 deletions src/gui/editors/BBEditor.cpp
Expand Up @@ -29,6 +29,7 @@
#include <QLayout>

#include "ComboBox.h"
#include "BBTrack.h"
#include "BBTrackContainer.h"
#include "embed.h"
#include "MainWindow.h"
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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<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();
}

0 comments on commit 733a411

Please sign in to comment.