7#include "QskArcMetrics.h"
8#include "QskArcRenderNode.h"
9#include "QskArcRenderer.h"
10#include "QskMargins.h"
11#include "QskGradient.h"
13#include "QskRgbValue.h"
29static void qskUpdateChildren( QSGNode* parentNode, quint8 role, QSGNode* node )
31 static const QVector< quint8 > roles = { ArcRole, FillRole };
33 auto oldNode = QskSGNode::findChildNode( parentNode, role );
34 QskSGNode::replaceChildNode( roles, role, parentNode, oldNode, node );
37template<
typename Node >
38inline Node* qskNode( QSGNode* parentNode, quint8 role )
40 using namespace QskSGNode;
42 auto node =
static_cast< Node*
> ( findChildNode( parentNode, role ) );
44 if ( node ==
nullptr )
47 setNodeRole( node, role );
53QskArcNode::QskArcNode()
57QskArcNode::~QskArcNode()
61void QskArcNode::setArcData(
const QRectF& rect,
64 setArcData( rect, arcMetrics, 0.0, QColor(), gradient );
67void QskArcNode::setArcData(
const QRectF& rect,
const QskArcMetrics& arcMetrics,
68 const qreal borderWidth,
const QColor& borderColor,
const QskGradient& gradient )
70 using namespace QskSGNode;
75 if ( !( rect.isEmpty() || arcMetrics.isNull() ) )
77 const bool radial =
false;
78 const auto metricsArc = arcMetrics.toAbsolute( rect.size() );
80 const auto hasFilling = gradient.isVisible();
81 const auto hasBorder = ( borderWidth > 0.0 ) && QskRgb::isVisible( borderColor );
83 if ( hasBorder || hasFilling )
85 arcNode = qskNode< QskArcRenderNode >(
this, ArcRole );
87 if ( hasBorder && hasFilling )
89 const bool doCombine = arcNode->hasHint( QskFillNode::PreferColoredGeometry )
90 && QskArcRenderer::isGradientSupported( rect, metricsArc, gradient );
93 fillNode = qskNode< QskArcRenderNode >(
this, FillRole );
98 arcNode->updateBorder( rect, metricsArc,
99 radial, borderWidth, borderColor );
101 fillNode->updateFilling( rect, metricsArc, radial, borderWidth, gradient );
105 arcNode->updateArc( rect, metricsArc,
106 radial, borderWidth, borderColor, gradient );
111 qskUpdateChildren(
this, ArcRole, arcNode );
112 qskUpdateChildren(
this, FillRole, fillNode );