8#include <private/qsgadaptationlayer_p.h>
9#include <private/qsgdistancefieldglyphnode_p.h>
10#include <private/qquickclipnode_p.h>
11#include <private/qquickitem_p.h>
12#include <private/qquicktextdocument_p.h>
14#include <QtCore/qpoint.h>
18#include <private/qquickstyledtext_p.h>
19#include <private/qquicktext_p_p.h>
20#include <private/qfont_p.h>
21#include <private/qfontengine_p.h>
23#include <private/qtextdocumentlayout_p.h>
34 : m_renderContext(renderContext)
36#ifdef QSG_RUNTIME_DESCRIPTION
64 if (fe->hasUnreliableGlyphOutline() || !fe->isSmoothlyScalable)
86 if (parentNode ==
nullptr)
97 fillNode->setColor(
color);
112 if (m_cursorNode !=
nullptr)
124 m_cursorNode =
nullptr;
141 texture->setFiltering(m_filtering);
152 int selectionStart,
int selectionEnd)
155 engine.setTextColor(m_color);
156 engine.setSelectedTextColor(m_selectionTextColor);
157 engine.setSelectionColor(m_selectionColor);
158 engine.setAnchorColor(m_linkColor);
161 QList<QTextFrame *> frames;
162 frames.append(textDocument->
rootFrame());
163 while (!frames.isEmpty()) {
165 frames.append(textFrame->childFrames());
167 engine.addFrameDecorations(textDocument, textFrame);
169 if (textFrame->firstPosition() > textFrame->lastPosition()
171 const int pos = textFrame->firstPosition() - 1;
176 QTextBlock block = textFrame->firstCursorPosition().block();
179 pos, textFrame->frameFormat().position());
183 while (!
it.atEnd()) {
187 engine.addTextBlock(textDocument, block,
position, m_color, m_linkColor, selectionStart, selectionEnd,
199 int selectionStart,
int selectionEnd,
200 int lineStart,
int lineCount)
203 engine.setTextColor(m_color);
204 engine.setSelectedTextColor(m_selectionTextColor);
205 engine.setSelectionColor(m_selectionColor);
206 engine.setAnchorColor(m_linkColor);
214 QVarLengthArray<QTextLayout::FormatRange> colorChanges;
215 engine.mergeFormats(textLayout, &colorChanges);
217 lineCount = lineCount >= 0
221 bool inViewport =
false;
222 for (
int i=lineStart;
i<lineCount; ++
i) {
230 if (preeditPosition >= 0
231 && preeditPosition >=
start
232 && preeditPosition <
end) {
233 end += preeditLength;
238 if (!inViewport && !m_viewport.
isNull()) {
239 m_firstLineInViewport =
i;
240 qCDebug(lcVP) <<
"first line in viewport" <<
i <<
"@" <<
line.y();
244 engine.addGlyphsForRanges(colorChanges,
start,
end, selectionStart, selectionEnd);
245 }
else if (inViewport) {
247 m_firstLinePastViewport =
i;
248 qCDebug(lcVP) <<
"first omitted line past bottom of viewport" <<
i <<
"@" <<
line.y();
260 m_cursorNode =
nullptr;
The QColor class provides colors based on RGB, HSV or CMYK values.
The QGlyphRun class provides direct access to the internal glyphs in a font.
QRawFont rawFont() const
Returns the font selected for this QGlyphRun object.
void append(parameter_type t)
\inmodule QtCore\reentrant
static const int largeTextSizeThreshold
static QRawFontPrivate * get(const QRawFont &font)
The QRawFont class provides access to a single physical instance of a font.
qreal ascent() const
Returns the ascent of this QRawFont in pixel units.
\inmodule QtCore\reentrant
constexpr qreal bottom() const noexcept
Returns the y-coordinate of the rectangle's bottom edge.
constexpr bool isNull() const noexcept
Returns true if the rectangle is a null rectangle, otherwise returns false.
constexpr qreal top() const noexcept
Returns the y-coordinate of the rectangle's top edge.
const QSGGeometry * geometry() const
Returns this node's geometry.
virtual QSGInternalImageNode * createInternalImageNode(QSGRenderContext *renderContext)=0
QSGInternalRectangleNode * createInternalRectangleNode(const QRectF &rect, const QColor &c)
Convenience factory function for creating a colored rectangle with the given geometry.
virtual QSGGlyphNode * createGlyphNode(QSGRenderContext *rc, QSGTextNode::RenderType renderType, int renderTypeQuality)=0
int renderOrder() const
Returns the render order of this geometry node.
void setVertexDataPattern(DataPattern p)
Sets the usage pattern for vertices to p.
void setIndexDataPattern(DataPattern p)
Sets the usage pattern for indices to p.
virtual void setGlyphs(const QPointF &position, const QGlyphRun &glyphs)=0
virtual void setStyle(QQuickText::TextStyle style)=0
virtual void setColor(const QColor &color)=0
virtual void setStyleColor(const QColor &color)=0
virtual void setTexture(QSGTexture *texture)=0
virtual void setTargetRect(const QRectF &rect)=0
virtual void setFiltering(QSGTexture::Filtering filtering)=0
virtual void setInnerTargetRect(const QRectF &rect)=0
void addImage(const QRectF &rect, const QImage &image)
void clear() override
Clears the contents of the node, deleting nodes and other data that represents the layouts and docume...
void doAddTextLayout(QPointF position, QTextLayout *textLayout, int selectionStart, int selectionEnd, int lineStart, int lineCount) override
Virtual function called by addTextLayout(), which converts the contents of layout to scene graph node...
void doAddTextDocument(QPointF position, QTextDocument *textDocument, int selectionStart, int selectionEnd) override
Virtual function called by addTextDocument(), which converts the contents of document to scene graph ...
virtual void addDecorationNode(const QRectF &rect, const QColor &color)
QSGGlyphNode * addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color, QQuickText::TextStyle style=QQuickText::Normal, const QColor &styleColor=QColor(), QSGNode *parentNode=0)
void addRectangleNode(const QRectF &rect, const QColor &color)
void setCursor(const QRectF &rect, const QColor &color)
QColor styleColor() const override
Returns the style color used when rendering the text.
\group qtquick-scenegraph-nodes \title Qt Quick Scene Graph Node classes
void removeChildNode(QSGNode *node)
Removes node from this node's list of children.
void appendChildNode(QSGNode *node)
Appends node to this node's list of children.
QSGNode * firstChild() const
Returns the first child of this node.
virtual QSGTexture * createTexture(const QImage &image, uint flags=CreateTexture_Alpha) const =0
QSGContext * sceneGraphContext() const
RenderType
This enum type describes type of glyph node used for rendering the text.
qsizetype size() const noexcept
Returns the number of characters in this string.
QTextLayout * layout() const
Returns the QTextLayout that is used to lay out and display the block's contents.
int position() const
Returns the index of the block's first character within the document.
\reentrant \inmodule QtGui
QAbstractTextDocumentLayout * documentLayout() const
Returns the document layout for this document.
QTextFrame * rootFrame() const
Returns the document's root frame.
int characterCount() const
QTextLine lineForTextPosition(int pos) const
Returns the line that contains the cursor position specified by pos.
int lineCount() const
Returns the number of lines in this text layout.
int preeditAreaPosition() const
Returns the position of the area in the text layout that will be processed before editing occurs.
QTextLine lineAt(int i) const
Returns the {i}-th line of text in this text layout.
QString preeditAreaText() const
Returns the text that is inserted in the layout before editing occurs.
qDeleteAll(list.begin(), list.end())
QSet< QString >::iterator it
Combined button and popup list for selecting options.
#define qCDebug(category,...)
#define Q_DECLARE_LOGGING_CATEGORY(name)
constexpr const T & qMin(const T &a, const T &b)
GLboolean GLboolean GLboolean GLboolean a
[7]
GLenum GLuint GLenum GLsizei length
GLint GLsizei GLsizei GLenum format
static qreal position(const QQuickItem *item, QQuickAnchors::Anchor anchorLine)
void qsgnode_set_description(QSGNode *node, const QString &description)
QLatin1StringView QLatin1String