Merge pull request #1553 from leeavital/1429-pattern-switch

Implement 1429 -- move to next and previous pattern
This commit is contained in:
Tres Finocchiaro
2015-01-12 21:23:00 -05:00
3 changed files with 47 additions and 0 deletions

View File

@@ -94,6 +94,10 @@ public:
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 );
@@ -137,6 +141,8 @@ private:
NoteVector m_notes;
int m_steps;
Pattern * adjacentPatternByOffset(int offset) const;
friend class PatternView;
friend class BBTrackContainerView;

View File

@@ -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
@@ -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

View File

@@ -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();