Skip to content
Permalink
Browse files

Fix graphical corruption during item resize

  • Loading branch information
nyalldawson committed Oct 13, 2013
1 parent a6a82fb commit e7a4ba70072f8ef14b4a5b56aee11208beacfba9
Showing with 12 additions and 5 deletions.
  1. +10 −5 src/core/composer/qgscomposermousehandles.cpp
  2. +2 −0 src/core/composer/qgscomposermousehandles.h
@@ -128,7 +128,7 @@ void QgsComposerMouseHandles::drawSelectedItemBounds( QPainter* painter )
{
//if currently resizing, calculate relative resize of this item
itemBounds = itemSceneBounds;
relativeResizeRect( itemBounds, QRectF( mBeginHandlePos.x(), mBeginHandlePos.y(), mBeginHandleWidth, mBeginHandleHeight ), sceneBoundingRect() );
relativeResizeRect( itemBounds, QRectF( mBeginHandlePos.x(), mBeginHandlePos.y(), mBeginHandleWidth, mBeginHandleHeight ), mResizeRect );
itemBounds = mapRectFromScene( itemBounds );
}
else
@@ -446,7 +446,7 @@ void QgsComposerMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent* event
QgsComposerItemCommand* subcommand = new QgsComposerItemCommand( *itemIter, "", parentCommand );
subcommand->savePreviousState();
QRectF itemBounds = ( *itemIter )->sceneBoundingRect();
relativeResizeRect( itemBounds, QRectF( mBeginHandlePos.x(), mBeginHandlePos.y(), mBeginHandleWidth, mBeginHandleHeight ), sceneBoundingRect() );
relativeResizeRect( itemBounds, QRectF( mBeginHandlePos.x(), mBeginHandlePos.y(), mBeginHandleWidth, mBeginHandleHeight ), mResizeRect );
( *itemIter )->setSceneRect( itemBounds );
subcommand->saveAfterState();
}
@@ -495,6 +495,7 @@ void QgsComposerMouseHandles::mousePressEvent( QGraphicsSceneMouseEvent* event )
mCurrentMouseMoveAction != QgsComposerMouseHandles::NoAction )
{
mIsResizing = true;
mResizeRect = QRectF( mBeginHandlePos.x(), mBeginHandlePos.y(), mBeginHandleWidth, mBeginHandleHeight );
}

}
@@ -717,10 +718,14 @@ void QgsComposerMouseHandles::resizeMouseMove( const QPointF& currentPosition, b

//update selection handle rectangle
QTransform itemTransform;
itemTransform.translate( mx, my );
//make sure selection handle size rectangle is normalized (ie, left coord < right coord)
double translateX = mBeginHandleWidth + rx > 0 ? mx : mx + mBeginHandleWidth + rx;
double translateY = mBeginHandleHeight + ry > 0 ? my : my + mBeginHandleHeight + ry;
itemTransform.translate( translateX, translateY );

setTransform( itemTransform );
QRectF itemRect( 0, 0, mBeginHandleWidth + rx, mBeginHandleHeight + ry );
setRect( itemRect );
mResizeRect = QRectF( mBeginHandlePos.x() + mx, mBeginHandlePos.y() + my, mBeginHandleWidth + rx, mBeginHandleHeight + ry );
setRect( 0, 0, fabs( mBeginHandleWidth + rx ), fabs( mBeginHandleHeight + ry ) );
}

void QgsComposerMouseHandles::relativeResizeRect( QRectF& rectToResize, const QRectF& boundsBefore, const QRectF& boundsAfter )
@@ -110,6 +110,8 @@ class CORE_EXPORT QgsComposerMouseHandles: public QObject, public QGraphicsRectI
double mBeginHandleWidth;
double mBeginHandleHeight;

QRectF mResizeRect;

/**True if user is currently dragging items*/
bool mIsDragging;
/**True is user is currently resizing items*/

0 comments on commit e7a4ba7

Please sign in to comment.
You can’t perform that action at this time.