Extend Fader::wheelEvent
Extend `Fader::wheelEvent` for the case where the model is not a dB
model (`modelIsLinear() == true`), e.g. for the mixer faders. In that
case it works as follows. Each step increments or decrements by 1 dB if
no modifier is pressed. With "Shift" pressed the increment value is 3 dB.
With "STRG" ("CTRL") pressed the increment value is reduced to 0.1 dB. If
the value goes below the minimum positive dB value that is allowed by the
fader then the fader is set to "-inf dB", i.e. zero amplification. If the
fader is set to "-inf dB" and the users want to increase the value then
it is first set to the minimum positive value that is allowed by the
fader.
If the model is a dB model then the same behavior as before is used.
Although it should be considered to adjust this case as well. These
models are used by the faders of the Crossover Equalizer, Equalizer,
Compressor and Delay and they are not very usable with the mouse wheel.
This commit is contained in:
@@ -212,12 +212,57 @@ void Fader::mouseReleaseEvent(QMouseEvent* mouseEvent)
|
||||
|
||||
void Fader::wheelEvent (QWheelEvent* ev)
|
||||
{
|
||||
ev->accept();
|
||||
const int direction = (ev->angleDelta().y() > 0 ? 1 : -1) * (ev->inverted() ? -1 : 1);
|
||||
|
||||
model()->incValue(direction);
|
||||
if (modelIsLinear())
|
||||
{
|
||||
auto value = model()->value();
|
||||
|
||||
if (value <= 0.)
|
||||
{
|
||||
// We are at -inf dB. Do nothing if we user wishes to decrease.
|
||||
if (direction > 0)
|
||||
{
|
||||
// Otherwise set the model to the minimum value supported by the fader.
|
||||
model()->setValue(dbfsToAmp(m_faderMinDb));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// We can safely compute the dB value as the value is greater than 0
|
||||
auto valueInDB = ampToDbfs(value);
|
||||
|
||||
auto incrementValue = 1.;
|
||||
|
||||
auto const modKeys = ev->modifiers();
|
||||
if (modKeys == Qt::ShiftModifier)
|
||||
{
|
||||
// The shift is intended to go through the values in very coarse steps as in:
|
||||
// "Shift into overdrive"
|
||||
incrementValue = 3.;
|
||||
}
|
||||
else if (modKeys == Qt::ControlModifier)
|
||||
{
|
||||
// The control key gives more control, i.e. it enables more fine-grained adjustments
|
||||
incrementValue = 0.1;
|
||||
}
|
||||
|
||||
auto increment = incrementValue * direction;
|
||||
|
||||
auto adjustedValue = valueInDB + increment;
|
||||
|
||||
model()->setValue(adjustedValue < m_faderMinDb ? 0. : dbfsToAmp(adjustedValue));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
model()->incValue(direction);
|
||||
}
|
||||
|
||||
updateTextFloat();
|
||||
s_textFloat->setVisibilityTimeOut(1000);
|
||||
|
||||
ev->accept();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user