From 3f6e68db95cc3c7769c6f1733533778ee7d910c1 Mon Sep 17 00:00:00 2001 From: krepa098 Date: Mon, 9 Feb 2015 17:45:48 +0100 Subject: [PATCH] tweaked layout calculation --- src/chatlog/chatline.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/chatlog/chatline.cpp b/src/chatlog/chatline.cpp index 1059d63e6..d3617b347 100644 --- a/src/chatlog/chatline.cpp +++ b/src/chatlog/chatline.cpp @@ -185,11 +185,11 @@ void ChatLine::layout(qreal w, QPointF scenePos) qreal maxVOffset = 0.0; qreal xOffset = 0.0; + qreal xPos[content.size()]; + for(int i = 0; i < static_cast(content.size()); ++i) { - maxVOffset = qMax(maxVOffset, content[i]->getAscent()); - // calculate the effective width of the current column qreal width; if(format[i].policy == ColumnFormat::FixedSize) @@ -216,21 +216,20 @@ void ChatLine::layout(qreal w, QPointF scenePos) } // reposition - content[i]->setPos(scenePos.x() + xOffset + xAlign, scenePos.y()); + xPos[i] = scenePos.x() + xOffset + xAlign; xOffset += width + columnSpacing; + maxVOffset = qMax(maxVOffset, content[i]->getAscent()); } for(int i = 0; i < static_cast(content.size()); ++i) { // calculate vertical alignment // vertical alignment may depend on width, so we do it in a second pass - qreal yOffset = 0.0; - - yOffset = maxVOffset - content[i]->getAscent(); + qreal yOffset = maxVOffset - content[i]->getAscent(); // reposition - content[i]->setPos(content[i]->pos().x(), content[i]->pos().y() + yOffset); + content[i]->setPos(xPos[i], scenePos.y() + yOffset); } updateBBox();