QskSlider: Do not exceed boundaries
This commit is contained in:
parent
525ca3bd0e
commit
05d3b15828
|
@ -136,15 +136,17 @@ QRectF QskSliderSkinlet::sampleRect(
|
||||||
|
|
||||||
if( slider->orientation() == Qt::Horizontal )
|
if( slider->orientation() == Qt::Horizontal )
|
||||||
{
|
{
|
||||||
r.setTop( r.center().y() - size.height() / 2 );
|
const auto y = r.center().y() - size.height() / 2;
|
||||||
|
r.setTop( qMax( 0.0, y ) );
|
||||||
const auto x = r.left() + slider->valueAsRatio( pos ) * r.width() - size.width() / 2;
|
const auto x = r.left() + slider->valueAsRatio( pos ) * r.width() - size.width() / 2;
|
||||||
r.setLeft( x );
|
r.setLeft( qMax( 0.0, x ) );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
r.setLeft( r.center().x() - size.width() / 2 );
|
const auto x = r.center().x() - size.width() / 2;
|
||||||
|
r.setLeft( qMax( 0.0, x ) );
|
||||||
const auto y = r.bottom() - slider->valueAsRatio( pos ) * r.height() - size.height() / 2;
|
const auto y = r.bottom() - slider->valueAsRatio( pos ) * r.height() - size.height() / 2;
|
||||||
r.setTop( y );
|
r.setTop( qMax( 0.0, y ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
r.setHeight( size.height() );
|
r.setHeight( size.height() );
|
||||||
|
|
Loading…
Reference in New Issue