Less "jumpy" knobs

Implement a more stable knob behavior.

Remove the jumping behavior if the users directly click on a volume
knob. By storing the offset from the knob center and taking it into
account during the changes it now also feels like the users are
dragging the knob.

Changes to the amplification are now only applied when the mouse is
moved. This makes the double click behavior much more stable, i.e. if
users click on the knob when it is at 0 dB the dialog will also show
0 dB and not something like 0.3 dB because the first click is already
registered as a change of volume.

If the users click next to the knob the amplification will still be
changed immediately to that value.

## Technical details

To make the knobs more stable a variable called `m_knobCenterOffset` was
introduced. It stores the offset of the click from the knob center so
that this value can be taken into account for in the method
`setVolumeByLocalPixelValue`.
This commit is contained in:
Michael Gregorius
2024-12-27 12:20:08 +01:00
parent 1f9f96deeb
commit a86ca84d57
2 changed files with 36 additions and 1 deletions

View File

@@ -144,6 +144,11 @@ private:
QPixmap m_knob {embed::getIconPixmap("fader_knob")};
// Stores the offset to the knob center when the user drags the fader knob.
// This is needed to make it feel like the users drag the knob without it
// jumping immediately to the click position.
int m_knobCenterOffset {0};
bool m_levelsDisplayedInDBFS {true};
bool m_modelIsLinear {false};