Skip to content

Commit

Permalink
Merge pull request #1553 from leeavital/1429-pattern-switch
Browse files Browse the repository at this point in the history
Implement 1429 -- move to next and previous pattern
  • Loading branch information
tresf committed Jan 13, 2015
2 parents 1459be1 + 7da4efd commit db2e7fe
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/Pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ class EXPORT Pattern : public TrackContentObject
void checkType();


// next/previous track based on position in the containing track
Pattern * previousPattern() const;
Pattern * nextPattern() const;

// settings-management
virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent );
virtual void loadSettings( const QDomElement & _this );
Expand Down Expand Up @@ -137,6 +141,8 @@ protected slots:
NoteVector m_notes;
int m_steps;

Pattern * adjacentPatternByOffset(int offset) const;

friend class PatternView;
friend class BBTrackContainerView;

Expand Down
15 changes: 15 additions & 0 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -967,6 +967,14 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke )
int amt = quantized ? quantization() : 1;
shiftPos( -amt );
}
else if( ke->modifiers() & Qt::AltModifier)
{
Pattern * p = m_pattern->previousPattern();
if(p != NULL)
{
setCurrentPattern(p);
}
}
else
{
// scroll
Expand Down Expand Up @@ -1001,6 +1009,13 @@ void PianoRoll::keyPressEvent(QKeyEvent* ke )
int amt = quantized ? quantization() : 1;
shiftPos( +amt );
}
else if( ke->modifiers() & Qt::AltModifier) {
Pattern * p = m_pattern->nextPattern();
if(p != NULL)
{
setCurrentPattern(p);
}
}
else
{
// scroll
Expand Down
26 changes: 26 additions & 0 deletions src/tracks/Pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,32 @@ void Pattern::loadSettings( const QDomElement & _this )



Pattern * Pattern::previousPattern() const
{
return adjacentPatternByOffset(-1);
}




Pattern * Pattern::nextPattern() const
{
return adjacentPatternByOffset(1);
}




Pattern * Pattern::adjacentPatternByOffset(int offset) const
{
QVector<TrackContentObject *> tcos = m_instrumentTrack->getTCOs();
int tcoNum = m_instrumentTrack->getTCONum(this);
return dynamic_cast<Pattern*>(tcos.value(tcoNum + offset, NULL));
}




void Pattern::clear()
{
addJournalCheckPoint();
Expand Down

0 comments on commit db2e7fe

Please sign in to comment.