diff --git a/include/AutomatableModel.h b/include/AutomatableModel.h index 15285e17ab3..44af3b15b7a 100644 --- a/include/AutomatableModel.h +++ b/include/AutomatableModel.h @@ -220,6 +220,11 @@ class LMMS_EXPORT AutomatableModel : public Model, public JournallingObject setValue( m_value + steps * m_step ); } + void addValue(float amount) + { + setValue(m_value + amount); + } + float range() const { return m_range; diff --git a/plugins/TripleOscillator/TripleOscillator.cpp b/plugins/TripleOscillator/TripleOscillator.cpp index f04cee81835..8b356677a5b 100644 --- a/plugins/TripleOscillator/TripleOscillator.cpp +++ b/plugins/TripleOscillator/TripleOscillator.cpp @@ -72,7 +72,7 @@ Plugin::Descriptor PLUGIN_EXPORT tripleoscillator_plugin_descriptor = OscillatorObject::OscillatorObject( Model * _parent, int _idx ) : Model( _parent ), m_volumeModel( DefaultVolume / NUM_OF_OSCILLATORS, MinVolume, - MaxVolume, 1.0f, this, tr( "Osc %1 volume" ).arg( _idx+1 ) ), + MaxVolume, 0.0f, this, tr( "Osc %1 volume" ).arg( _idx+1 ) ), m_panModel( DefaultPanning, PanningLeft, PanningRight, 1.0f, this, tr( "Osc %1 panning" ).arg( _idx+1 ) ), m_coarseModel( -_idx*KeysPerOctave, diff --git a/src/core/AutomatableModel.cpp b/src/core/AutomatableModel.cpp index e006be651a4..0812434a0e8 100644 --- a/src/core/AutomatableModel.cpp +++ b/src/core/AutomatableModel.cpp @@ -780,6 +780,7 @@ void AutomatableModel::setUseControllerValue(bool b) float FloatModel::getRoundedValue() const { + if (step() == 0.0f) { return value(); } return std::round(value() / step()) * step(); } @@ -789,6 +790,8 @@ float FloatModel::getRoundedValue() const int FloatModel::getDigitCount() const { auto steptemp = step(); + if (steptemp == 0.0f) { return 10; } + int digits = 0; while ( steptemp < 1 ) { diff --git a/src/gui/widgets/FloatModelEditorBase.cpp b/src/gui/widgets/FloatModelEditorBase.cpp index ebd0d3d9dc7..3dfa7c94c7a 100644 --- a/src/gui/widgets/FloatModelEditorBase.cpp +++ b/src/gui/widgets/FloatModelEditorBase.cpp @@ -311,7 +311,7 @@ void FloatModelEditorBase::wheelEvent(QWheelEvent * we) else if (modKeys == Qt::AltModifier) { // The alt key enables even finer adjustments - numberOfStepsForFullSweep = 2000; + numberOfStepsForFullSweep = 10000; // It seems that on some systems pressing Alt with mess with the directions, // i.e. scrolling the mouse wheel is interpreted as pressing the mouse wheel @@ -331,10 +331,17 @@ void FloatModelEditorBase::wheelEvent(QWheelEvent * we) direction = -direction; } - // Compute the number of steps but make sure that we always do at least one step - const float stepMult = std::max(range / numberOfStepsForFullSweep / step, 1.f); - const int inc = direction * stepMult; - model()->incValue(inc); + if (step != 0.0f) + { + // Compute the number of steps but make sure that we always do at least one step + const float stepMult = std::max(range / numberOfStepsForFullSweep / step, 1.f); + const int inc = direction * stepMult; + model()->incValue(inc); + } + else + { + model()->addValue(direction * range / numberOfStepsForFullSweep); + } s_textFloat->setText(displayValue()); s_textFloat->moveGlobal(this, QPoint(width() + 2, 0)); @@ -359,7 +366,9 @@ void FloatModelEditorBase::setPosition(const QPoint & p) float newValue = value * ratio; if (qAbs(newValue) >= step) { - float roundedValue = qRound((oldValue - value) / step) * step; + float roundedValue = step != 0.0f + ? qRound((oldValue - value) / step) * step + : oldValue - value; model()->setValue(roundedValue); m_leftOver = 0.0f; } @@ -373,7 +382,9 @@ void FloatModelEditorBase::setPosition(const QPoint & p) { if (qAbs(value) >= step) { - float roundedValue = qRound((oldValue - value) / step) * step; + float roundedValue = step != 0.0f + ? qRound((oldValue - value) / step) * step + : oldValue - value; model()->setValue(roundedValue); m_leftOver = 0.0f; }