Skip to content

Commit

Permalink
Mouse shift handling correction (surge-synthesizer#4747)
Browse files Browse the repository at this point in the history
The mouse distance restated values based on base + total motion
but this broke with shift which kncoked you out of whack so
keep an incremental distance and += the value or modvalue
based on that

Closes surge-synthesizer#4738
  • Loading branch information
baconpaul authored Jul 13, 2021
1 parent f6b52d1 commit 57bb23d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions src/gui/widgets/ModulatableSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,9 @@ void ModulatableSlider::mouseDrag(const juce::MouseEvent &event)
if (distance == 0 && editTypeWas == NOEDIT)
return;

float dDistance = distance - lastDistance;
lastDistance = distance;

if (editTypeWas == NOEDIT)
{
notifyBeginEdit();
Expand Down Expand Up @@ -348,11 +351,13 @@ void ModulatableSlider::mouseDrag(const juce::MouseEvent &event)

if (isEditingModulation)
{
modValue = limitpm1(modValueOnMouseDown + dMouse * distance);
modValue = modValue + dMouse * dDistance;
modValue = limitpm1(modValue);
}
else
{
value = limit01(valueOnMouseDown + dMouse * distance);
value = value + dMouse * dDistance;
value = limit01(value);
}

notifyValueChanged();
Expand All @@ -376,6 +381,7 @@ void ModulatableSlider::mouseDown(const juce::MouseEvent &event)

valueOnMouseDown = value;
modValueOnMouseDown = modValue;
lastDistance = 0.f;
editTypeWas = NOEDIT;
showInfowindow(isEditingModulation);
}
Expand Down
2 changes: 1 addition & 1 deletion src/gui/widgets/ModulatableSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct ModulatableSlider : public juce::Component,
void paint(juce::Graphics &g) override;

bool isHovered{false};
float valueOnMouseDown{0.f}, modValueOnMouseDown{0.f};
float valueOnMouseDown{0.f}, modValueOnMouseDown{0.f}, lastDistance{0.f};
void mouseEnter(const juce::MouseEvent &event) override;
void mouseExit(const juce::MouseEvent &event) override;
void mouseDrag(const juce::MouseEvent &event) override;
Expand Down

0 comments on commit 57bb23d

Please sign in to comment.