Merge pull request #1844 from curlymorphic/i457
Added option to duplicate first bar, in BBEditor
This commit is contained in:
BIN
data/themes/default/step_btn_duplicate.png
Normal file
BIN
data/themes/default/step_btn_duplicate.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 544 B |
@@ -82,6 +82,7 @@ public:
|
||||
|
||||
public slots:
|
||||
void addSteps();
|
||||
void cloneSteps();
|
||||
void removeSteps();
|
||||
void addAutomationTrack();
|
||||
|
||||
@@ -91,6 +92,7 @@ protected slots:
|
||||
|
||||
private:
|
||||
BBTrackContainer * m_bbtc;
|
||||
void makeSteps( bool clone );
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -127,6 +127,7 @@ protected:
|
||||
|
||||
protected slots:
|
||||
void addSteps();
|
||||
void cloneSteps();
|
||||
void removeSteps();
|
||||
void clear();
|
||||
void changeTimeSignature();
|
||||
|
||||
@@ -102,7 +102,9 @@ BBEditor::BBEditor( BBTrackContainer* tc ) :
|
||||
m_toolBar->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<Pattern *>( ( *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<Pattern *>( ( *it )->getTCO( m_bbtc->currentBB() ) );
|
||||
if( clone )
|
||||
{
|
||||
p->cloneSteps();
|
||||
} else
|
||||
{
|
||||
p->addSteps();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user