aboutsummaryrefslogtreecommitdiffstats
path: root/src/quick/scenegraph/qsgdefaultglyphnode.cpp
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@digia.com>2013-03-12 18:43:21 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-04-05 15:38:04 +0200
commit57855fd6a2d3d0d3a1abbafa1000d6a1a7ce3d40 (patch)
tree75e3fccd73525341dfc5b66b4661afaeac5cdde6 /src/quick/scenegraph/qsgdefaultglyphnode.cpp
parentfedd27e1faa65d38a1a5b11f750b5ae2fb5c4006 (diff)
Implemented text styles for QSGDefaultGlyphNode.
Used when Text has renderType: Text.NativeRendering. Task-number: QTBUG-27867 Change-Id: Id1262ef49e26229c86ebd2533b9f6de638bc75cb Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/quick/scenegraph/qsgdefaultglyphnode.cpp')
-rw-r--r--src/quick/scenegraph/qsgdefaultglyphnode.cpp63
1 files changed, 52 insertions, 11 deletions
diff --git a/src/quick/scenegraph/qsgdefaultglyphnode.cpp b/src/quick/scenegraph/qsgdefaultglyphnode.cpp
index 55eadab704..8f24485fc0 100644
--- a/src/quick/scenegraph/qsgdefaultglyphnode.cpp
+++ b/src/quick/scenegraph/qsgdefaultglyphnode.cpp
@@ -48,7 +48,8 @@
QT_BEGIN_NAMESPACE
QSGDefaultGlyphNode::QSGDefaultGlyphNode()
- : m_material(0)
+ : m_style(QQuickText::Normal)
+ , m_material(0)
, m_geometry(QSGGeometry::defaultAttributes_TexturedPoint2D(), 0)
{
m_geometry.setDrawingMode(GL_TRIANGLES);
@@ -74,22 +75,62 @@ void QSGDefaultGlyphNode::setGlyphs(const QPointF &position, const QGlyphRun &gl
if (m_material != 0)
delete m_material;
- QRawFont font = glyphs.rawFont();
- m_material = new QSGTextMaskMaterial(font);
+ m_position = position;
+ m_glyphs = glyphs;
+
+#ifdef QML_RUNTIME_TESTING
+ description = QLatin1String("glyphs");
+#endif
+}
+
+void QSGDefaultGlyphNode::setStyle(QQuickText::TextStyle style)
+{
+ if (m_style == style)
+ return;
+ m_style = style;
+}
+
+void QSGDefaultGlyphNode::setStyleColor(const QColor &color)
+{
+ if (m_styleColor == color)
+ return;
+ m_styleColor = color;
+}
+
+void QSGDefaultGlyphNode::update()
+{
+ QRawFont font = m_glyphs.rawFont();
+ QMargins margins(0, 0, 0, 0);
+
+ if (m_style == QQuickText::Normal) {
+ m_material = new QSGTextMaskMaterial(font);
+ } else if (m_style == QQuickText::Outline) {
+ QSGOutlinedTextMaterial *material = new QSGOutlinedTextMaterial(font);
+ material->setStyleColor(m_styleColor);
+ m_material = material;
+ margins = QMargins(1, 1, 1, 1);
+ } else {
+ QSGStyledTextMaterial *material = new QSGStyledTextMaterial(font);
+ if (m_style == QQuickText::Sunken) {
+ material->setStyleShift(QPointF(0, -1));
+ margins.setTop(1);
+ } else if (m_style == QQuickText::Raised) {
+ material->setStyleShift(QPointF(0, 1));
+ margins.setBottom(1);
+ }
+ material->setStyleColor(m_styleColor);
+ m_material = material;
+ }
+
m_material->setColor(m_color);
QRectF boundingRect;
- m_material->populate(position, glyphs.glyphIndexes(), glyphs.positions(), geometry(),
- &boundingRect, &m_baseLine);
-
- setMaterial(m_material);
+ m_material->populate(m_position, m_glyphs.glyphIndexes(), m_glyphs.positions(), geometry(),
+ &boundingRect, &m_baseLine, margins);
setBoundingRect(boundingRect);
+ setMaterial(m_material);
markDirty(DirtyGeometry);
-
-#ifdef QML_RUNTIME_TESTING
- description = QLatin1String("glyphs");
-#endif
}
QT_END_NAMESPACE