6#include "QskPageIndicatorSkinlet.h"
7#include "QskPageIndicator.h"
10#include "QskFunctions.h"
13 const QRectF& rect,
int index )
17 const auto n = indicator->count();
18 if ( n <= 0 || index < 0 || index >= n )
23 if ( indicator->orientation() == Qt::Horizontal )
24 index = n - ( index + 1 );
28 const qreal spacing = indicator->
spacingHint( Q::Panel );
29 const auto alignment = indicator->
alignmentHint( Q::Panel, Qt::AlignCenter );
33 if ( indicator->orientation() == Qt::Horizontal )
35 const auto maxWidth = n * size.width() + ( n - 1 ) * spacing;
36 const auto r = qskAlignedRectF( rect, maxWidth, size.height(), alignment );
38 x = r.x() + index * ( size.width() + spacing );
43 const auto maxHeight = n * size.height() + ( n - 1 ) * spacing;
44 const auto r = qskAlignedRectF( rect, maxHeight, size.height(), alignment );
47 y = r.y() + index * ( size.height() + spacing );;
50 return QRectF( x, y, size.width(), size.height() );
53QskPageIndicatorSkinlet::QskPageIndicatorSkinlet(
QskSkin* skin )
56 setNodeRoles( { PanelRole, BulletsRole } );
59QskPageIndicatorSkinlet::~QskPageIndicatorSkinlet()
63QRectF QskPageIndicatorSkinlet::subControlRect(
const QskSkinnable* skinnable,
66 if ( subControl == QskPageIndicator::Panel )
69 return Inherited::subControlRect( skinnable, contentsRect, subControl );
72QSGNode* QskPageIndicatorSkinlet::updateSubNode(
73 const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node )
const
80 return updateBoxNode( skinnable, node, Q::Panel );
83 return updateSeriesNode( skinnable, Q::Bullet, node );
86 return Inherited::updateSubNode( skinnable, nodeRole, node );
89int QskPageIndicatorSkinlet::sampleCount(
94 if ( subControl == Q::Bullet )
97 return indicator->count();
100 return Inherited::sampleCount( skinnable, subControl );
103QRectF QskPageIndicatorSkinlet::sampleRect(
const QskSkinnable* skinnable,
108 if ( subControl == Q::Bullet )
113 return qskBulletRect( indicator, rect, index );
116 return Inherited::sampleRect( skinnable, contentsRect, subControl, index );
119int QskPageIndicatorSkinlet::sampleIndexAt(
120 const QskSkinnable* skinnable,
const QRectF& contentsRect,
124 return Inherited::sampleIndexAt( skinnable, contentsRect, subControl, pos );
127QSGNode* QskPageIndicatorSkinlet::updateSampleNode(
const QskSkinnable* skinnable,
132 if ( subControl == Q::Bullet )
136 const auto rect = sampleRect( indicator, indicator->
contentsRect(), Q::Bullet, index );
137 const auto ratio = indicator->valueRatioAt( index );
143 const auto selectedStates = Q::Selected | indicator->skinStates();
145 return QskSkinlet::updateInterpolatedBoxNode( skinnable, node,
146 rect, Q::Bullet, Q::Bullet | selectedStates, ratio );
152QSizeF QskPageIndicatorSkinlet::sizeHint(
const QskSkinnable* skinnable,
153 Qt::SizeHint which,
const QSizeF& )
const
157 if ( which != Qt::PreferredSize )
162 QSizeF size( 0.0, 0.0 );
163 const int n = indicator->count();
168 const qreal spacing = indicator->
spacingHint( Q::Panel );
170 if ( indicator->orientation() == Qt::Horizontal )
171 size.rwidth() += ( n - 1 ) * ( size.width() + spacing );
173 size.rheight() += ( n - 1 ) * ( size.height() + spacing );
176 const auto hint = indicator->
outerBoxSize( Q::Panel, size );
177 return hint.expandedTo( indicator->
strutSizeHint( Q::Panel ) );
180#include "moc_QskPageIndicatorSkinlet.cpp"
Subcontrol
For use within the rendering or lay-outing of a specific QskSkinnable.
QRectF subControlContentsRect(QskAspect::Subcontrol) const
QRectF contentsRect() const
bool layoutMirroring() const
Describes the rendering interface of a QskControl. Change the skinlet to change the appearance of the...
qreal spacingHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a spacing hint.
QSizeF strutSizeHint(QskAspect, QskSkinHintStatus *=nullptr) const
Retrieves a strut size hint.
QSizeF outerBoxSize(QskAspect, const QSizeF &innerBoxSize) const
Calculate the size, when being expanded by paddings, indentations.
Qt::Alignment alignmentHint(QskAspect, Qt::Alignment=Qt::Alignment()) const
Retrieves an alignment hint.