Skip to content

Commit

Permalink
Merge pull request LMMS#1844 from curlymorphic/i457
Browse files Browse the repository at this point in the history
Added option to duplicate first bar, in BBEditor
  • Loading branch information
tresf committed Mar 12, 2015
2 parents c470bda + ca414da commit 7676878
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 11 deletions.
Binary file added data/themes/default/step_btn_duplicate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions include/BBEditor.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class BBTrackContainerView : public TrackContainerView

public slots:
void addSteps();
void cloneSteps();
void removeSteps();
void addAutomationTrack();

Expand All @@ -91,6 +92,7 @@ protected slots:

private:
BBTrackContainer * m_bbtc;
void makeSteps( bool clone );
};


Expand Down
1 change: 1 addition & 0 deletions include/Pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class EXPORT Pattern : public TrackContentObject

protected slots:
void addSteps();
void cloneSteps();
void removeSteps();
void clear();
void changeTimeSignature();
Expand Down
43 changes: 32 additions & 11 deletions src/gui/editors/BBEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() ),
Expand Down Expand Up @@ -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 );
}


Expand Down Expand Up @@ -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();
}
}
}
}
23 changes: 23 additions & 0 deletions src/tracks/Pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}




Expand Down

0 comments on commit 7676878

Please sign in to comment.