Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FEATURE] Holding ctrl while dragging a composer selection temporaril…
…y turns off snapping
  • Loading branch information
nyalldawson committed Oct 4, 2013
1 parent bf076a0 commit dae9b5d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/core/composer/qgscomposermousehandles.cpp
Expand Up @@ -378,7 +378,7 @@ void QgsComposerMouseHandles::mouseMoveEvent( QGraphicsSceneMouseEvent* event )
if ( mIsDragging )
{
//currently dragging a selection
dragMouseMove( event->lastScenePos(), shiftModifier );
dragMouseMove( event->lastScenePos(), shiftModifier, controlModifier );
}
else if ( mIsResizing )
{
Expand Down Expand Up @@ -499,7 +499,7 @@ void QgsComposerMouseHandles::mousePressEvent( QGraphicsSceneMouseEvent* event )

}

void QgsComposerMouseHandles::dragMouseMove( const QPointF& currentPosition, bool lockMovement )
void QgsComposerMouseHandles::dragMouseMove( const QPointF& currentPosition, bool lockMovement, bool preventSnap )
{
if ( !mComposition )
{
Expand All @@ -513,8 +513,18 @@ void QgsComposerMouseHandles::dragMouseMove( const QPointF& currentPosition, boo
//find target position before snapping (in scene coordinates)
QPointF upperLeftPoint( mBeginHandlePos.x() + moveX, mBeginHandlePos.y() + moveY );

//snap to grid and guides
QPointF snappedLeftPoint = snapPoint( upperLeftPoint, QgsComposerMouseHandles::Item );
QPointF snappedLeftPoint;
if ( !preventSnap )
{
//snap to grid and guides
snappedLeftPoint = snapPoint( upperLeftPoint, QgsComposerMouseHandles::Item );
}
else
{
//no snapping
snappedLeftPoint = upperLeftPoint;
deleteAlignItems();
}

//calculate total shift for item from beginning of drag operation to current position
double moveRectX = snappedLeftPoint.x() - mBeginHandlePos.x();
Expand Down
2 changes: 1 addition & 1 deletion src/core/composer/qgscomposermousehandles.h
Expand Up @@ -140,7 +140,7 @@ class CORE_EXPORT QgsComposerMouseHandles: public QObject, public QGraphicsRectI
QgsComposerMouseHandles::MouseAction mouseActionForPosition( const QPointF& itemCoordPos );

/**Handles dragging of items during mouse move*/
void dragMouseMove( const QPointF& currentPosition, bool lockMovement );
void dragMouseMove( const QPointF& currentPosition, bool lockMovement, bool preventSnap );
/**Handles resizing of items during mouse move*/
void resizeMouseMove( const QPointF& currentPosition, bool lockAspect, bool fromCenter );

Expand Down

0 comments on commit dae9b5d

Please sign in to comment.