6#include "QskProgressRingSkinlet.h"
7#include "QskArcMetrics.h"
8#include "QskProgressRing.h"
9#include "QskIntervalF.h"
29 std::swap( pos1, pos2 );
34static inline QPair< qreal, qreal > qskFillAngles(
37 const auto startAngle = metrics.startAngle() + intv.lowerBound() * metrics.spanAngle();
38 const auto endAngle = metrics.startAngle() + intv.upperBound() * metrics.spanAngle();
40 return { startAngle, endAngle };
43QskProgressRingSkinlet::QskProgressRingSkinlet(
QskSkin* skin )
48QskProgressRingSkinlet::~QskProgressRingSkinlet()
52QRectF QskProgressRingSkinlet::subControlRect(
53 const QskSkinnable* skinnable,
const QRectF& contentsRect,
56 if( subControl == Q::Groove || subControl == Q::Fill )
59 return Inherited::subControlRect( skinnable, contentsRect, subControl );
62QSGNode* QskProgressRingSkinlet::updateGrooveNode(
65 const auto ring =
static_cast< const Q*
>( indicator );
71 const auto fillMetrics = ring->arcMetricsHint( Q::Fill );
72 if ( fillMetrics.isClosed() )
74 const auto fillAngles = qskFillAngles( fillMetrics, qskFillInterval( ring ) );
76 qreal startAngle, endAngle;
77 if ( fillAngles.second > fillAngles.first )
79 startAngle = fillAngles.second + spacing;
80 endAngle = fillAngles.first + 360.0 - spacing;
84 startAngle = fillAngles.second - spacing;
85 endAngle = fillAngles.first - 360.0 + spacing;
88 return updateArcNode( ring, node,
89 startAngle, endAngle - startAngle, Q::Groove );
93 return updateArcNode( indicator, node, Q::Groove );
96QSGNode* QskProgressRingSkinlet::updateFillNode(
99 const auto ring =
static_cast< const Q*
>( indicator );
101 const auto subControl = Q::Fill;
104 if ( rect.isEmpty() )
107 const auto metrics = ring->arcMetricsHint( subControl );
108 if ( metrics.isNull() )
111 auto gradient = ring->gradientHint( subControl );
112 if ( !gradient.isVisible() )
115 const auto intv = qskFillInterval( ring );
117 if ( ( gradient.type() == QskGradient::Stops ) && !gradient.isMonochrome() )
119 const auto stops = qskExtractedGradientStops( gradient.stops(),
120 intv.lowerBound(), intv.upperBound() );
122 gradient.setStops( stops );
124 if ( metrics.spanAngle() < 0.0 )
128 const auto angles = qskFillAngles( metrics, intv );
130 return updateArcNode( ring, node, rect, gradient,
131 angles.first, angles.second - angles.first, subControl );
134QSizeF QskProgressRingSkinlet::sizeHint(
const QskSkinnable* skinnable,
135 Qt::SizeHint which,
const QSizeF& constraint )
const
137 if ( which != Qt::PreferredSize )
141 hint = hint.expandedTo( skinnable->
strutSizeHint( Q::Groove ) );
143 if ( !constraint.isEmpty() )
145 const qreal aspectRatio = hint.isEmpty() ? 1.0 : hint.width() / hint.height();
147 if ( constraint.width() >= 0.0 )
148 hint.setHeight( constraint.width() / aspectRatio );
150 hint.setWidth( constraint.height() * aspectRatio );
156#include "moc_QskProgressRingSkinlet.cpp"
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
QRectF subControlRect(QskAspect::Subcontrol) const
Base class for progress indicators.
bool isIndeterminate() const
static const QskAspect::Subcontrol Fill
Circular progress indicator.
qreal spacingHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a spacing hint.
QSizeF strutSizeHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a strut size hint.