Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep off-grid position of TCOs on group moving #4262

Merged
merged 2 commits into from Jan 6, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/core/Track.cpp
Expand Up @@ -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<selectableObject *> so =
m_trackView->trackContainerView()->selectedObjects();
QVector<TrackContentObject *> tcos;
MidiTime smallest_pos, t;
int smallestPos = 0;
MidiTime dtick = MidiTime( static_cast<int>( 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<selectableObject *>::iterator it = so.begin();
Expand All @@ -869,23 +877,18 @@ void TrackContentObjectView::mouseMoveEvent( QMouseEvent * me )
}
TrackContentObject * tco = tcov->m_tco;
tcos.push_back( tco );
smallest_pos = qMin<int>( smallest_pos,
(int)tco->startPosition() +
static_cast<int>( dx *
MidiTime::ticksPerTact() / ppt ) );
smallestPos = qMin<int>( smallestPos,
(int)tco->startPosition() + dtick );
}
dtick -= smallestPos;
if( snap )
{
dtick = dtick.toAbsoluteTact(); // round toward 0
}
for( QVector<TrackContentObject *>::iterator it = tcos.begin();
it != tcos.end(); ++it )
{
t = ( *it )->startPosition() +
static_cast<int>( 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 )
Expand Down