Skip to content

Commit 22e11ba

Browse files
committedOct 3, 2013
[FEATURE] Pressing shift while moving composer items constrains movement to horizontal/vertical axis
1 parent 9eddf69 commit 22e11ba

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed
 

‎src/core/composer/qgscomposermousehandles.cpp

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -516,12 +516,24 @@ void QgsComposerMouseHandles::dragMouseMove( const QPointF& currentPosition, boo
516516
//snap to grid and guides
517517
QPointF snappedLeftPoint = snapPoint( upperLeftPoint, QgsComposerMouseHandles::Item );
518518

519-
//TODO: shift moving should lock to horizontal/vertical movement
520-
521519
//calculate total shift for item from beginning of drag operation to current position
522520
double moveRectX = snappedLeftPoint.x() - mBeginHandlePos.x();
523521
double moveRectY = snappedLeftPoint.y() - mBeginHandlePos.y();
524522

523+
if ( lockMovement )
524+
{
525+
//constrained (shift) moving should lock to horizontal/vertical movement
526+
//reset the smaller of the x/y movements
527+
if ( abs( moveRectX ) <= abs( moveRectY ) )
528+
{
529+
moveRectX = 0;
530+
}
531+
else
532+
{
533+
moveRectY = 0;
534+
}
535+
}
536+
525537
//shift handle item to new position
526538
QTransform moveTransform;
527539
moveTransform.translate( moveRectX, moveRectY );

0 commit comments

Comments
 (0)
Please sign in to comment.