aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextutil.cpp
diff options
context:
space:
mode:
authorAndrew den Exter <andrew.den-exter@nokia.com>2012-06-07 15:56:16 +1000
committerQt by Nokia <qt-info@nokia.com>2012-07-09 01:34:54 +0200
commit3095493a4ce4bec11b9381a3d1d23f17b313332c (patch)
tree2869549eec623e38d8915c58592a235671f7a387 /src/quick/items/qquicktextutil.cpp
parentd65b660d5d7f30058efc74c7cab074641923038f (diff)
Reduce the number of unnecessary layouts on geometry changes.
Improve checks for geometry changes that don't affect layout, i.e width increasing when the previous layout didn't wrap or elide. Set implicit sizes just once during layout rather than setting the implicit width during and the implicit height after to limit the when an implicit size change can change geometry. And if there are multiple layouts of the same text/font combination re-use cached layout data as much as possible by guarding against unnecessary property changes on the layout, and not creating a new layout for calculating the implicit size of truncated text. Change-Id: Ia05e52e9170e1f5d3364896ab119e00d8a318299 Reviewed-by: Michael Brasser <michael.brasser@nokia.com>
Diffstat (limited to 'src/quick/items/qquicktextutil.cpp')
-rw-r--r--src/quick/items/qquicktextutil.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/quick/items/qquicktextutil.cpp b/src/quick/items/qquicktextutil.cpp
index 176301d450..151d72c6ee 100644
--- a/src/quick/items/qquicktextutil.cpp
+++ b/src/quick/items/qquicktextutil.cpp
@@ -78,7 +78,7 @@ QQuickItem *QQuickTextUtil::createCursor(
return item;
}
-qreal QQuickTextUtil::alignedX(const QRectF &rect, qreal width, int alignment)
+qreal QQuickTextUtil::alignedX(const qreal textWidth, const qreal itemWidth, int alignment)
{
qreal x = 0;
switch (alignment) {
@@ -86,26 +86,26 @@ qreal QQuickTextUtil::alignedX(const QRectF &rect, qreal width, int alignment)
case Qt::AlignJustify:
break;
case Qt::AlignRight:
- x = width - rect.width();
+ x = itemWidth - textWidth;
break;
case Qt::AlignHCenter:
- x = (width - rect.width()) / 2;
+ x = (itemWidth - textWidth) / 2;
break;
}
return x;
}
-qreal QQuickTextUtil::alignedY(const QRectF &rect, const qreal height, int alignment)
+qreal QQuickTextUtil::alignedY(const qreal textHeight, const qreal itemHeight, int alignment)
{
qreal y = 0;
switch (alignment) {
case Qt::AlignTop:
break;
case Qt::AlignBottom:
- y = height - rect.height();
+ y = itemHeight - textHeight;
break;
case Qt::AlignVCenter:
- y = (height - rect.height()) / 2;
+ y = (itemHeight - textHeight) / 2;
break;
}
return y;