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 dY;
QRectF rectBB;
QPointF ptDiff = pME->scenePos() - m_ptStart;
const QPointF ptDiff = pME->scenePos() - m_ptStart;
if (m_eMode == mMove)
{
// in move mode move the label along the mouse move from the origin
@ -458,13 +458,15 @@ void VTextGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent* pME)
QSizeF sz(m_szStart.width() + ptDiff.x(), m_szStart.height() + ptDiff.y());
rectBB.setSize(sz);
// 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)
{
sz = QSizeF(sz.width()+dX, sz.height()+dY);
}
SetSize(sz.width(), sz.height());
Update();
emit SignalShrink();
}
}
else if (m_eMode == mRotate)
{
// if the angle from the original position is small (0.5 degrees), just remeber the new angle