fixes rounding issue in automatablemodel (#3597)
* fixes rounding issue in automatablemodel * fix CRS knob sticking in instrument plugins
This commit is contained in:
committed by
GitHub
parent
143571761f
commit
5a2d8f12ad
@@ -407,7 +407,7 @@ public:
|
||||
{
|
||||
}
|
||||
float getRoundedValue() const;
|
||||
float getDigitCount();
|
||||
int getDigitCount() const;
|
||||
defaultTypedMethods(float);
|
||||
|
||||
} ;
|
||||
|
||||
@@ -716,19 +716,19 @@ float AutomatableModel::globalAutomationValueAt( const MidiTime& time )
|
||||
|
||||
float FloatModel::getRoundedValue() const
|
||||
{
|
||||
return static_cast<float>( static_cast<int>( value() / step<float>() + 0.5 ) ) * step<float>();
|
||||
return qRound( value() / step<float>() ) * step<float>();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
float FloatModel::getDigitCount()
|
||||
int FloatModel::getDigitCount() const
|
||||
{
|
||||
float steptemp = step<float>();
|
||||
int digits = 0;
|
||||
while ( steptemp < 1 )
|
||||
{
|
||||
steptemp = steptemp / 0.1f;
|
||||
steptemp = steptemp * 10.0f;
|
||||
digits++;
|
||||
}
|
||||
return digits;
|
||||
|
||||
@@ -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<float>( static_cast<int>( ( 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<float>( static_cast<int>( ( oldValue - value ) / step + 0.5 ) ) * step;
|
||||
float roundedValue = qRound( ( oldValue - value ) / step ) * step;
|
||||
model()->setValue( roundedValue );
|
||||
m_leftOver = 0.0f;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user