From 503006057c22c2f91d3f3fa44522d541bc263b3b Mon Sep 17 00:00:00 2001 From: IanCaio Date: Thu, 11 Jun 2020 01:12:42 -0300 Subject: [PATCH 1/2] 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. --- .../themes/classic/clone_bb_track_pattern.png | Bin 0 -> 614 bytes .../themes/default/clone_bb_track_pattern.png | Bin 0 -> 208 bytes include/BBEditor.h | 1 + src/gui/editors/BBEditor.cpp | 21 ++++++++++++++++++ 4 files changed, 22 insertions(+) create mode 100644 data/themes/classic/clone_bb_track_pattern.png create mode 100644 data/themes/default/clone_bb_track_pattern.png 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 0000000000000000000000000000000000000000..bf4b3669d816be1f834204a21be141ef63f9d3b2 GIT binary patch literal 614 zcmV-s0-61ZP)@uC87km@NO2K2hKTs-v{R$oO5`dcaw}UmjIqn2(P%o7;~U} zaaGRe^UwSJo_4z(F~;7MfJEf-5$vB~$=1&UjWN(#!x-bhRUOp9OF*r)nCD{{7|K z)>_|~*4b79?F=oj(P)%@!#IxJ_gX`1U@dJyah})f6|2<>&1Tct-ZiwBVnYalG)(oLI?;UlG$wb97Rz`L|;lkI}dv)*7AHlW4qmAFc_fKYC#BrBuP%w z>Gb({JcdN{wX)^qa`|qtSiA>-AP8P8&=^yM{hmxFAEcD8MD#7sV0Ev4v)K@Ul5HHv zKgZ+oN2Sz;h`tx={NhHHZ9bwX5&%LX`cYN)7wC@35d~K%rT_o{07*qoM6N<$g8q#O A(EtDd literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..ed7d40fa191d288ad3fb13ca97be9166e90373ce GIT binary patch literal 208 zcmeAS@N?(olHy`uVBq!ia0vp^A|TAc1|)ksWqE-VOR^eP*AeOHKHUqKdq!Zu_%?Hyu4g5GcUV1Ik6yBFTW^#_B$IXpdw#S7sn8b z-sCA0f)f|0B_t*!BvkzS@U6bc#QW50qeb0@fv=QG4mh1~3u4TTBD)z4*}Q$iB}F@!?5 literal 0 HcmV?d00001 diff --git a/include/BBEditor.h b/include/BBEditor.h index ed54beaf1..8743bfe98 100644 --- a/include/BBEditor.h +++ b/include/BBEditor.h @@ -86,6 +86,7 @@ public slots: void removeSteps(); void addSampleTrack(); void addAutomationTrack(); + void cloneBBTrackPattern(); protected slots: void dropEvent(QDropEvent * de ) override; diff --git a/src/gui/editors/BBEditor.cpp b/src/gui/editors/BBEditor.cpp index 56fe29856..1e5c2f900 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(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(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(); +} From b1c1d146013ac2b47d3cec0c15ab99236bc97682 Mon Sep 17 00:00:00 2001 From: IanCaio Date: Sat, 13 Jun 2020 12:14:47 -0300 Subject: [PATCH 2/2] Changes the clone pattern method name - Changes method name from cloneBBTrackPattern to clonePattern - Small fix on the comments - Adds a TODO comment regarding reusing the code from TrackOperationsWidget as a reference, so we can later figure out a way to not repeat the code --- include/BBEditor.h | 2 +- src/gui/editors/BBEditor.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/include/BBEditor.h b/include/BBEditor.h index 8743bfe98..311ed5704 100644 --- a/include/BBEditor.h +++ b/include/BBEditor.h @@ -86,7 +86,7 @@ public slots: void removeSteps(); void addSampleTrack(); void addAutomationTrack(); - void cloneBBTrackPattern(); + void clonePattern(); protected slots: void dropEvent(QDropEvent * de ) override; diff --git a/src/gui/editors/BBEditor.cpp b/src/gui/editors/BBEditor.cpp index 1e5c2f900..bfc16df5b 100644 --- a/src/gui/editors/BBEditor.cpp +++ b/src/gui/editors/BBEditor.cpp @@ -88,7 +88,7 @@ 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())); + m_trackContainerView, SLOT(clonePattern())); trackAndStepActionsToolBar->addAction( embed::getIconPixmap("add_sample_track"), tr("Add sample-track"), m_trackContainerView, @@ -315,8 +315,9 @@ 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() +// 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());