6#include "QskProgressBarSkinlet.h"
7#include "QskProgressBar.h"
8#include "QskIntervalF.h"
9#include "QskBoxBorderMetrics.h"
11#include <qeasingcurve.h>
22 if ( indicator->isIndeterminate() )
24 const auto pos = indicator->positionHint( QskProgressIndicator::Fill );
26 static const QEasingCurve curve( QEasingCurve::InOutCubic );
28 const qreal off = 0.15;
30 pos1 = curve.valueForProgress( qMax( pos - off, 0.0 ) );
31 pos2 = curve.valueForProgress( qMin( pos + off, 1.0 ) );
35 pos1 = indicator->valueAsRatio( indicator->origin() );
36 pos2 = indicator->valueAsRatio( indicator->value() );
40 if( bar->orientation() == Qt::Horizontal )
42 if ( bar->layoutMirroring() )
50 std::swap( pos1, pos2 );
56QskProgressBarSkinlet::QskProgressBarSkinlet(
QskSkin* skin )
61QskProgressBarSkinlet::~QskProgressBarSkinlet()
65QRectF QskProgressBarSkinlet::subControlRect(
66 const QskSkinnable* skinnable,
const QRectF& contentsRect,
69 const auto bar =
static_cast< const Q*
>( skinnable );
71 if( subControl == Q::Groove )
75 auto rect = contentsRect;
76 if ( bar->orientation() == Qt::Horizontal )
78 rect.setY( rect.y() + 0.5 * ( rect.height() - grooveSize ) );
79 rect.setHeight( grooveSize );
83 rect.setX( rect.x() + 0.5 * ( rect.width() - grooveSize ) );
84 rect.setWidth( grooveSize );
90 if( subControl == Q::Fill )
92 return barRect( bar );
95 return Inherited::subControlRect( skinnable, contentsRect, subControl );
98QSGNode* QskProgressBarSkinlet::updateGrooveNode(
101 return updateBoxNode( indicator, node, Q::Groove );
104QSGNode* QskProgressBarSkinlet::updateFillNode(
107 const auto bar =
static_cast< const Q*
>( indicator );
109 const auto subControl = Q::Fill;
112 if ( rect.isEmpty() )
116 if ( !gradient.isVisible() )
119 if ( ( gradient.type() == QskGradient::Stops ) && !gradient.isMonochrome() )
133 const auto intv = qskFillInterval( bar );
135 const auto stops = qskExtractedGradientStops( gradient.stops(),
136 intv.lowerBound(), intv.upperBound() );
138 gradient.setStops( stops );
140 gradient.setLinearDirection(
static_cast< Qt::Orientation
>( bar->orientation() ) );
142 if ( bar->orientation() == Qt::Vertical || bar->layoutMirroring() )
146 return updateBoxNode( indicator, node, rect, gradient, subControl );
149QRectF QskProgressBarSkinlet::barRect(
const Q* bar )
const
151 const auto subControl = Q::Groove;
156 if ( bar->orientation() == Qt::Horizontal )
158 rect.setY( rect.y() + 0.5 * ( rect.height() - barSize ) );
159 rect.setHeight( barSize );
163 rect.setX( rect.x() + 0.5 * ( rect.width() - barSize ) );
164 rect.setWidth( barSize );
170 m += 0.5 * borderMetrics.toAbsolute( rect.size() ).widths();
172 rect = rect.marginsRemoved( m );
174 const auto intv = qskFillInterval( bar );
176 if( bar->orientation() == Qt::Horizontal )
178 const auto w = rect.width();
180 rect.setRight( rect.left() + intv.upperBound() * w );
181 rect.setLeft( rect.left() + intv.lowerBound() * w );
185 const auto h = rect.height();
187 rect.setTop( rect.bottom() - h * intv.upperBound() );
188 rect.setBottom( rect.bottom() - h * intv.lowerBound() );
194QSizeF QskProgressBarSkinlet::sizeHint(
const QskSkinnable* skinnable,
195 Qt::SizeHint which,
const QSizeF& )
const
197 if ( which != Qt::PreferredSize )
200 const auto bar =
static_cast< const Q*
>( skinnable );
202 const auto extent = bar->extent();
204 if ( bar->orientation() == Qt::Horizontal )
205 return QSizeF( -1, extent );
207 return QSizeF( extent, -1 );
210#include "moc_QskProgressBarSkinlet.cpp"
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
QRectF subControlRect(QskAspect::Subcontrol) const
QMarginsF paddingHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a padding hint.
QskGradient gradientHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a color hint as gradient.
QskBoxBorderMetrics boxBorderMetricsHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a border hint.
qreal metric(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a metric hint.