diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index a4096f9ba8e..dd9bd7680cf 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -407,7 +407,7 @@ class FloatModel : public AutomatableModel { } float getRoundedValue() const; - float getDigitCount(); + int getDigitCount() const; defaultTypedMethods(float); } ; diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index 468f701e509..0391061b65f 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -716,19 +716,19 @@ float AutomatableModel::globalAutomationValueAt( const MidiTime& time ) float FloatModel::getRoundedValue() const { - return static_cast( static_cast( value() / step() + 0.5 ) ) * step(); + return qRound( value() / step() ) * step(); } -float FloatModel::getDigitCount() +int FloatModel::getDigitCount() const { float steptemp = step(); int digits = 0; while ( steptemp < 1 ) { - steptemp = steptemp / 0.1f; + steptemp = steptemp * 10.0f; digits++; } return digits; diff --git a/src/gui/widgets/Knob.cpp b/src/gui/widgets/Knob.cpp index 2c173954010..73ef427585b 100644 --- a/src/gui/widgets/Knob.cpp +++ b/src/gui/widgets/Knob.cpp @@ -631,7 +631,6 @@ void Knob::mouseMoveEvent( QMouseEvent * _me ) emit sliderMoved( model()->value() ); QCursor::setPos( mapToGlobal( m_origMousePos ) ); } - s_textFloat->setText( displayValue() ); } @@ -735,7 +734,7 @@ void Knob::setPosition( const QPoint & _p ) float newValue = value * ratio; if( qAbs( newValue ) >= step ) { - float roundedValue = static_cast( static_cast( ( oldValue - newValue ) / step + 0.5 ) ) * step; + float roundedValue = qRound( ( oldValue - value ) / step ) * step; model()->setValue( roundedValue ); m_leftOver = 0.0f; } @@ -749,7 +748,7 @@ void Knob::setPosition( const QPoint & _p ) { if( qAbs( value ) >= step ) { - float roundedValue = static_cast( static_cast( ( oldValue - value ) / step + 0.5 ) ) * step; + float roundedValue = qRound( ( oldValue - value ) / step ) * step; model()->setValue( roundedValue ); m_leftOver = 0.0f; }