Skip to content

Instantly share code, notes, and snippets.

@olilarkin
Created October 7, 2019 19:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save olilarkin/d2e9a2f3675421064dfc7cd1990ed654 to your computer and use it in GitHub Desktop.
Save olilarkin/d2e9a2f3675421064dfc7cd1990ed654 to your computer and use it in GitHub Desktop.
#include "IPlugEffect.h"
#include "IPlug_include_in_plug_src.h"
#include "IControls.h"
IPlugEffect::IPlugEffect(const InstanceInfo& info)
: Plugin(info, MakeConfig(kNumParams, kNumPrograms))
{
GetParam(kGain)->InitDouble("Gain", 0., 0., 100.0, 0.01, "%");
#if IPLUG_EDITOR // All UI methods and member variables should be within an IPLUG_EDITOR guard, should you want distributed UI
mMakeGraphicsFunc = [&]() {
return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS, 1.);
};
mLayoutFunc = [&](IGraphics* pGraphics) {
const IRECT b = pGraphics->GetBounds();
const IRECT panel = b.GetReducedFromTop(50);
auto showPage = [&](int page) {
if(page == 0) {
for (int i=0; i<16; i++) {
pGraphics->AttachControl(new IVKnobControl(panel.GetGridCell(i, 4, 4), kGain));
}
}
else if(page == 1) {
for (int i=0; i<16; i++) {
pGraphics->AttachControl(new IVSliderControl(panel.GetGridCell(i, 4, 4), kGain));
}
}
else if(page == 2) {
for (int i=0; i<16; i++) {
pGraphics->AttachControl(new IVToggleControl(panel.GetGridCell(i, 4, 4), SplashClickActionFunc));
}
}
SendCurrentParamValuesFromDelegate();
};
if(pGraphics->NControls())
{
pGraphics->RemoveControls(2);
showPage(page);
return;
}
pGraphics->AttachCornerResizer(EUIResizerMode::Scale, false);
pGraphics->AttachPanelBackground(COLOR_WHITE);
pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN);
pGraphics->AttachControl(new IVTabSwitchControl(b.GetFromTop(50), [&, pGraphics](IControl* pCaller) {
SplashClickActionFunc(pCaller);
page = dynamic_cast<IVTabSwitchControl*>(pCaller)->GetSelectedIdx();
LayoutUI(pGraphics);
}, {"Panel 1", "Panel 2", "Panel 3"}, ""));
showPage(0);
};
#endif
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment