Skip to content

Commit

Permalink
'Off beat' beat notes to MelodyPattern
Browse files Browse the repository at this point in the history
  • Loading branch information
zonkmachine committed Feb 20, 2017
1 parent 62ad715 commit 9e791ce
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 6 deletions.
3 changes: 1 addition & 2 deletions include/Pattern.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -132,7 +132,6 @@ protected slots:
MidiTime beatPatternLength() const;

void setType( PatternTypes _new_pattern_type );
void checkType();

void resizeToFirstTrack();

Expand Down
5 changes: 5 additions & 0 deletions src/gui/editors/PianoRoll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
}
}
Expand Down
10 changes: 6 additions & 4 deletions src/tracks/Pattern.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<int>
( ( *it )->pos() * ( ppt / MidiTime::ticksPerTact() ) );
( ( *it )->pos() * ( ppt / MidiTime::ticksPerTact() ) );
const int x2 = x_base +
static_cast<int>
( ( ( *it )->pos() + length ) * ( ppt / MidiTime::ticksPerTact() ) );
( ( ( *it )->pos() + length ) * ( ppt / MidiTime::ticksPerTact() ) );

// check bounds, draw line
if( x1 < width() - TCO_BORDER_WIDTH )
Expand Down

0 comments on commit 9e791ce

Please sign in to comment.