| 741 | } |
| 742 | |
| 743 | void TextLabelPrivate::updateBorder() { |
| 744 | using GluePoint = TextLabel::GluePoint; |
| 745 | |
| 746 | borderShapePath = QPainterPath(); |
| 747 | const auto& br = boundingRectangleText; |
| 748 | switch (borderShape) { |
| 749 | case (TextLabel::BorderShape::NoBorder): { |
| 750 | m_gluePoints.clear(); |
| 751 | m_gluePoints.append(GluePoint(QPointF(br.x() + br.width() / 2, br.y()), QStringLiteral("top"))); |
| 752 | m_gluePoints.append(GluePoint(QPointF(br.x() + br.width(), br.y() + br.height() / 2), QStringLiteral("right"))); |
| 753 | m_gluePoints.append(GluePoint(QPointF(br.x() + br.width() / 2, br.y() + br.height()), QStringLiteral("bottom"))); |
| 754 | m_gluePoints.append(GluePoint(QPointF(br.x(), br.y() + br.height() / 2), QStringLiteral("left"))); |
| 755 | break; |
| 756 | } |
| 757 | case (TextLabel::BorderShape::Rect): { |
| 758 | borderShapePath.addRect(br); |
| 759 | |
| 760 | m_gluePoints.clear(); |
| 761 | m_gluePoints.append(GluePoint(QPointF(br.x() + br.width() / 2, br.y()), QStringLiteral("top"))); |
| 762 | m_gluePoints.append(GluePoint(QPointF(br.x() + br.width(), br.y() + br.height() / 2), QStringLiteral("right"))); |
| 763 | m_gluePoints.append(GluePoint(QPointF(br.x() + br.width() / 2, br.y() + br.height()), QStringLiteral("bottom"))); |
| 764 | m_gluePoints.append(GluePoint(QPointF(br.x(), br.y() + br.height() / 2), QStringLiteral("left"))); |
| 765 | break; |
| 766 | } |
| 767 | case (TextLabel::BorderShape::Ellipse): { |
| 768 | const double xs = br.x(); |
| 769 | const double ys = br.y(); |
| 770 | const double w = br.width(); |
| 771 | const double h = br.height(); |
| 772 | const QRectF ellipseRect(xs - 0.1 * w, ys - 0.1 * h, 1.2 * w, 1.2 * h); |
| 773 | borderShapePath.addEllipse(ellipseRect); |
| 774 | |
| 775 | m_gluePoints.clear(); |
| 776 | m_gluePoints.append(GluePoint(QPointF(ellipseRect.x() + ellipseRect.width() / 2, ellipseRect.y()), QStringLiteral("top"))); |
| 777 | m_gluePoints.append(GluePoint(QPointF(ellipseRect.x() + ellipseRect.width(), ellipseRect.y() + ellipseRect.height() / 2), QStringLiteral("right"))); |
| 778 | m_gluePoints.append(GluePoint(QPointF(ellipseRect.x() + ellipseRect.width() / 2, ellipseRect.y() + ellipseRect.height()), QStringLiteral("bottom"))); |
| 779 | m_gluePoints.append(GluePoint(QPointF(ellipseRect.x(), ellipseRect.y() + ellipseRect.height() / 2), QStringLiteral("left"))); |
| 780 | break; |
| 781 | } |
| 782 | case (TextLabel::BorderShape::RoundSideRect): { |
| 783 | const double xs = br.x(); |
| 784 | const double ys = br.y(); |
| 785 | const double w = br.width(); |
| 786 | const double h = br.height(); |
| 787 | borderShapePath.moveTo(xs, ys); |
| 788 | borderShapePath.lineTo(xs + w, ys); |
| 789 | borderShapePath.quadTo(xs + w + h / 2, ys + h / 2, xs + w, ys + h); |
| 790 | borderShapePath.lineTo(xs, ys + h); |
| 791 | borderShapePath.quadTo(xs - h / 2, ys + h / 2, xs, ys); |
| 792 | |
| 793 | m_gluePoints.clear(); |
| 794 | m_gluePoints.append(GluePoint(QPointF(xs + w / 2, ys), QStringLiteral("top"))); |
| 795 | m_gluePoints.append(GluePoint(QPointF(xs + w + h / 2, ys + h / 2), QStringLiteral("right"))); |
| 796 | m_gluePoints.append(GluePoint(QPointF(xs + w / 2, ys + h), QStringLiteral("bottom"))); |
| 797 | m_gluePoints.append(GluePoint(QPointF(xs - h / 2, ys + h / 2), QStringLiteral("left"))); |
| 798 | break; |
| 799 | } |
| 800 | case (TextLabel::BorderShape::RoundCornerRect): { |