Commit 4685d135 authored by Eric Jiang's avatar Eric Jiang Committed by Jean-Baptiste Mardelle
Browse files

Fix titler text alignment

When editing text in the title editor, modifying left-aligned text
behaves as though the text is right-aligned and vice-versa. This diff
fixes the logic of offsetting the text location based on alignment.
parent 3c59d785
...@@ -360,9 +360,15 @@ void MyTextItem::updateGeometry() ...@@ -360,9 +360,15 @@ void MyTextItem::updateGeometry()
setAlignment(m_alignment); setAlignment(m_alignment);
QPointF topRight = boundingRect().topRight(); QPointF topRight = boundingRect().topRight();
if ((m_alignment & static_cast<int>((Qt::AlignRight) != 0)) != 0) { // if the text is right-aligned, then shift the container leftwards by the
// same amount it grew to maintain right-alignment
if (m_alignment & Qt::AlignRight) {
setPos(pos() + (topRightPrev - topRight)); setPos(pos() + (topRightPrev - topRight));
} }
// likewise, shift it halfway if we're center-aligned
else if (m_alignment & Qt::AlignHCenter) {
setPos(pos() + (topRightPrev - topRight) / 2);
}
} }
QRectF MyTextItem::baseBoundingRect() const QRectF MyTextItem::baseBoundingRect() const
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment