diff --git a/src/common/ModulationSource.h b/src/common/ModulationSource.h index be3742cfece..0a353870356 100644 --- a/src/common/ModulationSource.h +++ b/src/common/ModulationSource.h @@ -160,9 +160,9 @@ const char modsource_names_button[n_modsources][32] = { "Breath", "Expression", "Sustain", - "Lowest", // "key/voice is now an index - "Highest", - "Latest", + "Lowest Key", // "key/voice is now an index + "Highest Key", + "Latest Key", }; const char modsource_names[n_modsources][32] = { @@ -204,9 +204,9 @@ const char modsource_names[n_modsources][32] = { "Breath", "Expression", "Sustain Pedal", - "Lowest", // "key/voice is now an index" - "Highest", - "Latest", + "Lowest Key", // "key/voice is now an index" + "Highest Key", + "Latest Key", }; const char modsource_names_tag[n_modsources][32] = { @@ -351,11 +351,18 @@ template class ControllerModulationSourceVector : public Modulatio } virtual ~ControllerModulationSourceVector() {} + + void set_target(float f) + { + assert(NDX == 1); + set_target(0, f); + } + void set_target(int idx, float f) { target[idx] = f; - startingpoint[idx] = output; - changed[NDX] = true; + startingpoint[idx] = value[idx]; + changed[idx] = true; } void init(float f) @@ -376,7 +383,7 @@ template class ControllerModulationSourceVector : public Modulatio return NDX; // bipolar can't support lognormal obvs } - void set_target(float f, bool updatechanged = true) + void set_target01(float f, bool updatechanged = true) { assert(NDX == 1); set_target01(0, f, updatechanged); diff --git a/src/gui/SurgeGUIEditor.cpp b/src/gui/SurgeGUIEditor.cpp index 64d2a3156a1..b007fd58388 100644 --- a/src/gui/SurgeGUIEditor.cpp +++ b/src/gui/SurgeGUIEditor.cpp @@ -3520,15 +3520,31 @@ std::string SurgeGUIEditor::modulatorName(int i, bool button, int forScene) if (i >= ms_ctrl1 && i <= ms_ctrl8) { - std::string ccl = - std::string(synth->storage.getPatch().CustomControllerLabel[i - ms_ctrl1]); - if (ccl == "-") + if (button) { - return std::string(modsource_names[i]); + std::string ccl = + std::string(synth->storage.getPatch().CustomControllerLabel[i - ms_ctrl1]); + if (ccl == "-") + { + return std::string(modsource_names[i]); + } + else + { + return ccl; + } } else { - return ccl + " (" + modsource_names[i] + ")"; + std::string ccl = + std::string(synth->storage.getPatch().CustomControllerLabel[i - ms_ctrl1]); + if (ccl == "-") + { + return std::string(modsource_names[i]); + } + else + { + return ccl + " (" + modsource_names[i] + ")"; + } } } if (button) diff --git a/src/gui/widgets/ModulationSourceButton.cpp b/src/gui/widgets/ModulationSourceButton.cpp index 9c1f94ef229..0968d1ca557 100644 --- a/src/gui/widgets/ModulationSourceButton.cpp +++ b/src/gui/widgets/ModulationSourceButton.cpp @@ -20,6 +20,7 @@ #include "basic_dsp.h" #include "SurgeGUIEditor.h" #include "SurgeImage.h" +#include "SurgeGUIUtils.h" namespace Surge { @@ -312,6 +313,7 @@ void ModulationSourceButton::mouseDown(const juce::MouseEvent &event) { mouseMode = CLICK; everDragged = false; + mouseDownLocation = event.position; if (needsHamburger() && hamburgerHome.contains(event.position.toInt())) { @@ -343,11 +345,7 @@ void ModulationSourceButton::mouseDown(const juce::MouseEvent &event) if (bottomRect.contains(event.position.toInt())) { - juce::Desktop::getInstance().getMainMouseSource().enableUnboundedMouseMovement(true); - notifyBeginEdit(); - mouseMode = DRAG_VALUE; - valAtMouseDown = value; - + mouseMode = PREDRAG_VALUE; return; } } @@ -392,10 +390,12 @@ void ModulationSourceButton::mouseDoubleClick(const juce::MouseEvent &event) { value = isBipolar ? 0.5f : 0.f; + mouseMode = DRAG_VALUE; notifyBeginEdit(); notifyValueChanged(); notifyEndEdit(); repaint(); + mouseMode = NONE; return; } @@ -451,9 +451,12 @@ void ModulationSourceButton::mouseUp(const juce::MouseEvent &event) p = juce::Point(value * getWidth(), 20); } - juce::Desktop::getInstance().getMainMouseSource().enableUnboundedMouseMovement(false); - p = localPointToGlobal(p); - juce::Desktop::getInstance().getMainMouseSource().setScreenPosition(p); + if (!Surge::GUI::showCursor(storage)) + { + juce::Desktop::getInstance().getMainMouseSource().enableUnboundedMouseMovement(false); + p = localPointToGlobal(p); + juce::Desktop::getInstance().getMainMouseSource().setScreenPosition(p); + } notifyEndEdit(); } @@ -470,6 +473,22 @@ void ModulationSourceButton::mouseDrag(const juce::MouseEvent &event) return; } + auto distance = event.position.getX() - mouseDownLocation.getX(); + + if (mouseMode == PREDRAG_VALUE && distance == 0) + return; + + if (mouseMode == PREDRAG_VALUE) + { + if (!Surge::GUI::showCursor(storage)) + { + juce::Desktop::getInstance().getMainMouseSource().enableUnboundedMouseMovement(true); + } + notifyBeginEdit(); + mouseMode = DRAG_VALUE; + valAtMouseDown = value; + } + if (mouseMode == DRAG_VALUE) { float mul = 1.f; diff --git a/src/gui/widgets/ModulationSourceButton.h b/src/gui/widgets/ModulationSourceButton.h index 714e1f95095..039b10c3b28 100644 --- a/src/gui/widgets/ModulationSourceButton.h +++ b/src/gui/widgets/ModulationSourceButton.h @@ -148,10 +148,12 @@ struct ModulationSourceButton : public juce::Component, NONE, CLICK, CLICK_ARROW, + PREDRAG_VALUE, DRAG_VALUE, DRAG_COMPONENT_HAPPEN, HAMBURGER } mouseMode{NONE}; + juce::Point mouseDownLocation; MouseState getMouseMode() const { return mouseMode; }