Skip to content

Commit

Permalink
Fix a bunch of modulator macro and alternate things
Browse files Browse the repository at this point in the history
1. Remove the (Macro) name in the display if renamed
2. Fix the mouse drag to, you know, set the value properly
3. Mouse hiding way better
4. etc
  • Loading branch information
baconpaul committed Sep 2, 2021
1 parent 70d0f61 commit 7294fc5
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 22 deletions.
25 changes: 16 additions & 9 deletions src/common/ModulationSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -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] = {
Expand Down Expand Up @@ -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] = {
Expand Down Expand Up @@ -351,11 +351,18 @@ template <int NDX = 1> 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)
Expand All @@ -376,7 +383,7 @@ template <int NDX = 1> 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);
Expand Down
26 changes: 21 additions & 5 deletions src/gui/SurgeGUIEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
35 changes: 27 additions & 8 deletions src/gui/widgets/ModulationSourceButton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "basic_dsp.h"
#include "SurgeGUIEditor.h"
#include "SurgeImage.h"
#include "SurgeGUIUtils.h"

namespace Surge
{
Expand Down Expand Up @@ -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()))
{
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -451,9 +451,12 @@ void ModulationSourceButton::mouseUp(const juce::MouseEvent &event)
p = juce::Point<float>(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();
}
Expand All @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/ModulationSourceButton.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> mouseDownLocation;

MouseState getMouseMode() const { return mouseMode; }

Expand Down

0 comments on commit 7294fc5

Please sign in to comment.