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