From 9e791ce749c2751e1fba78cc746395a4e1f8f9ef Mon Sep 17 00:00:00 2001 From: Oskar Wallgren Date: Thu, 16 Feb 2017 01:17:46 +0100 Subject: [PATCH] 'Off beat' beat notes to MelodyPattern --- include/Pattern.h | 3 +-- src/gui/editors/PianoRoll.cpp | 5 +++++ src/tracks/Pattern.cpp | 10 ++++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/include/Pattern.h b/include/Pattern.h index 41b76553c17..94eef796c06 100644 --- a/include/Pattern.h +++ b/include/Pattern.h @@ -88,7 +88,7 @@ class EXPORT Pattern : public TrackContentObject { return m_patternType; } - + void checkType(); // next/previous track based on position in the containing track Pattern * previousPattern() const; @@ -132,7 +132,6 @@ protected slots: MidiTime beatPatternLength() const; void setType( PatternTypes _new_pattern_type ); - void checkType(); void resizeToFirstTrack(); diff --git a/src/gui/editors/PianoRoll.cpp b/src/gui/editors/PianoRoll.cpp index 52cdd585e5c..adbf64f1889 100644 --- a/src/gui/editors/PianoRoll.cpp +++ b/src/gui/editors/PianoRoll.cpp @@ -2451,6 +2451,11 @@ void PianoRoll::dragNotes( int x, int y, bool alt, bool shift, bool ctrl ) note->setPos( MidiTime( pos_ticks ) ); note->setKey( key_num ); + // If dragging beat notes check if pattern should be MelodyPattern + if( note->length() < 0 ) + { + m_pattern->checkType(); + } } } } diff --git a/src/tracks/Pattern.cpp b/src/tracks/Pattern.cpp index 1edaa868553..d3e3c1bda51 100644 --- a/src/tracks/Pattern.cpp +++ b/src/tracks/Pattern.cpp @@ -369,7 +369,9 @@ void Pattern::checkType() NoteVector::Iterator it = m_notes.begin(); while( it != m_notes.end() ) { - if( ( *it )->length() > 0 ) + if( ( *it )->length() > 0 || + ( *it )->pos() % ( MidiTime::ticksPerTact() / + MidiTime::stepsPerTact() ) ) { setType( MelodyPattern ); return; @@ -975,14 +977,14 @@ void PatternView::paintEvent( QPaintEvent * ) y_pos <= max_ht ) { // calculate start and end x-coords of the line to be drawn - int length = ( *it )->length(); + int length = ( *it )->length(); length = length > 0 ? length : 4; const int x1 = x_base + static_cast - ( ( *it )->pos() * ( ppt / MidiTime::ticksPerTact() ) ); + ( ( *it )->pos() * ( ppt / MidiTime::ticksPerTact() ) ); const int x2 = x_base + static_cast - ( ( ( *it )->pos() + length ) * ( ppt / MidiTime::ticksPerTact() ) ); + ( ( ( *it )->pos() + length ) * ( ppt / MidiTime::ticksPerTact() ) ); // check bounds, draw line if( x1 < width() - TCO_BORDER_WIDTH )