using strutSize
This commit is contained in:
parent
6bb7486578
commit
a49ef1daa4
|
@ -24,7 +24,7 @@ CustomSlider::CustomSlider( QQuickItem* parentItem )
|
||||||
setGradientHint( Fill, Grey700 );
|
setGradientHint( Fill, Grey700 );
|
||||||
setColor( Scale, qRgb( 178, 178, 178 ) ); // for the ticks
|
setColor( Scale, qRgb( 178, 178, 178 ) ); // for the ticks
|
||||||
|
|
||||||
setMetric( Handle | QskAspect::Size, 80 );
|
setStrutSizeHint( Handle, 80, 80 );
|
||||||
setColor( Handle, Grey800 );
|
setColor( Handle, Grey800 );
|
||||||
|
|
||||||
for ( auto state : { Pressed, Focused | Hovered, Hovered, Focused } )
|
for ( auto state : { Pressed, Focused | Hovered, Hovered, Focused } )
|
||||||
|
|
|
@ -222,9 +222,13 @@ QRectF CustomSliderSkinlet::handleRect(
|
||||||
handleRect.moveCenter( QPointF( fillRect.right(), handleRect.center().y() ) );
|
handleRect.moveCenter( QPointF( fillRect.right(), handleRect.center().y() ) );
|
||||||
|
|
||||||
if ( handleRect.left() < contentsRect.left() )
|
if ( handleRect.left() < contentsRect.left() )
|
||||||
|
{
|
||||||
handleRect.moveLeft( contentsRect.left() );
|
handleRect.moveLeft( contentsRect.left() );
|
||||||
|
}
|
||||||
else if ( handleRect.right() > contentsRect.right() )
|
else if ( handleRect.right() > contentsRect.right() )
|
||||||
|
{
|
||||||
handleRect.moveRight( contentsRect.right() );
|
handleRect.moveRight( contentsRect.right() );
|
||||||
|
}
|
||||||
|
|
||||||
return handleRect;
|
return handleRect;
|
||||||
}
|
}
|
||||||
|
@ -327,21 +331,21 @@ QSGNode* CustomSliderSkinlet::updateDecorationNode(
|
||||||
QSGNode* CustomSliderSkinlet::updateHandleNode(
|
QSGNode* CustomSliderSkinlet::updateHandleNode(
|
||||||
const QskSlider* slider, QSGNode* node ) const
|
const QskSlider* slider, QSGNode* node ) const
|
||||||
{
|
{
|
||||||
const QRectF handleRect = subControlRect(
|
const auto cr = slider->contentsRect();
|
||||||
slider, slider->contentsRect(), QskSlider::Handle );
|
|
||||||
|
const auto handleRect = subControlRect( slider, cr, QskSlider::Handle );
|
||||||
|
|
||||||
if ( handleRect.isEmpty() )
|
if ( handleRect.isEmpty() )
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
const QRectF fillRect = subControlRect(
|
const auto fillRect = subControlRect( slider, cr, QskSlider::Fill );
|
||||||
slider, slider->contentsRect(), QskSlider::Fill );
|
|
||||||
|
|
||||||
auto handleNode = static_cast< HandleNode* >( node );
|
auto handleNode = static_cast< HandleNode* >( node );
|
||||||
if ( handleNode == nullptr )
|
if ( handleNode == nullptr )
|
||||||
handleNode = new HandleNode();
|
handleNode = new HandleNode();
|
||||||
|
|
||||||
handleNode->update( handleRect, fillRect.right(),
|
const auto handleColor = slider->color( QskSlider::Handle );
|
||||||
slider->color( QskSlider::Handle ) );
|
handleNode->update( handleRect, fillRect.right(), handleColor );
|
||||||
|
|
||||||
// finally the value label
|
// finally the value label
|
||||||
auto labelNode = static_cast< QskTextNode* >( handleNode->firstChild() );
|
auto labelNode = static_cast< QskTextNode* >( handleNode->firstChild() );
|
||||||
|
@ -359,7 +363,7 @@ QSGNode* CustomSliderSkinlet::updateHandleNode(
|
||||||
auto textRect = handleRect;
|
auto textRect = handleRect;
|
||||||
textRect.setTop( textRect.bottom() - 0.5 * ( textRect.height() - qskPeak + h ) );
|
textRect.setTop( textRect.bottom() - 0.5 * ( textRect.height() - qskPeak + h ) );
|
||||||
|
|
||||||
const QString text = QString::number( slider->value(), 'f', 0 );
|
const auto text = QString::number( slider->value(), 'f', 0 );
|
||||||
|
|
||||||
labelNode->setTextData( slider, text, textRect, font, QskTextOptions(),
|
labelNode->setTextData( slider, text, textRect, font, QskTextOptions(),
|
||||||
QskTextColors( Qt::white ), Qt::AlignHCenter, Qsk::Normal );
|
QskTextColors( Qt::white ), Qt::AlignHCenter, Qsk::Normal );
|
||||||
|
|
|
@ -293,7 +293,8 @@ void QskMaterialSkin::initPageIndicatorHints()
|
||||||
|
|
||||||
for ( auto subControl : { Q::Bullet, Q::Highlighted } )
|
for ( auto subControl : { Q::Bullet, Q::Highlighted } )
|
||||||
{
|
{
|
||||||
setMetric( subControl | Size, qskDpiScaled( 10 ) );
|
const auto extent = qskDpiScaled( 10 );
|
||||||
|
setStrutSize( subControl, extent, extent );
|
||||||
|
|
||||||
// circles, without border
|
// circles, without border
|
||||||
setBoxShape( subControl, 100, Qt::RelativeSize );
|
setBoxShape( subControl, 100, Qt::RelativeSize );
|
||||||
|
@ -441,17 +442,17 @@ void QskMaterialSkin::initSliderHints()
|
||||||
|
|
||||||
const auto& pal = m_data->palette;
|
const auto& pal = m_data->palette;
|
||||||
|
|
||||||
const qreal dim = 30;
|
const qreal extent = 30;
|
||||||
|
|
||||||
// Panel
|
// Panel
|
||||||
|
|
||||||
setMetric( Q::Panel | Size, dim );
|
setMetric( Q::Panel | Size, extent );
|
||||||
setBoxShape( Q::Panel, 0 );
|
setBoxShape( Q::Panel, 0 );
|
||||||
setBoxBorderMetrics( Q::Panel, 0 );
|
setBoxBorderMetrics( Q::Panel, 0 );
|
||||||
setGradient( Q::Panel, QskGradient() );
|
setGradient( Q::Panel, QskGradient() );
|
||||||
|
|
||||||
setPadding( Q::Panel | Horizontal, QskMargins( 0.5 * dim, 0 ) );
|
setPadding( Q::Panel | Horizontal, QskMargins( 0.5 * extent, 0 ) );
|
||||||
setPadding( Q::Panel | Vertical, QskMargins( 0, 0.5 * dim ) );
|
setPadding( Q::Panel | Vertical, QskMargins( 0, 0.5 * extent ) );
|
||||||
|
|
||||||
// Groove, Fill
|
// Groove, Fill
|
||||||
|
|
||||||
|
@ -475,8 +476,9 @@ void QskMaterialSkin::initSliderHints()
|
||||||
setBoxBorderMetrics( Q::Handle, 4 );
|
setBoxBorderMetrics( Q::Handle, 4 );
|
||||||
|
|
||||||
// handle expanding, when being pressed
|
// handle expanding, when being pressed
|
||||||
setMetric( Q::Handle | Size, 0.6 * dim );
|
QSize extentSize( extent, extent );
|
||||||
setMetric( Q::Handle | Size | Q::Pressed, dim );
|
setStrutSize( Q::Handle, 0.6 * extentSize );
|
||||||
|
setStrutSize( Q::Handle | Q::Pressed, extentSize );
|
||||||
|
|
||||||
setGradient( Q::Handle | Q::Disabled, Grey );
|
setGradient( Q::Handle | Q::Disabled, Grey );
|
||||||
setBoxBorderColors( Q::Handle | Q::Disabled, Grey );
|
setBoxBorderColors( Q::Handle | Q::Disabled, Grey );
|
||||||
|
|
|
@ -391,16 +391,16 @@ void QskSquiekSkin::initPageIndicatorHints()
|
||||||
|
|
||||||
for ( auto subControl : { Q::Bullet, Q::Highlighted } )
|
for ( auto subControl : { Q::Bullet, Q::Highlighted } )
|
||||||
{
|
{
|
||||||
setMetric( subControl | Size, qskDpiScaled( 12 ) );
|
const auto extent = qskDpiScaled( 12 );
|
||||||
|
setStrutSize( subControl, extent, extent );
|
||||||
|
|
||||||
setBoxBorderMetrics( subControl, QskBoxBorderMetrics( 50, Qt::RelativeSize ) );
|
setBoxBorderMetrics( subControl, 50, Qt::RelativeSize );
|
||||||
setBoxShape( subControl, 100, Qt::RelativeSize );
|
setBoxShape( subControl, 100, Qt::RelativeSize );
|
||||||
|
|
||||||
setGradient( subControl,
|
|
||||||
( subControl == Q::Bullet ) ? pal.darker150 : pal.lighter150 );
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setGradient( Q::Bullet, pal.darker150 );
|
||||||
|
setGradient( Q::Highlighted, pal.lighter150 );
|
||||||
|
|
||||||
// no visible background panel
|
// no visible background panel
|
||||||
setBoxBorderMetrics( Q::Panel, 0 );
|
setBoxBorderMetrics( Q::Panel, 0 );
|
||||||
setBoxShape( Q::Panel, 2 );
|
setBoxShape( Q::Panel, 2 );
|
||||||
|
@ -604,7 +604,7 @@ void QskSquiekSkin::initSliderHints()
|
||||||
|
|
||||||
const auto& pal = m_data->palette;
|
const auto& pal = m_data->palette;
|
||||||
|
|
||||||
const qreal dim = 40;
|
const qreal extent = 40;
|
||||||
|
|
||||||
// Panel
|
// Panel
|
||||||
|
|
||||||
|
@ -612,14 +612,14 @@ void QskSquiekSkin::initSliderHints()
|
||||||
{
|
{
|
||||||
const auto aspect = Q::Panel | placement;
|
const auto aspect = Q::Panel | placement;
|
||||||
|
|
||||||
setMetric( aspect | Size, dim );
|
setMetric( aspect | Size, extent );
|
||||||
setBoxBorderMetrics( aspect, 0 );
|
setBoxBorderMetrics( aspect, 0 );
|
||||||
setBoxShape( aspect, 0 );
|
setBoxShape( aspect, 0 );
|
||||||
setGradient( aspect, QskGradient() );
|
setGradient( aspect, QskGradient() );
|
||||||
}
|
}
|
||||||
|
|
||||||
setPadding( Q::Panel | Horizontal, QskMargins( 0.5 * dim, 0 ) );
|
setPadding( Q::Panel | Horizontal, QskMargins( 0.5 * extent, 0 ) );
|
||||||
setPadding( Q::Panel | Vertical, QskMargins( 0, 0.5 * dim ) );
|
setPadding( Q::Panel | Vertical, QskMargins( 0, 0.5 * extent ) );
|
||||||
|
|
||||||
// Groove, Fill
|
// Groove, Fill
|
||||||
|
|
||||||
|
@ -629,17 +629,15 @@ void QskSquiekSkin::initSliderHints()
|
||||||
{
|
{
|
||||||
const auto aspect = subControl | placement;
|
const auto aspect = subControl | placement;
|
||||||
|
|
||||||
setMetric( aspect | Size, 0.3 * dim );
|
setMetric( aspect | Size, 0.3 * extent );
|
||||||
setPadding( aspect, 0 );
|
setPadding( aspect, 0 );
|
||||||
|
|
||||||
setBoxBorderMetrics( aspect, 0 );
|
setBoxBorderMetrics( aspect, 0 );
|
||||||
setBoxShape( aspect, 0.1 * dim );
|
setBoxShape( aspect, 0.1 * extent );
|
||||||
|
|
||||||
if ( subControl == Q::Groove )
|
|
||||||
setGradient( aspect, pal.darker200 );
|
|
||||||
else
|
|
||||||
setGradient( aspect, QskGradient() ); // no filling
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setGradient( Q::Groove | placement, pal.darker200 );
|
||||||
|
setGradient( Q::Fill | placement, QskGradient() ); // no filling
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle
|
// Handle
|
||||||
|
@ -651,7 +649,9 @@ void QskSquiekSkin::initSliderHints()
|
||||||
setButton( aspect, Raised, 1 );
|
setButton( aspect, Raised, 1 );
|
||||||
setBoxShape( aspect, 20.0, Qt::RelativeSize );
|
setBoxShape( aspect, 20.0, Qt::RelativeSize );
|
||||||
setButton( aspect | Q::Pressed, Sunken, 1 );
|
setButton( aspect | Q::Pressed, Sunken, 1 );
|
||||||
setMetric( Q::Handle | Size, 0.75 * dim );
|
|
||||||
|
const qreal sz = 0.75 * extent;
|
||||||
|
setStrutSize( aspect, sz, sz );
|
||||||
}
|
}
|
||||||
|
|
||||||
setAnimation( Q::Handle | Color, qskDuration );
|
setAnimation( Q::Handle | Color, qskDuration );
|
||||||
|
@ -669,10 +669,10 @@ void QskSquiekSkin::initTabBarHints()
|
||||||
const qreal vb = 1.0; // borderWidth of the view
|
const qreal vb = 1.0; // borderWidth of the view
|
||||||
const qreal pw = 1.0; // extra space for the negative padding of the buttons
|
const qreal pw = 1.0; // extra space for the negative padding of the buttons
|
||||||
|
|
||||||
setPadding( Q::Panel | Top, QskMargins( pw, 0.0, pw, vb ) );
|
setPadding( Q::Panel | Top, pw, 0.0, pw, vb );
|
||||||
setPadding( Q::Panel | Bottom, QskMargins( pw, vb, pw, 0.0 ) );
|
setPadding( Q::Panel | Bottom, pw, vb, pw, 0.0 );
|
||||||
setPadding( Q::Panel | Left, QskMargins( 0.0, pw, vb, pw ) );
|
setPadding( Q::Panel | Left, 0.0, pw, vb, pw );
|
||||||
setPadding( Q::Panel | Right, QskMargins( vb, pw, 0.0, pw ) );
|
setPadding( Q::Panel | Right, vb, pw, 0.0, pw );
|
||||||
|
|
||||||
// when flicking
|
// when flicking
|
||||||
setAnimation( Q::Panel | Metric, QskAnimationHint( 200, QEasingCurve::OutCubic ) );
|
setAnimation( Q::Panel | Metric, QskAnimationHint( 200, QEasingCurve::OutCubic ) );
|
||||||
|
@ -706,7 +706,6 @@ void QskSquiekSkin::initInputPanelHints()
|
||||||
|
|
||||||
void QskSquiekSkin::initInputPredictionBar()
|
void QskSquiekSkin::initInputPredictionBar()
|
||||||
{
|
{
|
||||||
using namespace QskAspect;
|
|
||||||
using Q = QskInputPredictionBar;
|
using Q = QskInputPredictionBar;
|
||||||
|
|
||||||
const auto& pal = m_data->palette;
|
const auto& pal = m_data->palette;
|
||||||
|
|
|
@ -66,7 +66,7 @@ void QskPageIndicator::setOrientation( Qt::Orientation orientation )
|
||||||
resetImplicitSize();
|
resetImplicitSize();
|
||||||
update();
|
update();
|
||||||
|
|
||||||
Q_EMIT orientationChanged();
|
Q_EMIT orientationChanged( orientation );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -79,7 +79,7 @@ void QskPageIndicator::setCount( int count )
|
||||||
resetImplicitSize();
|
resetImplicitSize();
|
||||||
update();
|
update();
|
||||||
|
|
||||||
Q_EMIT countChanged();
|
Q_EMIT countChanged( count );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -93,7 +93,7 @@ void QskPageIndicator::setCurrentIndex( qreal index )
|
||||||
m_data->currentIndex = index;
|
m_data->currentIndex = index;
|
||||||
update();
|
update();
|
||||||
|
|
||||||
Q_EMIT currentIndexChanged();
|
Q_EMIT currentIndexChanged( index );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +103,9 @@ QSizeF QskPageIndicator::contentsSizeHint(
|
||||||
if ( which != Qt::PreferredSize )
|
if ( which != Qt::PreferredSize )
|
||||||
return QSizeF();
|
return QSizeF();
|
||||||
|
|
||||||
const qreal sizeBullet = metric( Bullet | QskAspect::Size );
|
const auto bulletSize = strutSizeHint( Bullet );
|
||||||
const qreal sizeCurrent = metric( Highlighted | QskAspect::Size );
|
const auto maxSize = bulletSize.expandedTo( strutSizeHint( Highlighted ) );
|
||||||
|
|
||||||
const qreal spacing = spacingHint( Panel );
|
const qreal spacing = spacingHint( Panel );
|
||||||
|
|
||||||
const int n = m_data->count;
|
const int n = m_data->count;
|
||||||
|
@ -116,25 +117,25 @@ QSizeF QskPageIndicator::contentsSizeHint(
|
||||||
{
|
{
|
||||||
if ( n > 0 )
|
if ( n > 0 )
|
||||||
{
|
{
|
||||||
w += qMax( sizeCurrent, sizeBullet );
|
w += maxSize.width();
|
||||||
|
|
||||||
if ( n > 1 )
|
if ( n > 1 )
|
||||||
w += ( n - 1 ) * ( sizeBullet + spacing );
|
w += ( n - 1 ) * ( bulletSize.width() + spacing );
|
||||||
}
|
}
|
||||||
|
|
||||||
h = qMax( sizeCurrent, sizeBullet );
|
h = maxSize.height();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( n > 0 )
|
if ( n > 0 )
|
||||||
{
|
{
|
||||||
h += qMax( sizeCurrent, sizeBullet );
|
h += maxSize.height();
|
||||||
|
|
||||||
if ( n > 1 )
|
if ( n > 1 )
|
||||||
h += ( n - 1 ) * ( sizeBullet + spacing );
|
h += ( n - 1 ) * ( bulletSize.height() + spacing );
|
||||||
}
|
}
|
||||||
|
|
||||||
w = qMax( sizeCurrent, sizeBullet );
|
w = maxSize.width();
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto hint = outerBoxSize( Panel, QSizeF( w, h ) );
|
const auto hint = outerBoxSize( Panel, QSizeF( w, h ) );
|
||||||
|
|
|
@ -41,9 +41,9 @@ class QSK_EXPORT QskPageIndicator : public QskControl
|
||||||
void setOrientation( Qt::Orientation );
|
void setOrientation( Qt::Orientation );
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void countChanged();
|
void countChanged( int );
|
||||||
void currentIndexChanged();
|
void currentIndexChanged( qreal );
|
||||||
void orientationChanged();
|
void orientationChanged( Qt::Orientation );
|
||||||
|
|
||||||
public Q_SLOTS:
|
public Q_SLOTS:
|
||||||
void setCount( int count );
|
void setCount( int count );
|
||||||
|
|
|
@ -56,15 +56,17 @@ QRectF QskPageIndicatorSkinlet::bulletRect(
|
||||||
{
|
{
|
||||||
using Q = QskPageIndicator;
|
using Q = QskPageIndicator;
|
||||||
|
|
||||||
const qreal szNormal = indicator->metric( Q::Bullet | QskAspect::Size );
|
const qreal szNormal = indicator->strutSizeHint( Q::Bullet ).width();
|
||||||
const qreal szHighlighted = indicator->metric( Q::Highlighted | QskAspect::Size );
|
const qreal szHighlighted = indicator->strutSizeHint( Q::Highlighted ).width();
|
||||||
|
|
||||||
|
const auto currentIndex = indicator->currentIndex();
|
||||||
|
|
||||||
// scale bullet size if we are in between a transition:
|
// scale bullet size if we are in between a transition:
|
||||||
qreal indexDiff = qAbs( indicator->currentIndex() - index );
|
qreal indexDiff = qAbs( currentIndex - index );
|
||||||
if ( indexDiff > ( indicator->count() - 1 ) )
|
if ( indexDiff > ( indicator->count() - 1 ) )
|
||||||
indexDiff = ( indicator->count() - indicator->currentIndex() ); // wrapping
|
indexDiff = ( indicator->count() - currentIndex ); // wrapping
|
||||||
|
|
||||||
const qreal sz = ( indexDiff < 1 ) ?
|
const qreal sz0 = ( indexDiff < 1 ) ?
|
||||||
( 1 - indexDiff ) * szHighlighted + indexDiff * szNormal : szNormal;
|
( 1 - indexDiff ) * szHighlighted + indexDiff * szNormal : szNormal;
|
||||||
|
|
||||||
const qreal spacing = indicator->spacingHint( Q::Panel );
|
const qreal spacing = indicator->spacingHint( Q::Panel );
|
||||||
|
@ -85,44 +87,48 @@ QRectF QskPageIndicatorSkinlet::bulletRect(
|
||||||
QRectF r( 0, 0, w, h );
|
QRectF r( 0, 0, w, h );
|
||||||
r.moveCenter( rect.center() );
|
r.moveCenter( rect.center() );
|
||||||
|
|
||||||
const qreal s = ( index > indicator->currentIndex() ) ? szHighlighted : szNormal;
|
|
||||||
|
|
||||||
qreal s2;
|
qreal s2;
|
||||||
if ( indexDiff < 1 && index >= indicator->currentIndex() )
|
|
||||||
|
{
|
||||||
|
const qreal s = ( index > currentIndex ) ? szHighlighted : szNormal;
|
||||||
|
if ( indexDiff < 1 && index >= currentIndex )
|
||||||
{
|
{
|
||||||
// scrolling from or to this bullet:
|
// scrolling from or to this bullet:
|
||||||
s2 = szNormal + qAbs( szHighlighted - szNormal ) * indexDiff;
|
s2 = szNormal + qAbs( szHighlighted - szNormal ) * indexDiff;
|
||||||
}
|
}
|
||||||
else if ( ( indicator->currentIndex() > ( indicator->count() - 1 ) &&
|
else if ( ( currentIndex > ( indicator->count() - 1 ) &&
|
||||||
index > ( indicator->currentIndex() - indicator->count() + 1 ) ) )
|
index > ( currentIndex - indicator->count() + 1 ) ) )
|
||||||
{
|
{
|
||||||
// wrapping case:
|
// wrapping case:
|
||||||
qreal wrappingDiff = indexDiff;
|
qreal wrappingDiff = indexDiff;
|
||||||
while ( wrappingDiff > 1 )
|
while ( wrappingDiff > 1 )
|
||||||
wrappingDiff -= 1;
|
wrappingDiff -= 1;
|
||||||
|
|
||||||
s2 = szNormal + qAbs( szHighlighted - szNormal ) * wrappingDiff;
|
s2 = szNormal + qAbs( szHighlighted - szNormal ) * wrappingDiff;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
s2 = s;
|
s2 = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal x = r.left() + s2 + spacing + ( index - 1 ) * ( szNormal + spacing );
|
|
||||||
|
|
||||||
qreal yAdjust;
|
|
||||||
if ( indicator->currentIndex() == index )
|
|
||||||
{
|
|
||||||
yAdjust = qMax( 0.0, szNormal - szHighlighted ) / 2;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
yAdjust = qMax( 0.0, szHighlighted - szNormal ) / 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const qreal x = r.left() + s2 + spacing + ( index - 1 ) * ( szNormal + spacing );
|
||||||
|
|
||||||
|
qreal adjust = ( currentIndex == index )
|
||||||
|
? ( szNormal - szHighlighted ) : ( szHighlighted - szNormal );
|
||||||
|
adjust = 0.5 * qMax( 0.0, adjust );
|
||||||
|
|
||||||
if ( indexDiff < 1 )
|
if ( indexDiff < 1 )
|
||||||
yAdjust *= indexDiff;
|
adjust *= indexDiff;
|
||||||
const qreal y = ( horizontal ? r.top() : r.left() ) + yAdjust;
|
|
||||||
|
|
||||||
return horizontal ? QRectF( x, y, sz, sz ) : QRectF( y, x, sz, sz );
|
QRectF bulletRect( 0.0, 0.0, sz0, sz0 );
|
||||||
|
|
||||||
|
if ( horizontal )
|
||||||
|
bulletRect.moveTo( x, r.top() + adjust );
|
||||||
|
else
|
||||||
|
bulletRect.moveTo( r.left() + adjust, x );
|
||||||
|
|
||||||
|
return bulletRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSGNode* QskPageIndicatorSkinlet::updateBulletsNode(
|
QSGNode* QskPageIndicatorSkinlet::updateBulletsNode(
|
||||||
|
|
|
@ -123,9 +123,9 @@ QSizeF QskSlider::contentsSizeHint(
|
||||||
if ( which != Qt::PreferredSize )
|
if ( which != Qt::PreferredSize )
|
||||||
return QSizeF();
|
return QSizeF();
|
||||||
|
|
||||||
const qreal dim = metric( QskSlider::Panel | QskAspect::Size );
|
const qreal extent = metric( QskSlider::Panel | QskAspect::Size );
|
||||||
return ( m_data->orientation == Qt::Horizontal )
|
return ( m_data->orientation == Qt::Horizontal )
|
||||||
? QSizeF( 4 * dim, dim ) : QSizeF( dim, 4 * dim );
|
? QSizeF( 4 * extent, extent ) : QSizeF( extent, 4 * extent );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF QskSlider::handleSize() const
|
QSizeF QskSlider::handleSize() const
|
||||||
|
|
|
@ -10,11 +10,19 @@
|
||||||
#include "QskBoxBorderMetrics.h"
|
#include "QskBoxBorderMetrics.h"
|
||||||
#include "QskFunctions.h"
|
#include "QskFunctions.h"
|
||||||
|
|
||||||
static inline QMarginsF qskPadding(
|
static inline QRectF qskInnerPanelRect(
|
||||||
const QskSlider* slider, QskAspect::Subcontrol subControl )
|
const QskSlider* slider, const QRectF& contentsRect )
|
||||||
{
|
{
|
||||||
return slider->paddingHint( subControl ) +
|
using Q = QskSlider;
|
||||||
slider->boxBorderMetricsHint( subControl ).widths();
|
|
||||||
|
// QskSkinnable::innerBox ???
|
||||||
|
auto padding = slider->paddingHint( Q::Panel );
|
||||||
|
padding += slider->boxBorderMetricsHint( Q::Panel ).widths();
|
||||||
|
|
||||||
|
auto r = slider->subControlRect( contentsRect, Q::Panel );
|
||||||
|
r = r.marginsRemoved( padding );
|
||||||
|
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
QskSliderSkinlet::QskSliderSkinlet( QskSkin* skin )
|
QskSliderSkinlet::QskSliderSkinlet( QskSkin* skin )
|
||||||
|
@ -113,8 +121,7 @@ QRectF QskSliderSkinlet::panelRect(
|
||||||
QRectF QskSliderSkinlet::innerRect( const QskSlider* slider,
|
QRectF QskSliderSkinlet::innerRect( const QskSlider* slider,
|
||||||
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const
|
||||||
{
|
{
|
||||||
QRectF r = subControlRect( slider, contentsRect, QskSlider::Panel );
|
auto r = qskInnerPanelRect( slider, contentsRect );
|
||||||
r = r.marginsRemoved( qskPadding( slider, QskSlider::Panel ) );
|
|
||||||
|
|
||||||
QskSkinHintStatus status;
|
QskSkinHintStatus status;
|
||||||
|
|
||||||
|
@ -155,15 +162,10 @@ QRectF QskSliderSkinlet::scaleRect(
|
||||||
QRectF QskSliderSkinlet::fillRect(
|
QRectF QskSliderSkinlet::fillRect(
|
||||||
const QskSlider* slider, const QRectF& contentsRect ) const
|
const QskSlider* slider, const QRectF& contentsRect ) const
|
||||||
{
|
{
|
||||||
using Q = QskSlider;
|
const auto r = qskInnerPanelRect( slider, contentsRect );
|
||||||
|
const auto pos = qBound( 0.0, slider->handlePosition(), 1.0 );
|
||||||
|
|
||||||
auto r = subControlRect( slider, contentsRect, Q::Panel );
|
auto fillRect = innerRect( slider, contentsRect, QskSlider::Fill );
|
||||||
r = r.marginsRemoved( qskPadding( slider, Q::Panel ) );
|
|
||||||
|
|
||||||
qreal pos = slider->metric( Q::Handle | QskAspect::Position );
|
|
||||||
pos = qBound( 0.0, pos, 1.0 );
|
|
||||||
|
|
||||||
auto fillRect = innerRect( slider, contentsRect, Q::Fill );
|
|
||||||
if ( slider->orientation() == Qt::Horizontal )
|
if ( slider->orientation() == Qt::Horizontal )
|
||||||
{
|
{
|
||||||
fillRect.setLeft( r.left() );
|
fillRect.setLeft( r.left() );
|
||||||
|
@ -183,42 +185,38 @@ QRectF QskSliderSkinlet::handleRect(
|
||||||
{
|
{
|
||||||
using Q = QskSlider;
|
using Q = QskSlider;
|
||||||
|
|
||||||
auto r = subControlRect( slider, contentsRect, Q::Panel );
|
auto handleSize = slider->strutSizeHint( Q::Handle );
|
||||||
r = r.marginsRemoved( qskPadding( slider, Q::Panel ) );
|
const auto pos = qBound( 0.0, slider->handlePosition(), 1.0 );
|
||||||
|
|
||||||
const bool isHorizontal = slider->orientation() == Qt::Horizontal;
|
const auto r = qskInnerPanelRect( slider, contentsRect );
|
||||||
|
auto center = r.center();
|
||||||
qreal extent;
|
|
||||||
|
|
||||||
{
|
|
||||||
QskSkinHintStatus status;
|
|
||||||
|
|
||||||
extent = slider->metric( Q::Handle | QskAspect::Size, &status );
|
|
||||||
if ( !status.isValid() )
|
|
||||||
extent = isHorizontal ? r.height() : r.width();
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF handleRect( 0, 0, extent, extent );
|
|
||||||
if ( extent > 0 )
|
|
||||||
{
|
|
||||||
handleRect = handleRect.marginsRemoved(
|
|
||||||
slider->marginHint( Q::Handle) );
|
|
||||||
}
|
|
||||||
|
|
||||||
qreal pos = slider->metric( Q::Handle | QskAspect::Position );
|
|
||||||
pos = qBound( 0.0, pos, 1.0 );
|
|
||||||
|
|
||||||
if ( slider->orientation() == Qt::Horizontal )
|
if ( slider->orientation() == Qt::Horizontal )
|
||||||
{
|
{
|
||||||
pos = r.left() + pos * r.width();
|
if ( handleSize.height() < 0.0 )
|
||||||
handleRect.moveCenter( QPointF( pos, r.center().y() ) );
|
handleSize.setHeight( r.height() );
|
||||||
|
|
||||||
|
if ( handleSize.width() < 0.0 )
|
||||||
|
handleSize.setWidth( handleSize.height() );
|
||||||
|
|
||||||
|
center.setX( r.left() + pos * r.width() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
pos = r.bottom() - pos * r.height();
|
if ( handleSize.width() < 0.0 )
|
||||||
handleRect.moveCenter( QPointF( r.center().x(), pos ) );
|
handleSize.setWidth( r.width() );
|
||||||
|
|
||||||
|
if ( handleSize.height() < 0.0 )
|
||||||
|
handleSize.setHeight( handleSize.width() );
|
||||||
|
|
||||||
|
center.setY( r.bottom() - pos * r.height() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QRectF handleRect( 0, 0, handleSize.width(), handleSize.height() );
|
||||||
|
handleRect.moveCenter( center );
|
||||||
|
|
||||||
|
handleRect = handleRect.marginsRemoved( slider->marginHint( Q::Handle ) );
|
||||||
|
|
||||||
return handleRect;
|
return handleRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue