QskFillNode::Hints added
This commit is contained in:
parent
f0f17b3cb5
commit
58344c0c4e
@ -115,7 +115,7 @@ void QskFillNode::setColoring( Coloring coloring )
|
|||||||
|
|
||||||
QskFillNode::Coloring QskFillNode::coloring() const
|
QskFillNode::Coloring QskFillNode::coloring() const
|
||||||
{
|
{
|
||||||
return d_func()->coloring;
|
return static_cast< QskFillNode::Coloring >( d_func()->coloring );
|
||||||
}
|
}
|
||||||
|
|
||||||
void QskFillNode::setColoring( const QColor& color )
|
void QskFillNode::setColoring( const QColor& color )
|
||||||
@ -147,7 +147,34 @@ void QskFillNode::setColoring( const QRectF& rect, const QskGradient& gradient )
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QskFillNode::setHint( Hint hint, bool on )
|
||||||
|
{
|
||||||
|
Q_D( QskFillNode );
|
||||||
|
|
||||||
|
if ( on )
|
||||||
|
d->hints |= hint;
|
||||||
|
else
|
||||||
|
d->hints &= ~hint;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QskFillNode::setHints( Hints hints )
|
||||||
|
{
|
||||||
|
d_func()->hints = hints;
|
||||||
|
}
|
||||||
|
|
||||||
|
QskFillNode::Hints QskFillNode::hints() const
|
||||||
|
{
|
||||||
|
return static_cast< QskFillNode::Hints >( d_func()->hints );
|
||||||
|
}
|
||||||
|
|
||||||
|
bool QskFillNode::hasHint( Hint hint ) const
|
||||||
|
{
|
||||||
|
return d_func()->hints & hint;
|
||||||
|
}
|
||||||
|
|
||||||
bool QskFillNode::isGeometryColored() const
|
bool QskFillNode::isGeometryColored() const
|
||||||
{
|
{
|
||||||
return d_func()->geometry.attributeCount() != 1;
|
return d_func()->geometry.attributeCount() != 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#include "moc_QskFillNode.cpp"
|
||||||
|
@ -8,12 +8,15 @@
|
|||||||
|
|
||||||
#include "QskGlobal.h"
|
#include "QskGlobal.h"
|
||||||
#include <qsgnode.h>
|
#include <qsgnode.h>
|
||||||
|
#include <qcolor.h>
|
||||||
|
|
||||||
class QskFillNodePrivate;
|
class QskFillNodePrivate;
|
||||||
class QskGradient;
|
class QskGradient;
|
||||||
|
|
||||||
class QSK_EXPORT QskFillNode : public QSGGeometryNode
|
class QSK_EXPORT QskFillNode : public QSGGeometryNode
|
||||||
{
|
{
|
||||||
|
Q_GADGET
|
||||||
|
|
||||||
using Inherited = QSGGeometryNode;
|
using Inherited = QSGGeometryNode;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
@ -27,6 +30,28 @@ class QSK_EXPORT QskFillNode : public QSGGeometryNode
|
|||||||
Conic
|
Conic
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum Hint
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
Colors might be defined in the material ( QskGradientMaterial,
|
||||||
|
QSGFlatColorMaterial ) or attached to each point ( QSGVertexColorMaterial ).
|
||||||
|
|
||||||
|
The main advantage of using colored points is, that the material becomes
|
||||||
|
independent of the coloring and the scene graph is able to batch the nodes
|
||||||
|
( https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph.html ).
|
||||||
|
|
||||||
|
However adding the color information for each point increases the memory
|
||||||
|
footprint.
|
||||||
|
|
||||||
|
The default setting is to use colored points where possible. Note, that
|
||||||
|
this is what is also done in the Qt/Quick code.
|
||||||
|
*/
|
||||||
|
PreferColoredGeometry = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
Q_ENUM( Hint )
|
||||||
|
Q_DECLARE_FLAGS( Hints, Hint )
|
||||||
|
|
||||||
QskFillNode();
|
QskFillNode();
|
||||||
~QskFillNode() override;
|
~QskFillNode() override;
|
||||||
|
|
||||||
@ -35,11 +60,20 @@ class QSK_EXPORT QskFillNode : public QSGGeometryNode
|
|||||||
void setColoring( Coloring );
|
void setColoring( Coloring );
|
||||||
Coloring coloring() const;
|
Coloring coloring() const;
|
||||||
|
|
||||||
|
void setColoring( QRgb );
|
||||||
void setColoring( const QColor& );
|
void setColoring( const QColor& );
|
||||||
|
void setColoring( Qt::GlobalColor );
|
||||||
|
|
||||||
void setColoring( const QRectF&, const QskGradient& );
|
void setColoring( const QRectF&, const QskGradient& );
|
||||||
|
|
||||||
bool isGeometryColored() const;
|
bool isGeometryColored() const;
|
||||||
|
|
||||||
|
void setHints( Hints );
|
||||||
|
Hints hints() const;
|
||||||
|
|
||||||
|
void setHint( Hint, bool on = true );
|
||||||
|
bool hasHint( Hint ) const;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
QskFillNode( QskFillNodePrivate& );
|
QskFillNode( QskFillNodePrivate& );
|
||||||
|
|
||||||
@ -47,4 +81,14 @@ class QSK_EXPORT QskFillNode : public QSGGeometryNode
|
|||||||
Q_DECLARE_PRIVATE( QskFillNode )
|
Q_DECLARE_PRIVATE( QskFillNode )
|
||||||
};
|
};
|
||||||
|
|
||||||
|
inline void QskFillNode::setColoring( QRgb rgb )
|
||||||
|
{
|
||||||
|
setColoring( QColor::fromRgba( rgb ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
inline void QskFillNode::setColoring( Qt::GlobalColor color )
|
||||||
|
{
|
||||||
|
setColoring( QColor( color ) );
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -19,6 +19,8 @@ class QskFillNodePrivate : public QSGGeometryNodePrivate
|
|||||||
public:
|
public:
|
||||||
inline QskFillNodePrivate()
|
inline QskFillNodePrivate()
|
||||||
: geometry( QSGGeometry::defaultAttributes_ColoredPoint2D(), 0 )
|
: geometry( QSGGeometry::defaultAttributes_ColoredPoint2D(), 0 )
|
||||||
|
, coloring( QskFillNode::Polychrome )
|
||||||
|
, hints( QskFillNode::PreferColoredGeometry )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -26,7 +28,9 @@ class QskFillNodePrivate : public QSGGeometryNodePrivate
|
|||||||
friend class QskFillNode;
|
friend class QskFillNode;
|
||||||
|
|
||||||
QSGGeometry geometry;
|
QSGGeometry geometry;
|
||||||
QskFillNode::Coloring coloring = QskFillNode::Polychrome;
|
|
||||||
|
uint coloring : 5;
|
||||||
|
uint hints : 3;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user