aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextedit.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-04-08 13:09:24 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@theqtcompany.com>2015-04-09 06:32:08 +0000
commit067a01bc76b76599aa696d867018c1e060ff30c6 (patch)
tree26da8e12431d26d74e40f288a5eaf38a9761ec25 /src/quick/items/qquicktextedit.cpp
parent0f15c9a4171cd7d07cf290cda6a11f93bbf7b866 (diff)
Fix TextEdit when vertical alignment != AlignTop
When the TextEdit's alignment was either AlignBottom or AlignVCenter, several things would be broken: First of all the position of all non-dirty nodes would not be updated, so if you e.g. added text to the end of the document, it would overlap with the previously added text. Also, the frame decorations were always aligned to the top, since the basePosition was not accounted for in the node for this. The fix is to translate the root node to the base position instead of baking this into the position of the text nodes. This also automatically fixes frame decorations since it's already aligned to the top of the root node. [ChangeLog][TextEdit] Fixed issues with using other vertical alignments than AlignTop. Change-Id: I11f73eab21a28658a5cbf00292fd519efd0f3e7f Task-number: QTBUG-45032 Reviewed-by: Gunnar Sletta <gunnar@sletta.org>
Diffstat (limited to 'src/quick/items/qquicktextedit.cpp')
-rw-r--r--src/quick/items/qquicktextedit.cpp11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index 03efbd0aa0..c3315878f2 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -1834,6 +1834,10 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
int currentNodeSize = 0;
int nodeStart = firstDirtyPos;
QPointF basePosition(d->xoff, d->yoff);
+ QMatrix4x4 basePositionMatrix;
+ basePositionMatrix.translate(basePosition.x(), basePosition.y());
+ rootNode->setMatrix(basePositionMatrix);
+
QPointF nodeOffset;
TextNode *firstCleanNode = (nodeIterator != d->textNodeMap.end()) ? *nodeIterator : 0;
@@ -1845,7 +1849,6 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
frames.append(textFrame->childFrames());
rootNode->frameDecorationsNode->m_engine->addFrameDecorations(d->document, textFrame);
-
if (textFrame->lastPosition() < firstDirtyPos || (firstCleanNode && textFrame->firstPosition() >= firstCleanNode->startPos()))
continue;
node = d->createTextNode();
@@ -1866,7 +1869,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
nodeOffset = d->document->documentLayout()->frameBoundingRect(textFrame).topLeft();
updateNodeTransform(node, nodeOffset);
while (!it.atEnd())
- node->m_engine->addTextBlock(d->document, (it++).currentBlock(), basePosition - nodeOffset, d->color, QColor(), selectionStart(), selectionEnd() - 1);
+ node->m_engine->addTextBlock(d->document, (it++).currentBlock(), -nodeOffset, d->color, QColor(), selectionStart(), selectionEnd() - 1);
nodeStart = textFrame->firstPosition();
} else {
// Having nodes spanning across frame boundaries will break the current bookkeeping mechanism. We need to prevent that.
@@ -1889,7 +1892,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
nodeStart = block.position();
}
- node->m_engine->addTextBlock(d->document, block, basePosition - nodeOffset, d->color, QColor(), selectionStart(), selectionEnd() - 1);
+ node->m_engine->addTextBlock(d->document, block, -nodeOffset, d->color, QColor(), selectionStart(), selectionEnd() - 1);
currentNodeSize += block.length();
if ((it.atEnd()) || (firstCleanNode && block.next().position() >= firstCleanNode->startPos())) // last node that needed replacing or last block of the frame
@@ -1933,7 +1936,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
if (d->cursorComponent == 0 && !isReadOnly()) {
QSGRectangleNode* cursor = 0;
if (d->cursorVisible && d->control->cursorOn())
- cursor = d->sceneGraphContext()->createRectangleNode(cursorRectangle(), d->color);
+ cursor = d->sceneGraphContext()->createRectangleNode(d->control->cursorRect(), d->color);
rootNode->resetCursorNode(cursor);
}