diff options
author | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com> | 2011-06-01 09:45:55 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-08-19 15:15:56 +0200 |
commit | 1cc58fdf174656a52603af00cb40478066c5abd4 (patch) | |
tree | 432054d60316a981b17655dc888805e4e5434966 /src/declarative/items/qsgtextnode_p.h | |
parent | 7059861a8b8d48b5187eb46a2678f306ba288320 (diff) |
Make QSGTextNode back-end for QML's TextInput and TextEdit
Use the general QSGTextNode class as back-end for all text
elements in QML to make all text elements look the same and
use the same text rasterization back-end. This requires a
few rewrites in the text node to support e.g. selections.
Crashes seen with threaded renderer in TextEdit and TextInput on
Mac are also fixed by this.
Reviewed-by: Jiang Jiang
Task-number: QTBUG-18019, QTBUG-20017
Change-Id: I4207faf180c83422e5f8b726741321af395bd724
Reviewed-on: http://codereview.qt.nokia.com/2865
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>
Diffstat (limited to 'src/declarative/items/qsgtextnode_p.h')
-rw-r--r-- | src/declarative/items/qsgtextnode_p.h | 38 |
1 files changed, 23 insertions, 15 deletions
diff --git a/src/declarative/items/qsgtextnode_p.h b/src/declarative/items/qsgtextnode_p.h index 7ff31998c6..4c5199aefa 100644 --- a/src/declarative/items/qsgtextnode_p.h +++ b/src/declarative/items/qsgtextnode_p.h @@ -54,10 +54,20 @@ class QColor; class QTextDocument; class QSGContext; class QRawFont; +class QSGSimpleRectNode; +class QSGClipNode; class QSGTextNode : public QSGTransformNode { public: + enum Decoration { + NoDecoration = 0x0, + Underline = 0x1, + Overline = 0x2, + StrikeOut = 0x4 + }; + Q_DECLARE_FLAGS(Decorations, Decoration) + QSGTextNode(QSGContext *); ~QSGTextNode(); @@ -65,26 +75,24 @@ public: void deleteContent(); void addTextLayout(const QPointF &position, QTextLayout *textLayout, const QColor &color = QColor(), - QSGText::TextStyle style = QSGText::Normal, const QColor &styleColor = QColor()); + QSGText::TextStyle style = QSGText::Normal, const QColor &styleColor = QColor(), + const QColor &selectionColor = QColor(), const QColor &selectedTextColor = QColor(), + int selectionStart = -1, int selectionEnd = -1); void addTextDocument(const QPointF &position, QTextDocument *textDocument, const QColor &color = QColor(), - QSGText::TextStyle style = QSGText::Normal, const QColor &styleColor = QColor()); + QSGText::TextStyle style = QSGText::Normal, const QColor &styleColor = QColor(), + const QColor &selectionColor = QColor(), const QColor &selectedTextColor = QColor(), + int selectionStart = -1, int selectionEnd = -1); -private: - enum Decoration { - NoDecoration = 0x0, - Underline = 0x1, - Overline = 0x2, - StrikeOut = 0x4 - }; + void setCursor(const QRectF &rect, const QColor &color); + QSGSimpleRectNode *cursorNode() const { return m_cursorNode; } - void addTextBlock(const QPointF &position, QTextDocument *textDocument, const QTextBlock &block, - const QColor &overrideColor, QSGText::TextStyle style = QSGText::Normal, const QColor &styleColor = QColor()); QSGGlyphNode *addGlyphs(const QPointF &position, const QGlyphRun &glyphs, const QColor &color, - QSGText::TextStyle style = QSGText::Normal, const QColor &styleColor = QColor(), - QSGGlyphNode *node = 0); - void addTextDecorations(Decoration decorations, const QPointF &position, const QColor &color, - qreal width, qreal lineThickness, qreal underlinePosition, qreal ascent); + QSGText::TextStyle style = QSGText::Normal, const QColor &styleColor = QColor(), + QSGNode *parentNode = 0); + +private: QSGContext *m_context; + QSGSimpleRectNode *m_cursorNode; }; QT_END_NAMESPACE |