Made sure that labels stay inside the detail after changing size or height

--HG--
branch : feature
This commit is contained in:
BojanKverh 2016-08-15 17:19:21 +02:00
parent a5f16ab738
commit 92ec78e6b3
4 changed files with 29 additions and 4 deletions

View File

@ -2805,6 +2805,7 @@ void MainWindow::ChangedSize(const QString & text)
if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), text.toInt(), static_cast<int>(pattern->height()))) if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), text.toInt(), static_cast<int>(pattern->height())))
{ {
doc->LiteParseTree(Document::LiteParse); doc->LiteParseTree(Document::LiteParse);
emit sceneDetails->DimensionsChanged();
} }
else else
{ {
@ -2833,6 +2834,7 @@ void MainWindow::ChangedHeight(const QString &text)
if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), static_cast<int>(pattern->size()), text.toInt())) if (UpdateMeasurements(AbsoluteMPath(curFile, doc->MPath()), static_cast<int>(pattern->size()), text.toInt()))
{ {
doc->LiteParseTree(Document::LiteParse); doc->LiteParseTree(Document::LiteParse);
emit sceneDetails->DimensionsChanged();
} }
else else
{ {

View File

@ -230,6 +230,23 @@ void VTextGraphicsItem::SetSize(qreal fW, qreal fH)
return; return;
} }
if (fW > parentItem()->boundingRect().width())
{
fW = parentItem()->boundingRect().width();
}
if (fW < MIN_W)
{
fW = MIN_W;
}
if (fH > parentItem()->boundingRect().height())
{
fH = parentItem()->boundingRect().height();
}
if (fH < m_iMinH)
{
fH = m_iMinH;
}
m_rectBoundingBox.setTopLeft(QPointF(0, 0)); m_rectBoundingBox.setTopLeft(QPointF(0, 0));
m_rectBoundingBox.setWidth(fW); m_rectBoundingBox.setWidth(fW);
m_rectBoundingBox.setHeight(fH); m_rectBoundingBox.setHeight(fH);

View File

@ -206,6 +206,10 @@ VToolDetail::VToolDetail(VAbstractPattern *doc, VContainer *data, const quint32
connect(doc, &VAbstractPattern::patternChanged, this, &VToolDetail::UpdatePatternInfo); connect(doc, &VAbstractPattern::patternChanged, this, &VToolDetail::UpdatePatternInfo);
connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdateLabel); connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdateLabel);
connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdatePatternInfo); connect(doc, &VAbstractPattern::CheckLayout, this, &VToolDetail::UpdatePatternInfo);
connect(sceneDetails, &VMainGraphicsScene::DimensionsChanged, this, &VToolDetail::UpdateLabel);
connect(sceneDetails, &VMainGraphicsScene::DimensionsChanged, this, &VToolDetail::UpdatePatternInfo);
UpdateLabel(); UpdateLabel();
UpdatePatternInfo(); UpdatePatternInfo();
} }
@ -770,8 +774,8 @@ void VToolDetail::UpdateLabel()
QPointF pt = data.GetPos(); QPointF pt = data.GetPos();
QRectF rectBB; QRectF rectBB;
rectBB.setTopLeft(pt); rectBB.setTopLeft(pt);
rectBB.setWidth(data.GetLabelWidth()); rectBB.setWidth(dataLabel->boundingRect().width());
rectBB.setHeight(data.GetLabelHeight()); rectBB.setHeight(dataLabel->boundingRect().height());
qreal dX; qreal dX;
qreal dY; qreal dY;
if (dataLabel->IsContained(rectBB, data.GetRotation(), dX, dY) == false) if (dataLabel->IsContained(rectBB, data.GetRotation(), dX, dY) == false)
@ -816,8 +820,8 @@ void VToolDetail::UpdatePatternInfo()
QPointF pt = geom.GetPos(); QPointF pt = geom.GetPos();
QRectF rectBB; QRectF rectBB;
rectBB.setTopLeft(pt); rectBB.setTopLeft(pt);
rectBB.setWidth(geom.GetLabelWidth()); rectBB.setWidth(patternInfo->boundingRect().width());
rectBB.setHeight(geom.GetLabelHeight()); rectBB.setHeight(patternInfo->boundingRect().height());
qreal dX; qreal dX;
qreal dY; qreal dY;
if (patternInfo->IsContained(rectBB, geom.GetRotation(), dX, dY) == false) if (patternInfo->IsContained(rectBB, geom.GetRotation(), dX, dY) == false)

View File

@ -146,6 +146,8 @@ signals:
void EnableNodePointItemHover(bool enabled); void EnableNodePointItemHover(bool enabled);
void EnableDetailItemHover(bool enabled); void EnableDetailItemHover(bool enabled);
void EnableLineItemHover(bool enabled); void EnableLineItemHover(bool enabled);
void DimensionsChanged();
private: private:
/** @brief horScrollBar value horizontal scroll bar. */ /** @brief horScrollBar value horizontal scroll bar. */
qint32 horScrollBar; qint32 horScrollBar;