From 7dbb81e94a9966fa4c0d16814bf9406dd6a1f398 Mon Sep 17 00:00:00 2001 From: Mike Krus Date: Wed, 7 Nov 2018 15:46:31 +0000 Subject: Add documentation for QText2DEntity Also fix the shaders to work on macOS Change-Id: If1fb183741c21b284474c9d747c8dd4c70b9d779 Reviewed-by: Wieland Hagen Reviewed-by: Paul Lemire --- src/extras/shaders/gl3/distancefieldtext.frag | 2 +- src/extras/shaders/gl3/distancefieldtext.vert | 2 +- src/extras/text/qtext2dentity.cpp | 95 ++++++++++++++++++++++++--- 3 files changed, 88 insertions(+), 11 deletions(-) diff --git a/src/extras/shaders/gl3/distancefieldtext.frag b/src/extras/shaders/gl3/distancefieldtext.frag index c53f3df55..23dff8e0f 100644 --- a/src/extras/shaders/gl3/distancefieldtext.frag +++ b/src/extras/shaders/gl3/distancefieldtext.frag @@ -1,4 +1,4 @@ -#version 130 +#version 150 core uniform sampler2D distanceFieldTexture; uniform float minAlpha; diff --git a/src/extras/shaders/gl3/distancefieldtext.vert b/src/extras/shaders/gl3/distancefieldtext.vert index 74a48f426..f6743001c 100644 --- a/src/extras/shaders/gl3/distancefieldtext.vert +++ b/src/extras/shaders/gl3/distancefieldtext.vert @@ -1,4 +1,4 @@ -#version 130 +#version 150 core in vec3 vertexPosition; in vec2 vertexTexCoord; diff --git a/src/extras/text/qtext2dentity.cpp b/src/extras/text/qtext2dentity.cpp index ae25e8ecc..aa4785fe7 100644 --- a/src/extras/text/qtext2dentity.cpp +++ b/src/extras/text/qtext2dentity.cpp @@ -69,6 +69,72 @@ inline Q_DECL_CONSTEXPR QRectF scaleRectF(const QRectF &rect, float scale) namespace Qt3DExtras { +/*! + * \qmltype Text2DEntity + * \instantiates Qt3DExtras::QText2DEntity + * \inqmlmodule Qt3D.Extras + * \brief Text2DEntity allows creation of a 2D text in 3D space. + * + * The Text2DEntity renders text as triangles in the XY plane. The geometry will be fitted + * in the rectangle of specified width and height. If the resulting geometry is wider than + * the specified width, the remainder will be rendered on the new line. + * + * The entity can be positionned in the scene by adding a transform component. + * + * Text2DEntity will create geometry based on the shape of the glyphs and a solid + * material using the specified color. + * + */ + +/*! + * \qmlproperty QString Text2DEntity::text + * + * Holds the text used for the mesh. + */ + +/*! + * \qmlproperty QFont Text2DEntity::font + * + * Holds the font of the text. + */ + +/*! + * \qmlproperty QColor Text2DEntity::color + * + * Holds the color of the text. + */ + +/*! + * \qmlproperty float Text2DEntity::width + * + * Holds the width of the text's bounding rectangle. + */ + +/*! + * \qmlproperty float Text2DEntity::height + * + * Holds the height of the text's bounding rectangle. + */ + + +/*! + * \class Qt3DExtras::QText2DEntity + * \inheaderfile Qt3DExtras/QText2DEntity + * \inmodule Qt3DExtras + * + * \brief QText2DEntity allows creation of a 2D text in 3D space. + * + * The QText2DEntity renders text as triangles in the XY plane. The geometry will be fitted + * in the rectangle of specified width and height. If the resulting geometry is wider than + * the specified width, the remainder will be rendered on the new line. + * + * The entity can be positionned in the scene by adding a transform component. + * + * QText2DEntity will create geometry based on the shape of the glyphs and a solid + * material using the specified color. + * + */ + QHash QText2DEntityPrivate::m_glyphCacheInstances; QText2DEntityPrivate::QText2DEntityPrivate() @@ -129,6 +195,7 @@ QText2DEntity::QText2DEntity(QNode *parent) { } +/*! \internal */ QText2DEntity::~QText2DEntity() { } @@ -298,8 +365,10 @@ void QText2DEntityPrivate::update() } /*! - Returns the font for the text item that is displayed - in the Qt Quick scene. + \property QText2DEntity::font + + Holds the font for the text item that is displayed + in the Qt Quick scene. */ QFont QText2DEntity::font() const { @@ -326,8 +395,10 @@ void QText2DEntity::setFont(const QFont &font) } /*! - Returns the color for the text item that is displayed in the Qt - Quick scene. + \property QText2DEntity::color + + Holds the color for the text item that is displayed in the Qt + Quick scene. */ QColor QText2DEntity::color() const { @@ -349,7 +420,9 @@ void QText2DEntity::setColor(const QColor &color) } /*! - Returns the text that is displayed in the Qt Quick scene. + \property QText2DEntity::text + + Holds the text that is displayed in the Qt Quick scene. */ QString QText2DEntity::text() const { @@ -369,8 +442,10 @@ void QText2DEntity::setText(const QString &text) } /*! - Returns the width of the text item that is displayed in the - Qt Quick scene. + \property QText2DEntity::width + + Returns the width of the text item that is displayed in the + Qt Quick scene. */ float QText2DEntity::width() const { @@ -379,8 +454,10 @@ float QText2DEntity::width() const } /*! - Returns the width of the text item that is displayed in the - Qt Quick scene. + \property QText2DEntity::height + + Returns the height of the text item that is displayed in the + Qt Quick scene. */ float QText2DEntity::height() const { -- cgit v1.2.3