2
0
Fork 0

Implemented shift + click to reset panning knobs

This commit is contained in:
George Reales 2022-02-20 19:51:30 +01:00
parent 7c371aae29
commit 3417d52d83
3 changed files with 61 additions and 1 deletions

View file

@ -25,7 +25,7 @@
#include "../Source/Engine/SynthEngine.h"
#include "../Components/ScaleComponent.h"
class ObxdAudioProcessor;
class Knob : public Slider, public ScalableComponent
class Knob : public Slider, public ScalableComponent, public ActionBroadcaster
{
juce::String img_name;
public:
@ -57,6 +57,18 @@ public:
*/
repaint();
}
void mouseDown(const MouseEvent& event) override
{
if (event.mods.isShiftDown())
{
if (shouldResetOnShiftClick)
{
sendActionMessage(resetActionMessage);
}
}
Slider::mouseDown(event);
}
// Source: https://git.iem.at/audioplugins/IEMPluginSuite/-/blob/master/resources/customComponents/ReverseSlider.h
public:
class KnobAttachment : public juce::AudioProcessorValueTreeState::SliderAttachment
@ -106,9 +118,17 @@ public:
}
~Knob() override {};
void resetOnShiftClick(bool value, const String& identifier)
{
shouldResetOnShiftClick = value;
resetActionMessage = identifier;
}
private:
Image kni;
int fh, numFr;
int w2, h2;
bool shouldResetOnShiftClick{ false };
String resetActionMessage{};
AudioProcessorParameter* parameter {nullptr};
};

View file

@ -420,35 +420,51 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
if (name == "pan1Knob"){
pan1Knob = addKnob (x, y, d, ownerFilter, PAN1, "1", 0.5);
pan1Knob->resetOnShiftClick(true, Action::panReset);
pan1Knob->addActionListener(this);
mappingComps["pan1Knob"] = pan1Knob;
}
if (name == "pan2Knob"){
pan2Knob = addKnob (x, y, d, ownerFilter, PAN2, "2", 0.5);
pan2Knob->resetOnShiftClick(true, Action::panReset);
pan2Knob->addActionListener(this);
mappingComps["pan2Knob"] = pan2Knob;
}
if (name == "pan3Knob"){
pan3Knob = addKnob (x, y, d, ownerFilter, PAN3, "3", 0.5);
pan3Knob->resetOnShiftClick(true, Action::panReset);
pan3Knob->addActionListener(this);
mappingComps["pan3Knob"] = pan3Knob;
}
if (name == "pan4Knob"){
pan4Knob = addKnob (x, y, d, ownerFilter, PAN4, "4", 0.5);
pan4Knob->resetOnShiftClick(true, Action::panReset);
pan4Knob->addActionListener(this);
mappingComps["pan4Knob"] = pan4Knob;
}
if (name == "pan5Knob"){
pan5Knob = addKnob (x, y, d, ownerFilter, PAN5, "5", 0.5);
pan5Knob->resetOnShiftClick(true, Action::panReset);
pan5Knob->addActionListener(this);
mappingComps["pan5Knob"] = pan5Knob;
}
if (name == "pan6Knob"){
pan6Knob = addKnob (x, y, d, ownerFilter, PAN6, "6", 0.5);
pan6Knob->resetOnShiftClick(true, Action::panReset);
pan6Knob->addActionListener(this);
mappingComps["pan6Knob"] = pan6Knob;
}
if (name == "pan7Knob"){
pan7Knob = addKnob (x, y, d, ownerFilter, PAN7, "7", 0.5);
pan7Knob->resetOnShiftClick(true, Action::panReset);
pan7Knob->addActionListener(this);
mappingComps["pan7Knob"] = pan7Knob;
}
if (name == "pan8Knob"){
pan8Knob = addKnob (x, y, d, ownerFilter, PAN8, "8", 0.5);
pan8Knob->resetOnShiftClick(true, Action::panReset);
pan8Knob->addActionListener(this);
mappingComps["pan8Knob"] = pan8Knob;
}
@ -730,6 +746,22 @@ TooglableButton* ObxdAudioProcessorEditor::addButton (int x, int y, int w, int h
return button;
}
void ObxdAudioProcessorEditor::actionListenerCallback(const String& message)
{
if (message.equalsIgnoreCase(Action::panReset))
{
const StringArray parameters{ "pan1Knob", "pan2Knob", "pan3Knob", "pan4Knob", "pan5Knob", "pan6Knob", "pan7Knob", "pan8Knob" };
for (const auto& parameter : parameters)
{
if (auto* knob = dynamic_cast<Knob*>(mappingComps[parameter]))
{
knob->setValue(knob->getDoubleClickReturnValue());
}
}
}
}
Rectangle<int> ObxdAudioProcessorEditor::transformBounds(int x, int y, int w, int h)
{
if (getScaleFactor() == 1.0f)
@ -1449,6 +1481,8 @@ void ObxdAudioProcessorEditor::filesDropped(const StringArray& files, int x, int
//createMenu();
}
}
const String ObxdAudioProcessorEditor::Action::panReset{ "panReset" };
/*
bool ObxdAudioProcessorEditor::keyPressed(const KeyPress & press) {
if (press.getKeyCode() == '+' || press.getKeyCode() == KeyPress::numberPadAdd)

View file

@ -55,6 +55,7 @@ class ObxdAudioProcessorEditor : public AudioProcessorEditor
// , public Slider::Listener
, public Button::Listener
// , public ComboBox::Listener
, public ActionListener
, public ApplicationCommandTarget
, public Timer
, public FileDragAndDropTarget
@ -177,6 +178,7 @@ public:
{
return processor.physicalPixelScaleFactor > 1.0;
}
void actionListenerCallback(const String& message) override;
private:
Rectangle<int> transformBounds(int x, int y, int w, int h);
Knob* addKnob (int x, int y, int d, ObxdAudioProcessor& filter, int parameter, String name, float defval);
@ -304,6 +306,10 @@ private:
int menuScaleNum;
int countTimerForLed = 0;
struct Action
{
static const String panReset;
};
};
#endif // PLUGINEDITOR_H_INCLUDED