Commit c4f4343b authored by Aleksei Kanash's avatar Aleksei Kanash

Fixed scaling of rotated and mirrored images.

parent 370e5b37
......@@ -477,29 +477,20 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
QTransform tr = buildTransform();
//TODO UB 4.x: Could find a better solution ?
if (resizingRight() || resizingBottom() || resizingBottomRight())
{
QPointF ref;
if(!mMirrorX && !mMirrorY){
ref = delegated()->boundingRect().topLeft();
}else if(mMirrorX && !mMirrorY){
ref = delegated()->boundingRect().topLeft();
}else if(!mMirrorX && mMirrorY){
ref = delegated()->boundingRect().topLeft();
}else if(mMirrorX && mMirrorY){
ref = delegated()->boundingRect().topRight();
}
// Map the item topleft point to the current mouse move transform
QPointF topLeft = tr.map(ref);
// Map the item topleft point to the mouse press transform
QPointF fixedPoint = mInitialTransform.map(ref);
// we just detects coordinates of corner before and after scaling and then moves object at diff between them.
if (resizingBottomRight() && mMirrorX)
mTranslateX += mInitialTransform.map(delegated()->boundingRect().bottomRight()).x() - tr.map(delegated()->boundingRect().bottomRight()).x();
else
mTranslateX += mInitialTransform.map(delegated()->boundingRect().topLeft()).x() - tr.map(delegated()->boundingRect().topLeft()).x();
// Update the translation coordinates
mTranslateX += fixedPoint.x() - topLeft.x();
mTranslateY += fixedPoint.y() - topLeft.y();
if (resizingBottomRight() && mMirrorY)
mTranslateY += mInitialTransform.map(delegated()->boundingRect().bottomRight()).y() - tr.map(delegated()->boundingRect().bottomRight()).y();
else
mTranslateY += mInitialTransform.map(delegated()->boundingRect().topLeft()).y() - tr.map(delegated()->boundingRect().topLeft()).y();
// Update the transform
tr = buildTransform();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment