Skip to content

Commit 6ab9c22

Browse files
committedOct 6, 2017
Fix resizing items
1 parent e0089fb commit 6ab9c22

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed
 

‎src/gui/layout/qgslayoutmousehandles.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -646,9 +646,12 @@ void QgsLayoutMouseHandles::mouseReleaseEvent( QGraphicsSceneMouseEvent *event )
646646
itemRect = itemRect.normalized();
647647
QPointF newPos = mapToScene( itemRect.topLeft() );
648648

649-
#if 0 //TODO - convert to existing units
650-
item->attemptMove( newPos.x(), newPos.y(), itemRect.width(), itemRect.height(), QgsComposerItem::UpperLeft, true );
651-
#endif
649+
// translate new position to current item units
650+
QgsLayoutPoint itemPos = mLayout->convertFromLayoutUnits( newPos, item->positionWithUnits().units() );
651+
item->attemptMove( itemPos );
652+
653+
QgsLayoutSize itemSize = mLayout->convertFromLayoutUnits( itemRect.size(), item->sizeWithUnits().units() );
654+
item->attemptResize( itemSize );
652655
#if 0
653656
subcommand->saveAfterState();
654657
#endif
@@ -777,11 +780,9 @@ QSizeF QgsLayoutMouseHandles::calcCursorEdgeOffset( QPointF cursorPos )
777780

778781
case QgsLayoutMouseHandles::ResizeLeftDown:
779782
return QSizeF( sceneMousePos.x(), sceneMousePos.y() - rect().height() );
780-
781-
// default:
782-
// return QSizeF( 0, 0 );
783783
}
784784

785+
return QSizeF();
785786
}
786787

787788
void QgsLayoutMouseHandles::dragMouseMove( QPointF currentPosition, bool lockMovement, bool preventSnap )
@@ -866,6 +867,7 @@ void QgsLayoutMouseHandles::resizeMouseMove( QPointF currentPosition, bool lockR
866867
QPointF snappedPosition = snapPoint( QPointF( currentPosition.x() - mCursorOffset.width(), currentPosition.y() - mCursorOffset.height() ), QgsLayoutMouseHandles::Point );
867868
finalPosition = mapFromScene( snappedPosition );
868869
#endif
870+
finalPosition = mapFromScene( currentPosition );
869871
}
870872
else
871873
{

0 commit comments

Comments
 (0)
Please sign in to comment.