diff --git a/src/core/Track.cpp b/src/core/Track.cpp index 65187f552d8..40e1449f398 100644 --- a/src/core/Track.cpp +++ b/src/core/Track.cpp @@ -852,10 +852,18 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) else if( m_action == MoveSelection ) { const int dx = me->x() - m_initialMousePos.x(); + const bool snap = !(me->modifiers() & Qt::AltModifier) && + me->button() == Qt::NoButton; QVector so = m_trackView->trackContainerView()->selectedObjects(); QVector tcos; - MidiTime smallest_pos, t; + int smallestPos = 0; + MidiTime dtick = MidiTime( static_cast( dx * + MidiTime::ticksPerTact() / ppt ) ); + if( snap ) + { + dtick = dtick.toNearestTact(); + } // find out smallest position of all selected objects for not // moving an object before zero for( QVector::iterator it = so.begin(); @@ -869,23 +877,18 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me ) } TrackContentObject * tco = tcov->m_tco; tcos.push_back( tco ); - smallest_pos = qMin( smallest_pos, - (int)tco->startPosition() + - static_cast( dx * - MidiTime::ticksPerTact() / ppt ) ); + smallestPos = qMin( smallestPos, + (int)tco->startPosition() + dtick ); + } + dtick -= smallestPos; + if( snap ) + { + dtick = dtick.toAbsoluteTact(); // round toward 0 } for( QVector::iterator it = tcos.begin(); it != tcos.end(); ++it ) { - t = ( *it )->startPosition() + - static_cast( dx *MidiTime::ticksPerTact() / - ppt )-smallest_pos; - if( ! ( me->modifiers() & Qt::AltModifier ) - && me->button() == Qt::NoButton ) - { - t = t.toNearestTact(); - } - ( *it )->movePosition( t ); + ( *it )->movePosition( ( *it )->startPosition() + dtick ); } } else if( m_action == Resize )