diff options
author | Jochen Becher <[email protected]> | 2017-12-21 21:15:20 +0100 |
---|---|---|
committer | Jochen Becher <[email protected]> | 2018-01-09 14:21:10 +0000 |
commit | 0c7ce54cc6d144549a497b86d1aa4888ff74c513 (patch) | |
tree | a6a3914df035899fee2abc96d7573fdf336a77a2 /src/libs/modelinglib | |
parent | eceaf47614a76c154a6e780da6f0bf87ef374581 (diff) |
ModelEditor: Support text alignment in custom icons
Change-Id: I69a5b10a3bf46d40744b002eea47fa926a617c17
Reviewed-by: Tobias Hunger <[email protected]>
Diffstat (limited to 'src/libs/modelinglib')
-rw-r--r-- | src/libs/modelinglib/qmt/diagram_scene/items/itemitem.cpp | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/src/libs/modelinglib/qmt/diagram_scene/items/itemitem.cpp b/src/libs/modelinglib/qmt/diagram_scene/items/itemitem.cpp index 1837b63b576..525fdb56be8 100644 --- a/src/libs/modelinglib/qmt/diagram_scene/items/itemitem.cpp +++ b/src/libs/modelinglib/qmt/diagram_scene/items/itemitem.cpp @@ -165,8 +165,12 @@ QSizeF ItemItem::calcMinimumGeometry() const double height = 0.0; if (m_customIcon) { - return stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), - CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT); + QSizeF sz = stereotypeIconMinimumSize(m_customIcon->stereotypeIcon(), + CUSTOM_ICON_MINIMUM_AUTO_WIDTH, CUSTOM_ICON_MINIMUM_AUTO_HEIGHT); + if (shapeIcon().textAlignment() != qmt::StereotypeIcon::TextalignTop + && shapeIcon().textAlignment() != qmt::StereotypeIcon::TextalignCenter) + return sz; + width = sz.width(); } height += BODY_VERT_BORDER; @@ -231,13 +235,36 @@ void ItemItem::updateGeometry() if (m_customIcon) { m_customIcon->setPos(left, top); m_customIcon->setActualSize(QSizeF(width, height)); - y += height; } if (m_shape) m_shape->setRect(rect); - y += BODY_VERT_BORDER; + switch (shapeIcon().textAlignment()) { + case qmt::StereotypeIcon::TextalignBelow: + y += height + BODY_VERT_BORDER; + break; + case qmt::StereotypeIcon::TextalignCenter: + { + double h = 0.0; + if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) + h += stereotypeIconItem->boundingRect().height(); + if (StereotypesItem *stereotypesItem = this->stereotypesItem()) + h += stereotypesItem->boundingRect().height(); + if (nameItem()) + h += nameItem()->boundingRect().height(); + if (m_contextLabel) + h += m_contextLabel->height(); + y = top + (height - h) / 2.0; + break; + } + case qmt::StereotypeIcon::TextalignNone: + // nothing to do + break; + case qmt::StereotypeIcon::TextalignTop: + y += BODY_VERT_BORDER; + break; + } if (CustomIconItem *stereotypeIconItem = this->stereotypeIconItem()) { stereotypeIconItem->setPos(right - stereotypeIconItem->boundingRect().width() - BODY_HORIZ_BORDER, y); y += stereotypeIconItem->boundingRect().height(); |