|
|
@ -325,11 +325,53 @@ QPointF UBGraphicsDelegateFrame::getFixedPointFromPos() |
|
|
|
fixedPoint = delegated()->sceneBoundingRect().bottomRight(); |
|
|
|
fixedPoint = delegated()->sceneBoundingRect().bottomRight(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else if (resizingBottomRight()) |
|
|
|
} |
|
|
|
|
|
|
|
return fixedPoint; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QSizeF UBGraphicsDelegateFrame::getResizeVector(qreal moveX, qreal moveY) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
qreal dPosX = 0; |
|
|
|
|
|
|
|
qreal dPosY = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resizingTop())
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
|
|
|
|
dPosY = moveY; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
dPosY = -moveY; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (resizingLeft())
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
|
|
|
|
dPosX = moveX; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
dPosX = -moveX; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else if (resizingRight()) |
|
|
|
|
|
|
|
dPosX = (mMirrorX) ? -moveX : moveX; |
|
|
|
|
|
|
|
else if (resizingBottom())
|
|
|
|
|
|
|
|
dPosY = mMirrorY ? -moveY : moveY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return QSizeF(dPosX, dPosY); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsDelegateFrame::resizeDelegate(qreal moveX, qreal moveY) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QPointF fixedPoint = getFixedPointFromPos(); |
|
|
|
|
|
|
|
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(delegated()); |
|
|
|
|
|
|
|
if (resizableItem) |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
QSizeF originalSize = delegated()->boundingRect().size();
|
|
|
|
|
|
|
|
resizableItem->resize(originalSize + getResizeVector(moveX, moveY)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resizingTop() || resizingLeft() || ((mMirrorX || mMirrorY) && resizingBottomRight())) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
delegated()->setPos(delegated()->pos()-getFixedPointFromPos()+fixedPoint); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return fixedPoint; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
@ -523,54 +565,27 @@ void UBGraphicsDelegateFrame::mouseMoveEvent(QGraphicsSceneMouseEvent *event) |
|
|
|
} |
|
|
|
} |
|
|
|
else if (mOperationMode == Resizing) |
|
|
|
else if (mOperationMode == Resizing) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QSizeF originalSize = delegated()->boundingRect().size();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mScaleX = 1; |
|
|
|
|
|
|
|
mScaleY = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!moving() && !rotating()) |
|
|
|
if (!moving() && !rotating()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
qreal dPosX = 0; |
|
|
|
if (resizingBottomRight()) |
|
|
|
qreal dPosY = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QPointF fixedPoint = getFixedPointFromPos(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (resizingTop())
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
|
|
|
|
dPosY = moveY; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
dPosY = -moveY; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (resizingLeft())
|
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
dPosX = moveX; |
|
|
|
mCurrentTool = ResizeTop; |
|
|
|
else |
|
|
|
else |
|
|
|
dPosX = -moveX; |
|
|
|
mCurrentTool = ResizeBottom; |
|
|
|
} |
|
|
|
|
|
|
|
else if (resizingBottomRight()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
dPosX = moveX; |
|
|
|
|
|
|
|
dPosY = moveY; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (resizingRight()) |
|
|
|
|
|
|
|
dPosX = (mMirrorX) ? -moveX : moveX; |
|
|
|
|
|
|
|
else if (resizingBottom())
|
|
|
|
|
|
|
|
dPosY = mMirrorY ? -moveY : moveY; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
UBResizableGraphicsItem* resizableItem = dynamic_cast<UBResizableGraphicsItem*>(delegated()); |
|
|
|
resizeDelegate(moveX, moveY);
|
|
|
|
if (resizableItem) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
resizableItem->resize(originalSize.width() + dPosX, originalSize.height() + dPosY); |
|
|
|
|
|
|
|
if (resizingTop() || resizingLeft() || ((mMirrorX || mMirrorY) && resizingBottomRight())) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
QPointF newFixedPoint = getFixedPointFromPos();; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
delegated()->setPos(delegated()->pos()-newFixedPoint+fixedPoint); |
|
|
|
if (mMirrorX && mMirrorY) |
|
|
|
} |
|
|
|
mCurrentTool = ResizeLeft; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
mCurrentTool = ResizeRight; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
resizeDelegate(moveX, moveY);
|
|
|
|
|
|
|
|
mCurrentTool = ResizeBottomRight; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
resizeDelegate(moveX, moveY);
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|