Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(XT 1.1) Always use Exact mouse sensitivity in Touchscreen mode #5803

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/surge-xt/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1730,11 +1730,23 @@ void SurgeGUIEditor::openOrRecreateEditor()

// Mouse behavior
if (Surge::Widgets::ModulatableSlider::sliderMoveRateState ==
Surge::Widgets::ModulatableSlider::kUnInitialized)
Surge::Widgets::ModulatableSlider::MoveRateState::kUnInitialized)
{
Surge::Widgets::ModulatableSlider::sliderMoveRateState =
(Surge::Widgets::ModulatableSlider::MoveRateState)Surge::Storage::getUserDefaultValue(
&(synth->storage), Surge::Storage::SliderMoveRateState,
(int)Surge::Widgets::ModulatableSlider::kLegacy);
}

if (Surge::Widgets::ModulatableSlider::touchscreenMode ==
Surge::Widgets::ModulatableSlider::TouchscreenMode::kUnassigned)
{
bool touchMode = Surge::Storage::getUserDefaultValue(&(synth->storage),
Surge::Storage::TouchMouseMode, false);
Surge::Widgets::ModulatableSlider::touchscreenMode =
(touchMode == false) ? Surge::Widgets::ModulatableSlider::TouchscreenMode::kDisabled
: Surge::Widgets::ModulatableSlider::TouchscreenMode::kEnabled;
}

/*
** Skin Labels
Expand Down Expand Up @@ -3166,6 +3178,10 @@ juce::PopupMenu SurgeGUIEditor::makeMouseBehaviorMenu(const juce::Point<int> &wh

mouseMenu.addItem(Surge::GUI::toOSCaseForMenu("Touchscreen Mode"), true, touchMode,
[this, touchMode]() {
Surge::Widgets::ModulatableSlider::touchscreenMode =
(!touchMode == false)
? Surge::Widgets::ModulatableSlider::TouchscreenMode::kDisabled
: Surge::Widgets::ModulatableSlider::TouchscreenMode::kEnabled;
Surge::Storage::updateUserDefaultValue(
&(this->synth->storage), Surge::Storage::TouchMouseMode, !touchMode);
});
Expand Down
11 changes: 11 additions & 0 deletions src/surge-xt/gui/widgets/ModulatableSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ namespace Widgets

ModulatableSlider::MoveRateState ModulatableSlider::sliderMoveRateState =
ModulatableSlider::MoveRateState::kUnInitialized;
ModulatableSlider::TouchscreenMode ModulatableSlider::touchscreenMode =
ModulatableSlider::TouchscreenMode::kUnassigned;
ModulatableSlider::ModulatableSlider() { setRepaintsOnMouseActivity(true); }

ModulatableSlider::~ModulatableSlider() {}
Expand Down Expand Up @@ -409,9 +411,12 @@ void ModulatableSlider::mouseDrag(const juce::MouseEvent &event)
updateLocationState();

float dMouse = 1.f / range;

if (event.mods.isShiftDown())
dMouse = dMouse * 0.1;

float tsMouse = dMouse;

switch (sliderMoveRateState)
{
case kExact:
Expand All @@ -428,6 +433,12 @@ void ModulatableSlider::mouseDrag(const juce::MouseEvent &event)
break;
}

// make sure we're in Exact mouse sensitivity mode for touchscreen input
if (touchscreenMode == ModulatableSlider::TouchscreenMode::kEnabled)
{
dMouse = tsMouse;
}

if (isEditingModulation)
{
modValue = modValue + dMouse * dDistance;
Expand Down
9 changes: 9 additions & 0 deletions src/surge-xt/gui/widgets/ModulatableSlider.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,16 @@ struct ModulatableSlider : public juce::Component,
kMedium,
kExact
};

enum TouchscreenMode
{
kUnassigned = 0,
kDisabled,
kEnabled
};

static MoveRateState sliderMoveRateState;
static TouchscreenMode touchscreenMode;

/**
* The slider is 'light' backgrounded (which matters in the classic skin only)
Expand Down