QskPageIndicator improved
This commit is contained in:
parent
1feccd942a
commit
4a3b419470
|
@ -136,4 +136,9 @@ qreal QskPageIndicator::valueRatioAt( int index ) const
|
|||
return 0.0;
|
||||
}
|
||||
|
||||
QskAspect::Placement QskPageIndicator::effectivePlacement() const
|
||||
{
|
||||
return static_cast< QskAspect::Placement >( m_data->orientation );
|
||||
}
|
||||
|
||||
#include "moc_QskPageIndicator.cpp"
|
||||
|
|
|
@ -46,6 +46,8 @@ class QSK_EXPORT QskPageIndicator : public QskControl
|
|||
|
||||
qreal valueRatioAt( int index ) const;
|
||||
|
||||
QskAspect::Placement effectivePlacement() const override;
|
||||
|
||||
Q_SIGNALS:
|
||||
void countChanged( int );
|
||||
void currentIndexChanged( qreal );
|
||||
|
|
|
@ -24,30 +24,31 @@ static QRectF qskBulletRect( const QskPageIndicator* indicator,
|
|||
{
|
||||
using Q = QskPageIndicator;
|
||||
|
||||
/*
|
||||
The bullets might have different sizes, but as a pager indicator
|
||||
usually does not have many bullets we can simply iterate
|
||||
*/
|
||||
const auto n = indicator->count();
|
||||
if ( n <= 0 || index < 0 || index >= n )
|
||||
return QRectF();
|
||||
|
||||
const qreal spacing = indicator->spacingHint( Q::Panel );
|
||||
const auto size = indicator->strutSizeHint( Q::Bullet );
|
||||
const qreal spacing = indicator->spacingHint( Q::Panel );
|
||||
const auto alignment = indicator->alignmentHint( Q::Panel, Qt::AlignCenter );
|
||||
|
||||
qreal x = rect.x();
|
||||
qreal y = rect.y();
|
||||
qreal x, y;
|
||||
|
||||
if ( indicator->orientation() == Qt::Horizontal )
|
||||
{
|
||||
for ( int i = 0; i < index; i++ )
|
||||
x += size.width() + spacing;
|
||||
const auto maxWidth = n * size.width() + ( n - 1 ) * spacing;
|
||||
const auto r = qskAlignedRectF( rect, maxWidth, size.height(), alignment );
|
||||
|
||||
y += 0.5 * ( rect.height() - size.height() );
|
||||
x = r.x() + index * ( size.width() + spacing );
|
||||
y = r.y();
|
||||
}
|
||||
else
|
||||
{
|
||||
for ( int i = 0; i < index; i++ )
|
||||
y += size.height() + spacing;
|
||||
const auto maxHeight = n * size.height() + ( n - 1 ) * spacing;
|
||||
const auto r = qskAlignedRectF( rect, maxHeight, size.height(), alignment );
|
||||
|
||||
x += 0.5 * ( rect.width() - size.width() );
|
||||
x = r.x();
|
||||
y = r.y() + index * ( size.height() + spacing );;
|
||||
}
|
||||
|
||||
return QRectF( x, y, size.width(), size.height() );
|
||||
|
|
Loading…
Reference in New Issue