Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] Pressing shift while moving composer items constrains movem…
…ent to horizontal/vertical axis
  • Loading branch information
nyalldawson committed Oct 3, 2013
1 parent 9eddf69 commit 22e11ba
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/core/composer/qgscomposermousehandles.cpp
Expand Up @@ -516,12 +516,24 @@ void QgsComposerMouseHandles::dragMouseMove( const QPointF& currentPosition, boo
//snap to grid and guides
QPointF snappedLeftPoint = snapPoint( upperLeftPoint, QgsComposerMouseHandles::Item );

//TODO: shift moving should lock to horizontal/vertical movement

//calculate total shift for item from beginning of drag operation to current position
double moveRectX = snappedLeftPoint.x() - mBeginHandlePos.x();
double moveRectY = snappedLeftPoint.y() - mBeginHandlePos.y();

if ( lockMovement )
{
//constrained (shift) moving should lock to horizontal/vertical movement
//reset the smaller of the x/y movements
if ( abs( moveRectX ) <= abs( moveRectY ) )
{
moveRectX = 0;
}
else
{
moveRectY = 0;
}
}

//shift handle item to new position
QTransform moveTransform;
moveTransform.translate( moveRectX, moveRectY );
Expand Down

0 comments on commit 22e11ba

Please sign in to comment.