From ca414dab10445809a3f25324e113dbaa551f8ae1 Mon Sep 17 00:00:00 2001 From: Dave French Date: Mon, 9 Mar 2015 17:23:22 +0000 Subject: [PATCH] Added option to duplicate first bar, in BBEditor Added a new button to the action bar, using step_btn_duplicate.png The new button, aswell as adding a bar to the patten, then copies the first bar to the last. fixes #457 BBEditor Duplicate Pattern. updated image, changed function name Have updated the new image step_button_duplicate.png Renamed the function from duplicateFirstBarAtEnd to duplicateSteps. BBEditor renamed function duplicateSteps renamed duplicateSteps() to cloneSteps() as requested BBEditor rechange duplicateSteps to cloneSteps BB Editor changed actionBtn text from duplicate to clone --- data/themes/default/step_btn_duplicate.png | Bin 0 -> 544 bytes include/BBEditor.h | 2 + include/Pattern.h | 1 + src/gui/editors/BBEditor.cpp | 43 +++++++++++++++------ src/tracks/Pattern.cpp | 23 +++++++++++ 5 files changed, 58 insertions(+), 11 deletions(-) create mode 100644 data/themes/default/step_btn_duplicate.png diff --git a/data/themes/default/step_btn_duplicate.png b/data/themes/default/step_btn_duplicate.png new file mode 100644 index 0000000000000000000000000000000000000000..af9521fad20c4285888f1a1d4a5e98744850dd32 GIT binary patch literal 544 zcmV+*0^j|KP)ymGz!Jxtq>LEyKHWFPxJ`R4a~`Mzfr3Wd`k2ow=nxQR)U zM22B_Af;Sqc|j0Rar@IF+(ELrG0Np~EKj6qiu*9efa?ik3`^vCtO?UJ1=kZqbgxK6 z;Cif;C+l!{_zC|@pfLtq@4;&$IdveSX>B@3P5k_@1(J_LZBBqA2_vMbY8dX;|PQtk`+Fq@addAction(embed::getIconPixmap("step_btn_remove"), tr("Remove steps"), m_trackContainerView, SLOT(removeSteps())); m_toolBar->addAction(embed::getIconPixmap("step_btn_add"), tr("Add steps"), - m_trackContainerView, SLOT(addSteps())); + m_trackContainerView, SLOT( addSteps())); + m_toolBar->addAction( embed::getIconPixmap( "step_btn_duplicate" ), tr( "Clone Steps" ), + m_trackContainerView, SLOT( cloneSteps() ) ); m_toolBar->addSeparator(); connect( &tc->m_bbComboBoxModel, SIGNAL( dataChanged() ), @@ -170,17 +172,12 @@ BBTrackContainerView::BBTrackContainerView(BBTrackContainer* tc) : void BBTrackContainerView::addSteps() { - TrackContainer::TrackList tl = model()->tracks(); + makeSteps( false ); +} - for( TrackContainer::TrackList::iterator it = tl.begin(); - it != tl.end(); ++it ) - { - if( ( *it )->type() == Track::InstrumentTrack ) - { - Pattern* p = static_cast( ( *it )->getTCO( m_bbtc->currentBB() ) ); - p->addSteps(); - } - } +void BBTrackContainerView::cloneSteps() +{ + makeSteps( true ); } @@ -264,3 +261,27 @@ void BBTrackContainerView::updatePosition() //realignTracks(); emit positionChanged( m_currentPosition ); } + + + + +void BBTrackContainerView::makeSteps( bool clone ) +{ + TrackContainer::TrackList tl = model()->tracks(); + + for( TrackContainer::TrackList::iterator it = tl.begin(); + it != tl.end(); ++it ) + { + if( ( *it )->type() == Track::InstrumentTrack ) + { + Pattern* p = static_cast( ( *it )->getTCO( m_bbtc->currentBB() ) ); + if( clone ) + { + p->cloneSteps(); + } else + { + p->addSteps(); + } + } + } +} diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index cea27895a..e9ba69d9f 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -478,6 +478,29 @@ void Pattern::addSteps() updateBBTrack(); } +void Pattern::cloneSteps() +{ + int oldLength = m_steps; + m_steps += MidiTime::stepsPerTact(); + ensureBeatNotes(); + for(int i = 0; i < MidiTime::stepsPerTact(); ++i ) + { + Note *toCopy = noteAtStep( i ); + if( toCopy ) + { + setStep( oldLength + i, true ); + Note *newNote = noteAtStep( oldLength + i ); + newNote->setKey( toCopy->key() ); + newNote->setLength( toCopy->length() ); + newNote->setPanning( toCopy->getPanning() ); + newNote->setVolume( toCopy->getVolume() ); + } + } + ensureBeatNotes(); + emit dataChanged(); + updateBBTrack(); +} +