aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/items/qquicktextinput.cpp
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-08-24 09:57:39 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2023-09-01 11:20:33 +0200
commit8e7572ac63b4eb7ced5148fdca11702108fa511d (patch)
tree748bdad14566f96cfe5b8a4a8178d7ba7ac3a332 /src/quick/items/qquicktextinput.cpp
parentac5c7d52737489b2b63071e1003ef2d72e8eb8ae (diff)
Make text node scenegraph API public
A lot of functionality is hidden underneath this, so exposing this API will make it possible to build custom text-based components for Qt Quick. [ChangeLog][Text] Added QSGTextNode and QQuickWindow::createTextNode() for creating scene graph nodes containing text. This can be useful when building custom Qt Quick items with text. Fixes: QTBUG-72773 Change-Id: I4810589cc28eb1cdfe91c9d8b66f4c6fe52a0c6a Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Diffstat (limited to 'src/quick/items/qquicktextinput.cpp')
-rw-r--r--src/quick/items/qquicktextinput.cpp26
1 files changed, 17 insertions, 9 deletions
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 22db97b96c..ea53e3b77c 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -13,7 +13,7 @@
#include <QtQml/qqmlinfo.h>
#include <QtGui/qevent.h>
#include <QTextBoundaryFinder>
-#include "qquicktextnode_p.h"
+#include "qsginternaltextnode_p.h"
#include <QtQuick/qsgsimplerectnode.h>
#include <QtGui/qstylehints.h>
@@ -1916,9 +1916,9 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
d->updateType = QQuickTextInputPrivate::UpdateNone;
- QQuickTextNode *node = static_cast<QQuickTextNode *>(oldNode);
+ QSGInternalTextNode *node = static_cast<QSGInternalTextNode *>(oldNode);
if (node == nullptr)
- node = new QQuickTextNode(this);
+ node = d->sceneGraphContext()->createInternalTextNode(d->sceneGraphRenderContext());
d->textNode = node;
const bool showCursor = !isReadOnly() && d->cursorItem == nullptr && d->cursorVisible && d->m_blinkStatus;
@@ -1929,9 +1929,19 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
else
node->clearCursor();
} else {
- node->setUseNativeRenderer(d->renderType == NativeRendering);
+ node->setRenderType(QSGTextNode::RenderType(d->renderType));
node->deleteContent();
node->setMatrix(QMatrix4x4());
+ node->setTextStyle(QSGInternalTextNode::Normal);
+ node->setColor(d->color);
+ node->setSelectionTextColor(d->selectedTextColor);
+ node->setSelectionColor(d->selectionColor);
+ node->setSmooth(smooth());
+
+ if (flags().testFlag(ItemObservesViewport))
+ node->setViewport(clipRect());
+ else
+ node->setViewport(QRectF{});
QPointF offset(leftPadding(), topPadding());
if (d->autoScroll && d->m_textLayout.lineCount() > 0) {
@@ -1947,16 +1957,14 @@ QSGNode *QQuickTextInput::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData
|| !d->m_textLayout.preeditAreaText().isEmpty()
#endif
) {
- node->addTextLayout(offset, &d->m_textLayout, d->color,
- QQuickText::Normal, QColor(), QColor(),
- d->selectionColor, d->selectedTextColor,
+ node->addTextLayout(offset, &d->m_textLayout,
d->selectionStart(),
d->selectionEnd() - 1); // selectionEnd() returns first char after
- // selection
+ // selection
}
if (showCursor)
- node->setCursor(cursorRectangle(), d->color);
+ node->setCursor(cursorRectangle(), d->color);
d->textLayoutDirty = false;
}