Resizing of items works fine in all cases.

preferencesAboutTextFull
Aleksei Kanash 12 years ago
parent e68336e1e3
commit 304591d1d8
  1. 97
      src/domain/UBGraphicsDelegateFrame.cpp
  2. 2
      src/domain/UBGraphicsDelegateFrame.h

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

@ -38,6 +38,8 @@ class UBGraphicsDelegateFrame: public QGraphicsRectItem, public QObject
virtual void mousePressEvent(QGraphicsSceneMouseEvent *event);
QPointF getFixedPointFromPos();
QSizeF getResizeVector(qreal moveX, qreal moveY);
void resizeDelegate(qreal moveX, qreal moveY);
virtual void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);

Loading…
Cancel
Save