From e255fdf207891765aa550709e084614242aebeec Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 1 Sep 2015 12:31:07 +0200 Subject: Fix baseline of text with vertical align != Top When the height changes and the vertical alignment is center or bottom, we need to call updateSize(), since this updates the baseline offset. So we need to account for this case in the geometryChanged() handler. [ChangeLog][Text] Fixed baseline of Text elements where the vertical alignment was something other than top. Change-Id: I738c0603e7bf91e5e7ea1a40d4f925f41f868758 Task-number: QTBUG-43226 Reviewed-by: Lars Knoll --- src/quick/items/qquicktext.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/quick') diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index 85c453644e..895a616cb7 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -2299,18 +2299,19 @@ void QQuickText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo bool widthMaximum = newGeometry.width() >= oldGeometry.width() && !d->widthExceeded; bool heightMaximum = newGeometry.height() >= oldGeometry.height() && !d->heightExceeded; + bool verticalPositionChanged = heightChanged && d->vAlign != AlignTop; + if ((!widthChanged && !heightChanged) || d->internalWidthUpdate) goto geomChangeDone; - if ((effectiveHAlign() != QQuickText::AlignLeft && widthChanged) - || (vAlign() != QQuickText::AlignTop && heightChanged)) { + if ((effectiveHAlign() != QQuickText::AlignLeft && widthChanged) || verticalPositionChanged) { // If the width has changed and we're not left aligned do an update so the text is // repositioned even if a full layout isn't required. And the same for vertical. d->updateType = QQuickTextPrivate::UpdatePaintNode; update(); } - if (!wrapped && !elide && !scaleFont) + if (!wrapped && !elide && !scaleFont && !verticalPositionChanged) goto geomChangeDone; // left aligned unwrapped text without eliding never needs relayout if (elide // eliding and dimensions were and remain invalid; @@ -2319,7 +2320,7 @@ void QQuickText::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeo goto geomChangeDone; } - if (widthMaximum && heightMaximum && !d->isLineLaidOutConnected()) // Size is sufficient and growing. + if (widthMaximum && heightMaximum && !d->isLineLaidOutConnected() && !verticalPositionChanged) // Size is sufficient and growing. goto geomChangeDone; if (!(widthChanged || widthMaximum) && !d->isLineLaidOutConnected()) { // only height has changed -- cgit v1.2.3