wavetable/plugin/Source/Editor.cpp

107 lines
3.2 KiB
C++
Raw Normal View History

#include "Editor.h"
Editor::Editor (WavetableAudioProcessor& proc_)
2023-10-08 14:31:14 -07:00
: proc (proc_)
{
for (auto& o : oscillators) addAndMakeVisible (o);
for (auto& l : lfos) addAndMakeVisible (l);
2023-08-26 12:33:15 -07:00
for (auto& e : envs) addAndMakeVisible (e);
2023-08-26 11:17:03 -07:00
addAndMakeVisible (sub);
addAndMakeVisible (noise);
2023-08-26 12:33:15 -07:00
addAndMakeVisible (adsr);
addAndMakeVisible (filter);
2023-08-26 12:33:15 -07:00
addAndMakeVisible (step);
2023-08-26 13:01:59 -07:00
addAndMakeVisible (mod);
2023-09-08 17:11:50 -07:00
addAndMakeVisible (mtx);
2023-08-26 13:01:59 -07:00
addAndMakeVisible (global);
2023-10-08 14:31:14 -07:00
fx.addAndMakeVisible (gate);
fx.addAndMakeVisible (chorus);
fx.addAndMakeVisible (distort);
fx.addAndMakeVisible (delay);
fx.addAndMakeVisible (reverb);
fx.onDragStart = [] (const juce::MouseEvent& e)
{
if (dynamic_cast<gin::ParamHeader*> (e.originalComponent))
return true;
return false;
};
2024-01-22 21:43:19 -08:00
fx.onOrderChanged = [this] (int, int)
2023-10-08 14:31:14 -07:00
{
proc.fxParams.fx1->setUserValue (fx.getChildComponent(0)->getProperties()["fxId"]);
proc.fxParams.fx2->setUserValue (fx.getChildComponent(1)->getProperties()["fxId"]);
proc.fxParams.fx3->setUserValue (fx.getChildComponent(2)->getProperties()["fxId"]);
proc.fxParams.fx4->setUserValue (fx.getChildComponent(3)->getProperties()["fxId"]);
proc.fxParams.fx5->setUserValue (fx.getChildComponent(4)->getProperties()["fxId"]);
handleAsyncUpdate();
};
proc.fxParams.fx1->addListener (this);
proc.fxParams.fx2->addListener (this);
proc.fxParams.fx3->addListener (this);
proc.fxParams.fx4->addListener (this);
proc.fxParams.fx5->addListener (this);
addAndMakeVisible (fx);
setupCallbacks();
2023-10-08 14:31:14 -07:00
handleAsyncUpdate();
}
Editor::~Editor()
{
proc.fxParams.fx1->removeListener (this);
proc.fxParams.fx2->removeListener (this);
proc.fxParams.fx3->removeListener (this);
proc.fxParams.fx4->removeListener (this);
proc.fxParams.fx5->removeListener (this);
}
void Editor::handleAsyncUpdate()
{
if (fx.isDragInProgress())
return;
fx.removeAllChildren();
auto getComp = [this] (int fxId) -> juce::Component*
{
if (fxId == fxGate) return &gate;
if (fxId == fxChorus) return &chorus;
if (fxId == fxDistort) return &distort;
if (fxId == fxDelay) return &delay;
if (fxId == fxReverb) return &reverb;
jassertfalse;
return nullptr;
};
fx.addAndMakeVisible (getComp (proc.fxParams.fx1->getUserValueInt()));
fx.addAndMakeVisible (getComp (proc.fxParams.fx2->getUserValueInt()));
fx.addAndMakeVisible (getComp (proc.fxParams.fx3->getUserValueInt()));
fx.addAndMakeVisible (getComp (proc.fxParams.fx4->getUserValueInt()));
fx.addAndMakeVisible (getComp (proc.fxParams.fx5->getUserValueInt()));
if (fx.getWidth() > 0)
fx.resized();
}
void Editor::setupCallbacks()
{
}
void Editor::resized()
{
#if JUCE_DEBUG
auto f = juce::File (__FILE__).getChildFile ("../../Resources/layout.json");
2025-11-19 17:15:05 -08:00
layout.setLayout ({f});
#else
2025-11-19 17:15:05 -08:00
layout.setLayout ({"layout.json"});
#endif
handleAsyncUpdate();
}