Correct label size according to parent's bounding rect.

--HG--
branch : feature
This commit is contained in:
Roman Telezhynskyi 2016-12-15 09:33:01 +02:00
parent cda54a62ec
commit d45a04feb0

View File

@ -433,7 +433,7 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
qreal dX; qreal dX;
qreal dY; qreal dY;
QRectF rectBB; QRectF rectBB;
QPointF ptDiff = pME->scenePos() - m_ptStart; const QPointF ptDiff = pME->scenePos() - m_ptStart;
if (m_eMode == mMove) if (m_eMode == mMove)
{ {
// in move mode move the label along the mouse move from the origin // in move mode move the label along the mouse move from the origin
@ -458,12 +458,14 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
QSizeF sz(m_szStart.width() + ptDiff.x(), m_szStart.height() + ptDiff.y()); QSizeF sz(m_szStart.width() + ptDiff.x(), m_szStart.height() + ptDiff.y());
rectBB.setSize(sz); rectBB.setSize(sz);
// before resizing the label to a new size, check if it will still be inside the parent item // before resizing the label to a new size, check if it will still be inside the parent item
if (IsContained(rectBB, rotation(), dX, dY) == true) if (IsContained(rectBB, rotation(), dX, dY) == false)
{ {
SetSize(sz.width(), sz.height()); sz = QSizeF(sz.width()+dX, sz.height()+dY);
Update();
emit SignalShrink();
} }
SetSize(sz.width(), sz.height());
Update();
emit SignalShrink();
} }
else if (m_eMode == mRotate) else if (m_eMode == mRotate)
{ {
@ -651,7 +653,7 @@ QRectF VTextGraphicsItem::GetBoundingRect(QRectF rectBB, qreal dRot) const
qreal dY1 = 0; qreal dY1 = 0;
qreal dY2 = 0; qreal dY2 = 0;
double dAng = qDegreesToRadians(dRot); double dAng = qDegreesToRadians(dRot);
for (int i = 0; i < 4; ++i) for (int i = 0; i < 4; ++i)
{ {
QPointF pt = apt[i] - ptCenter; QPointF pt = apt[i] - ptCenter;