6#include "QskProgressRingSkinlet.h"
7#include "QskArcMetrics.h"
8#include "QskProgressRing.h"
9#include "QskIntervalF.h"
13QskProgressRingSkinlet::QskProgressRingSkinlet(
QskSkin* skin )
18QskProgressRingSkinlet::~QskProgressRingSkinlet()
22QRectF QskProgressRingSkinlet::subControlRect(
23 const QskSkinnable* skinnable,
const QRectF& contentsRect,
26 if( subControl == Q::Groove || subControl == Q::Fill )
29 return Inherited::subControlRect( skinnable, contentsRect, subControl );
32QSGNode* QskProgressRingSkinlet::updateGrooveNode(
35 return updateArcNode( indicator, node, Q::Groove );
38QSGNode* QskProgressRingSkinlet::updateFillNode(
41 const auto ring =
static_cast< const Q*
>( indicator );
43 const auto subControl = Q::Fill;
49 const auto metrics = ring->arcMetricsHint( subControl );
50 if ( metrics.isNull() )
53 auto gradient = ring->gradientHint( subControl );
54 if ( !gradient.isVisible() )
57 const auto intv = fillInterval( ring );
59 if ( ( gradient.type() == QskGradient::Stops ) && !gradient.isMonochrome() )
61 const auto stops = qskExtractedGradientStops( gradient.stops(),
62 intv.lowerBound(), intv.upperBound() );
64 gradient.setStops( stops );
66 if ( metrics.spanAngle() < 0.0 )
70 const auto startAngle = metrics.startAngle() + intv.lowerBound() * metrics.spanAngle();
71 const auto spanAngle = intv.upperBound() * metrics.spanAngle();
73 return updateArcNode( ring, node, rect, gradient, startAngle, spanAngle, subControl );
76QSizeF QskProgressRingSkinlet::sizeHint(
const QskSkinnable* skinnable,
77 Qt::SizeHint which,
const QSizeF& constraint )
const
79 if ( which != Qt::PreferredSize )
83 hint = hint.expandedTo( skinnable->
strutSizeHint( Q::Groove ) );
85 if ( !constraint.isEmpty() )
87 const qreal aspectRatio = hint.isEmpty() ? 1.0 : hint.width() / hint.height();
89 if ( constraint.width() >= 0.0 )
90 hint.setHeight( constraint.width() / aspectRatio );
92 hint.setWidth( constraint.height() * aspectRatio );
103 if ( indicator->isIndeterminate() )
105 pos1 = pos2 = indicator->positionHint( QskProgressIndicator::Fill );
109 pos1 = indicator->valueAsRatio( indicator->origin() );
110 pos2 = indicator->valueAsRatio( indicator->value() );
114 std::swap( pos1, pos2 );
119#include "moc_QskProgressRingSkinlet.cpp"
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
QRectF subControlRect(QskAspect::Subcontrol) const
QSizeF strutSizeHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a strut size hint.