Logscale: Fix negative ranges

This fixes errors that happen on models that have both logarithmic scale and a range that goes to the negative.
This commit is contained in:
Vesa
2014-06-21 10:56:28 +03:00
parent 8da423412c
commit f7042977a9
2 changed files with 18 additions and 4 deletions

View File

@@ -674,8 +674,10 @@ void knob::setPosition( const QPoint & _p )
if( model()->isScaleLogarithmic() ) // logarithmic code
{
const float pos = ( oldValue - model()->minValue() ) / model()->range();
const float ratio = 0.1f + pos * 15.f;
const float pos = model()->minValue() < 0
? oldValue / qMax( qAbs( model()->maxValue() ), qAbs( model()->minValue() ) )
: ( oldValue - model()->minValue() ) / model()->range();
const float ratio = 0.1f + qAbs( pos ) * 15.f;
float newValue = value * ratio;
if( qAbs( newValue ) >= step )
{