snap mode improved for unaligned boundaries

This commit is contained in:
Uwe Rathmann 2021-04-19 09:29:22 +02:00
parent a73df141c6
commit 1f8ec04bde
1 changed files with 9 additions and 4 deletions

View File

@ -123,13 +123,18 @@ void QskBoundedInput::alignInput()
qreal QskBoundedInput::alignedValue( qreal value ) const qreal QskBoundedInput::alignedValue( qreal value ) const
{ {
if ( m_snap ) value = boundedValue( value );
if ( value > minimum() && value < maximum() )
{ {
if ( const auto step = m_stepSize ) if ( m_snap && m_stepSize )
value = qRound( value / step ) * step; {
value = qRound( value / m_stepSize ) * m_stepSize;
value = boundedValue( value );
}
} }
return boundedValue( value ); return value;
} }
QskIntervalF QskBoundedInput::alignedInterval( const QskIntervalF& interval ) const QskIntervalF QskBoundedInput::alignedInterval( const QskIntervalF& interval ) const