Skip to content

Commit

Permalink
LastChance forwarding for Middle Button
Browse files Browse the repository at this point in the history
  • Loading branch information
baconpaul committed Aug 29, 2021
1 parent 8075918 commit cedbef0
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/gui/widgets/EffectChooser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ juce::Rectangle<int> EffectChooser::getEffectRectangle(int i)

void EffectChooser::mouseDown(const juce::MouseEvent &event)
{
if (forwardedMainFrameMouseDowns(event))
{
return;
}

hasDragged = false;
currentClicked = -1;

Expand Down
5 changes: 5 additions & 0 deletions src/gui/widgets/LFOAndStepDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1223,6 +1223,11 @@ void LFOAndStepDisplay::onSkinChanged()

void LFOAndStepDisplay::mouseDown(const juce::MouseEvent &event)
{
if (forwardedMainFrameMouseDowns(event))
{
return;
}

auto sge = firstListenerOfType<SurgeGUIEditor>();

for (int i = 0; i < n_lfo_types; ++i)
Expand Down
5 changes: 5 additions & 0 deletions src/gui/widgets/MenuForDiscreteParams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ void MenuForDiscreteParams::paint(juce::Graphics &g)

void MenuForDiscreteParams::mouseDown(const juce::MouseEvent &event)
{
if (forwardedMainFrameMouseDowns(event))
{
return;
}

if (glyphMode && glyphPosition.contains(event.position))
{
mouseDownOrigin = event.position.toInt();
Expand Down
5 changes: 5 additions & 0 deletions src/gui/widgets/ModulatableSlider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,11 @@ void ModulatableSlider::mouseDrag(const juce::MouseEvent &event)

void ModulatableSlider::mouseDown(const juce::MouseEvent &event)
{
if (forwardedMainFrameMouseDowns(event))
{
return;
}

if (event.mods.isPopupMenu())
{
editTypeWas = NOEDIT;
Expand Down
5 changes: 5 additions & 0 deletions src/gui/widgets/MultiSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ float MultiSwitch::coordinateToValue(int x, int y)

void MultiSwitch::mouseDown(const juce::MouseEvent &event)
{
if (forwardedMainFrameMouseDowns(event))
{
return;
}

if (event.mods.isPopupMenu())
{
notifyControlModifierClicked(event.mods);
Expand Down
9 changes: 9 additions & 0 deletions src/gui/widgets/NumberField.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,18 +110,27 @@ void NumberField::setControlMode(Surge::Skin::Parameters::NumberfieldControlMode
}
void NumberField::mouseDown(const juce::MouseEvent &event)
{
if (forwardedMainFrameMouseDowns(event))
{
return;
}

mouseMode = NONE;

if (event.mods.isPopupMenu())
{
notifyControlModifierClicked(event.mods);
return;
}

mouseMode = DRAG;

if (!Surge::GUI::showCursor(storage))
{
juce::Desktop::getInstance().getMainMouseSource().enableUnboundedMouseMovement(true);
mouseDownOrigin = event.position;
}

lastDistanceChecked = 0;
}

Expand Down
12 changes: 12 additions & 0 deletions src/gui/widgets/OscillatorWaveformDisplay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,16 @@ void OscillatorWaveformDisplay::showWavetableMenu()
menu.showMenuAsync(juce::PopupMenu::Options());
}
}

void OscillatorWaveformDisplay::mouseDown(const juce::MouseEvent &event)
{
if (event.mods.isMiddleButtonDown() && sge)
{
sge->frame->mouseDown(event);
return;
}
}

void OscillatorWaveformDisplay::mouseUp(const juce::MouseEvent &event)
{
bool usesWT = uses_wavetabledata(oscdata->type.val.i);
Expand Down Expand Up @@ -506,6 +516,7 @@ void OscillatorWaveformDisplay::mouseUp(const juce::MouseEvent &event)
}
}
}

void OscillatorWaveformDisplay::mouseMove(const juce::MouseEvent &event)
{
if (supportsCustomEditor())
Expand Down Expand Up @@ -891,6 +902,7 @@ void OscillatorWaveformDisplay::drawEditorBox(juce::Graphics &g, const std::stri
g.setFont(Surge::GUI::getFontManager()->getLatoAtSize(9));
g.drawText(s, customEditorBox, juce::Justification::centred);
}

void OscillatorWaveformDisplay::mouseExit(const juce::MouseEvent &event)
{
isCustomEditorHovered = false;
Expand Down
2 changes: 2 additions & 0 deletions src/gui/widgets/OscillatorWaveformDisplay.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "SkinSupport.h"
#include "Parameter.h"
#include "SurgeStorage.h"
#include "WidgetBaseMixin.h"

#include "juce_gui_basics/juce_gui_basics.h"
#include "Oscillator.h"
Expand Down Expand Up @@ -67,6 +68,7 @@ struct OscillatorWaveformDisplay : public juce::Component, public Surge::GUI::Sk
pdata tp[n_scene_params];
juce::Rectangle<float> leftJog, rightJog, waveTableName;

void mouseDown(const juce::MouseEvent &event) override;
void mouseUp(const juce::MouseEvent &event) override;
void mouseMove(const juce::MouseEvent &event) override;
void mouseExit(const juce::MouseEvent &event) override;
Expand Down
6 changes: 6 additions & 0 deletions src/gui/widgets/Switch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
** open source in September 2018.
*/

#include "SurgeGUIEditor.h"
#include "Switch.h"
#include "SurgeImage.h"

Expand Down Expand Up @@ -53,6 +54,11 @@ void Switch::paint(juce::Graphics &g)

void Switch::mouseDown(const juce::MouseEvent &event)
{
if (forwardedMainFrameMouseDowns(event))
{
return;
}

if (event.mods.isPopupMenu())
{
notifyControlModifierClicked(event.mods);
Expand Down
1 change: 1 addition & 0 deletions src/gui/widgets/VerticalLabel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ VerticalLabel::VerticalLabel()
#if SURGE_JUCE_ACCESSIBLE
setAccessible(false); // it's just derocative
#endif
setInterceptsMouseClicks(false, false);
}
VerticalLabel::~VerticalLabel() = default;

Expand Down
1 change: 1 addition & 0 deletions src/gui/widgets/VuMeter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ VuMeter::VuMeter()
#if SURGE_JUCE_ACCESSIBLE
setAccessible(false);
#endif
setInterceptsMouseClicks(false, false);
}
VuMeter::~VuMeter() = default;

Expand Down
5 changes: 5 additions & 0 deletions src/gui/widgets/WaveShaperSelector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,11 @@ void WaveShaperSelector::setValue(float f)

void WaveShaperSelector::mouseDown(const juce::MouseEvent &event)
{
if (forwardedMainFrameMouseDowns(event))
{
return;
}

lastDragDistance = 0;
everDragged = false;

Expand Down
13 changes: 13 additions & 0 deletions src/gui/widgets/WidgetBaseMixin.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "juce_gui_basics/juce_gui_basics.h"

#include <unordered_set>
#include "MainFrame.h"

class SurgeGUIEditor;

Expand Down Expand Up @@ -124,6 +125,18 @@ struct WidgetBaseMixin : public Surge::GUI::SkinConsumingComponent,
}
return nullptr;
}

bool forwardedMainFrameMouseDowns(const juce::MouseEvent &e)
{
if (e.mods.isMiddleButtonDown())
{
auto sge = firstListenerOfType<SurgeGUIEditor>();
if (sge && sge->frame)
sge->frame->mouseDown(e);
return true;
}
return false;
}
};
} // namespace Widgets
} // namespace Surge
Expand Down

0 comments on commit cedbef0

Please sign in to comment.