diff --git a/src/controls/QskPageIndicator.cpp b/src/controls/QskPageIndicator.cpp index abd786cb..49911e96 100644 --- a/src/controls/QskPageIndicator.cpp +++ b/src/controls/QskPageIndicator.cpp @@ -102,8 +102,8 @@ QSizeF QskPageIndicator::contentsSizeHint() const { using namespace QskAspect; - const QSizeF sizeBullet = bulletSize( Bullet ); - const QSizeF sizeCurrent = bulletSize( Highlighted ); + const qreal sizeBullet = metric( Bullet | Size ); + const qreal sizeCurrent = metric( Highlighted | Size ); const qreal spacing = metric( Panel | Spacing ); const int n = m_data->count; @@ -115,39 +115,33 @@ QSizeF QskPageIndicator::contentsSizeHint() const { if ( n > 0 ) { - w += qMax( sizeCurrent.width(), sizeBullet.width() ); + w += qMax( sizeCurrent, sizeBullet ); if ( n > 1 ) - w += ( n - 1 ) * ( sizeBullet.width() + spacing ); + w += ( n - 1 ) * ( sizeBullet + spacing ); } - h = qMax( sizeCurrent.height(), sizeBullet.height() ); + h = qMax( sizeCurrent, sizeBullet ); } else { if ( n > 0 ) { - h += qMax( sizeCurrent.height(), sizeBullet.height() ); + h += qMax( sizeCurrent, sizeBullet ); if ( n > 1 ) - h += ( n - 1 ) * ( sizeBullet.height() + spacing ); + h += ( n - 1 ) * ( sizeBullet + spacing ); } - w = qMax( sizeCurrent.width(), sizeBullet.width() ); + w = qMax( sizeCurrent, sizeBullet ); } const QSizeF minSize( - metric( Panel | QskAspect::MinimumWidth ), - metric( Panel | QskAspect::MinimumHeight ) ); + metric( Panel | MinimumWidth ), + metric( Panel | MinimumHeight ) ); return outerBoxSize( Panel, QSizeF( w, h ) ).expandedTo( minSize ); } -QSizeF QskPageIndicator::bulletSize( QskAspect::Subcontrol subControl ) const -{ - const qreal dim = metric( subControl | QskAspect::Size ); - return QSizeF( dim, dim ); -} - #include "moc_QskPageIndicator.cpp" diff --git a/src/controls/QskPageIndicator.h b/src/controls/QskPageIndicator.h index 458736dc..af7c0e22 100644 --- a/src/controls/QskPageIndicator.h +++ b/src/controls/QskPageIndicator.h @@ -36,8 +36,6 @@ public: virtual QSizeF contentsSizeHint() const override; - QSizeF bulletSize( QskAspect::Subcontrol ) const; - Q_SIGNALS: void countChanged(); void currentIndexChanged(); diff --git a/src/controls/QskPageIndicatorSkinlet.cpp b/src/controls/QskPageIndicatorSkinlet.cpp index d1fd1714..d0e15fd4 100644 --- a/src/controls/QskPageIndicatorSkinlet.cpp +++ b/src/controls/QskPageIndicatorSkinlet.cpp @@ -54,11 +54,8 @@ QSGNode* QskPageIndicatorSkinlet::updateSubNode( const QskSkinnable* skinnable, QRectF QskPageIndicatorSkinlet::bulletRect( const QskPageIndicator* indicator, const QRectF& rect, int index ) const { -#if 1 - // ignoring, that width/height might differ !!! - const qreal szNormal = indicator->bulletSize( QskPageIndicator::Bullet ).width(); - const qreal szHighlighted = indicator->bulletSize( QskPageIndicator::Highlighted ).width(); -#endif + const qreal szNormal = indicator->metric( QskPageIndicator::Bullet | QskAspect::Size ); + const qreal szHighlighted = indicator->metric( QskPageIndicator::Highlighted | QskAspect::Size ); // scale bullet size if we are in between a transition: qreal indexDiff = qAbs( indicator->currentIndex() - index ); @@ -82,29 +79,27 @@ QRectF QskPageIndicatorSkinlet::bulletRect( w = rect.width(); h = ( indicator->count() - 1 ) * ( szNormal + spacing ) + szHighlighted; } + QRectF r( 0, 0, w, h ); r.moveCenter( rect.center() ); - // x-adjust (in horizontal mode) when not scrolling: const qreal s = ( index > indicator->currentIndex() ) ? szHighlighted : szNormal; - // adapt x-adjust while scrolling: qreal s2; - // scrolling from or to this bullet: if ( indexDiff < 1 && index >= indicator->currentIndex() ) { + // scrolling from or to this bullet: s2 = szNormal + qAbs( szHighlighted - szNormal ) * indexDiff; } - // wrapping case: else if ( ( indicator->currentIndex() > ( indicator->count() - 1 ) && index > ( indicator->currentIndex() - indicator->count() + 1 ) ) ) { + // wrapping case: qreal wrappingDiff = indexDiff; while ( wrappingDiff > 1 ) wrappingDiff -= 1; s2 = szNormal + qAbs( szHighlighted - szNormal ) * wrappingDiff; } - // unrelated bullet: else { s2 = s;