aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/util/qsgtextnode.cpp
blob: 27f9e3edaeea2a72047592b9deb142b062f9b9fe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#include "qsgtextnode.h"

QT_BEGIN_NAMESPACE

/*!
    \class QSGTextNode

    \brief The QSGTextNode class is a class for drawing text layouts and text documents in
    the Qt Quick scene graph.
    \inmodule QtQuick
    \since 6.7

    QSGTextNode can be useful for creating custom Qt Quick items that require text. It is used
    in Qt Quick by the Text, TextEdit and TextInput elements.

    You can create QSGTextNode objects using QQuickWindow::createTextNode(). The addTextLayout()
    and addTextDocument() functions provide ways to add text to the QSGTextNode. The text must
    already be laid out.

    \note Properties must be set before \l addTextLayout() or \l addTextDocument() are called in
    order to have an effect.
 */

/*!
      \enum QSGTextNode::TextStyle

      This enum type describes styles that can be applied to text rendering.

      \value Normal The text is drawn without any style applied.
      \value Outline The text is drawn with an outline.
      \value Raised The text is drawn raised.
      \value Sunken The text is drawn sunken.

      \sa setTextStyle(), setStyleColor()
*/

/*!
      \enum QSGTextNode::RenderType

      This enum type describes type of glyph node used for rendering the text.

      \value QtRendering Text is rendered using a scalable distance field for each glyph.
      \value NativeRendering Text is rendered using a platform-specific technique.
      \value CurveRendering Text is rendered using a curve rasterizer running directly on the
                            graphics hardware.

      Select \c NativeRendering if you prefer text to look native on the target platform and do
      not require advanced features such as transformation of the text. Using such features in
      combination with the NativeRendering render type will lend poor and sometimes pixelated
      results.

      Both \c Text.QtRendering and \c Text.CurveRendering are hardware-accelerated techniques.
      \c QtRendering is the faster of the two, but uses more memory and will exhibit rendering
      artifacts at large sizes. \c CurveRendering should be considered as an alternative in cases
      where \c QtRendering does not give good visual results or where reducing graphics memory
      consumption is a priority.

      \sa setRenderType(), setRenderTypeQuality()
*/

/*!
    \fn void QSGTextNode::setColor(const QColor &color)

    Sets the main color to use when rendering the text to \a color.

    The default is black: \c QColor(0, 0, 0).
*/

/*!
    \fn QColor QSGTextNode::color() const

    Returns the main color used when rendering the text.
*/

/*!
    \fn void QSGTextNode::setStyleColor(const QColor &styleColor)

    Sets the style color to use when rendering the text to \a styleColor.

    The default is black: \c QColor(0, 0, 0).

    \sa setTextStyle()
*/

/*!
    \fn QColor QSGTextNode::styleColor() const

    Returns the style color used when rendering the text.

    \sa textStyle()
*/

/*!
    \fn void QSGTextNode::setTextStyle(QSGTextNode::TextStyle textStyle)

    Sets the style of the rendered text to \a textStyle. The default is \c Normal.

    \sa setStyleColor()
*/

/*!
    \fn QSGTextNode::TextStyle QSGTextNode::textStyle()

    Returns the style of the rendered text.

    \sa styleColor()
*/

/*!
    \fn void QSGTextNode::setLinkColor(const QColor &linkColor)

    Sets the color of or hyperlinks to \a linkColor in the text.

    The default is blue: \c QColor(0, 0, 255).
*/

/*!
    \fn QColor QSGTextNode::linkColor() const

    Returns the color of hyperlinks in the text.
*/

/*!
    \fn void QSGTextNode::setSelectionColor(const QColor &color)

    Sets the color of the selection background to \a color when any part of the text is
    marked as selected.

    The default is dark blue: \c QColor(0, 0, 128).
*/

/*!
    \fn QColor QSGTextNode::selectionColor() const

    Returns the color of the selection background when any part of the text is marked as selected.
*/

/*!
    \fn QColor QSGTextNode::selectionTextColor() const

    Returns the color of the selection text when any part of the text is marked as selected.
*/

/*!
    \fn void QSGTextNode::setSelectionTextColor(const QColor &selectionTextColor)

    Sets the color of the selection text to \a selectionTextColor when any part of the text is
    marked as selected.

    The default is white: \c QColor(255, 255, 255).
*/


/*!
    \fn void QSGTextNode::setRenderType(RenderType renderType)

    Sets the type of glyph node in use to \a renderType.

    The default is \l QtRendering.
*/

/*!
    \fn QSGTextNode::RenderType QSGTextNode::renderType() const

    Returns the type of glyph node used for rendering the text.
*/

/*!
    \fn void QSGTextNode::setRenderTypeQuality(int renderTypeQuality)

    If the \l renderType() in use supports it, set the quality to use when rendering the text.
    When supported, this can be used to trade visual fidelity for execution speed or memory.

    When the \a renderTypeQuality is < 0, the default quality is used.

    The \a renderTypeQuality can be any integer, although limitations imposed by the underlying
    graphics hardware may be encountered if extreme values are set. The Qt Quick Text element
    operates with the following predefined values:

    \value DefaultRenderTypeQuality    -1 (default)
    \value LowRenderTypeQuality        26
    \value NormalRenderTypeQuality     52
    \value HighRenderTypeQuality       104
    \value VeryHighRenderTypeQuality   208

    This value is currently only respected by the QtRendering render type. Setting it changes the
    resolution of the distance fields used to represent the glyphs. Setting it above normal will
    cause memory consumption to increase, but reduces filtering artifacts on very large text.

    The default is -1.
*/

/*!
    \fn int QSGTextNode::renderTypeQuality() const

    Returns the render type quality of the node. See \l setRenderTypeQuality() for details.
*/

/*!
    \fn void QSGTextNode::setSmooth(bool smooth)

    Sets the smoothness of the text node to \a smooth. This should typically match the item's
    \l{QQuickItem::smooth} property.

    The default is false.
*/

/*!
    \fn bool QSGTextNode::smooth() const

    Returns whether the QSGTextNode will be rendered as smooth or not.
*/

/*!
    \fn void QSGTextNode::setViewport(const QRectF &viewport)

    Sets the bounding rect of the viewport where the text is displayed to \a viewport. Providing
    this information makes it possible for the QSGTextNode to optimize which parts of the text
    layout or document are included in the scene graph.

    The default is a default-constructed QRectF. For this viewport, all contents will be included
    in the graph.
*/

/*!
    \fn QRectF QSGTextNode::viewport() const

    Returns the current viewport set for this QSGTextNode.
*/

/*!
    \fn QSGTextNode::addTextLayout(const QPointF &position, QTextLayout *layout, int selectionStart = -1, int selectionCount = -1, int lineStart = 0, int lineCount = -1)

    Adds the contents of \a layout to the text node at \a position. If \a selectionStart is >= 0,
    then this marks the first character in a selected area of \a selectionCount number of
    characters. The selection is represented as a background fill with the \l selectionColor() and
    the selected text is rendered in the \l selectionTextColor().

    For convenience, \a lineStart and \a lineCount can be used to select the range of \l QTextLine
    objects to include from the layout. This can be useful, for instance, when creating elided
    layouts. If \a lineCount is < 0, then the the node will include the lines from \a lineStart to
    the end of the layout.
*/

/*!
    \fn QSGTextNode::addTextDocument(const QPointF &position, QTextDocument *document, int selectionStart = -1, int selectionCount = -1)

    Adds the contents of \a document to the text node at \a position. If \a selectionStart is >= 0,
    then this marks the first character in a selected area of \a selectionCount number of
    characters. The selection is represented as a background fill with the \l selectionColor() and
    the selected text is rendered in the \l selectionTextColor().
*/

QT_END_NAMESPACE