qskinny/src/nodes/QskFillNode.h

95 lines
2.2 KiB
C
Raw Normal View History

2023-11-15 10:47:56 +00:00
/******************************************************************************
2024-01-17 13:31:45 +00:00
* QSkinny - Copyright (C) The authors
2023-11-15 10:47:56 +00:00
* SPDX-License-Identifier: BSD-3-Clause
*****************************************************************************/
#ifndef QSK_FILL_NODE_H
#define QSK_FILL_NODE_H
#include "QskGlobal.h"
#include <qsgnode.h>
2024-09-17 11:40:58 +00:00
#include <qcolor.h>
2023-11-15 10:47:56 +00:00
class QskFillNodePrivate;
class QskGradient;
class QSK_EXPORT QskFillNode : public QSGGeometryNode
{
2024-09-17 11:40:58 +00:00
Q_GADGET
2023-11-15 10:47:56 +00:00
using Inherited = QSGGeometryNode;
public:
enum Coloring
{
Monochrome,
Polychrome,
Linear,
Radial,
Conic
};
2024-09-17 11:40:58 +00:00
enum Hint
{
/*
Colors might be defined in the material ( QskGradientMaterial,
QSGFlatColorMaterial ) or attached to each point ( QSGVertexColorMaterial ).
2024-09-23 13:38:12 +00:00
Having colored points makes the material independent of the coloring
and the scene graph is able to batch the geometries
2024-09-17 11:40:58 +00:00
( https://doc.qt.io/qt-6/qtquick-visualcanvas-scenegraph.html ).
2024-09-23 13:38:12 +00:00
Having the colors in the material needs less memory and avoids updates
of the geometry only because of recoloring.
2024-09-17 11:40:58 +00:00
The default setting is to use colored points where possible. Note, that
2024-09-23 13:38:12 +00:00
this is what is also done in the Qt/Quick classes.
2024-09-17 11:40:58 +00:00
*/
PreferColoredGeometry = 1
};
Q_ENUM( Hint )
Q_DECLARE_FLAGS( Hints, Hint )
2023-11-15 10:47:56 +00:00
QskFillNode();
~QskFillNode() override;
void resetGeometry();
void setColoring( Coloring );
Coloring coloring() const;
2024-09-17 11:40:58 +00:00
void setColoring( QRgb );
2023-11-15 10:47:56 +00:00
void setColoring( const QColor& );
2024-09-17 11:40:58 +00:00
void setColoring( Qt::GlobalColor );
2023-11-15 10:47:56 +00:00
void setColoring( const QRectF&, const QskGradient& );
bool isGeometryColored() const;
2024-09-17 11:40:58 +00:00
void setHints( Hints );
Hints hints() const;
void setHint( Hint, bool on = true );
bool hasHint( Hint ) const;
2023-11-15 10:47:56 +00:00
protected:
QskFillNode( QskFillNodePrivate& );
private:
Q_DECLARE_PRIVATE( QskFillNode )
};
2024-09-17 11:40:58 +00:00
inline void QskFillNode::setColoring( QRgb rgb )
{
setColoring( QColor::fromRgba( rgb ) );
}
inline void QskFillNode::setColoring( Qt::GlobalColor color )
{
setColoring( QColor( color ) );
}
2023-11-15 10:47:56 +00:00
#endif