Last active
May 17, 2021 17:35
-
-
Save olilarkin/97dd9e73a12f1a1b60ba3f4ac7c28f5e to your computer and use it in GitHub Desktop.
Switch IGraphics DrawScale using a radio button
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "IPlugEffect.h" | |
#include "IPlug_include_in_plug_src.h" | |
#include "IControls.h" | |
IPlugEffect::IPlugEffect(const InstanceInfo& info) | |
: Plugin(info, MakeConfig(kNumParams, kNumPresets)) | |
{ | |
GetParam(kGain)->InitDouble("Gain", 0., 0., 100.0, 0.01, "%"); | |
#if IPLUG_EDITOR // http://bit.ly/2S64BDd | |
mMakeGraphicsFunc = [&]() { | |
return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS, GetScaleForScreen(PLUG_WIDTH, PLUG_HEIGHT)); | |
}; | |
mLayoutFunc = [&](IGraphics* pGraphics) { | |
pGraphics->SetLayoutOnResize(true); | |
pGraphics->AttachPanelBackground(COLOR_GRAY); | |
pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN); | |
const IRECT b = pGraphics->GetBounds(); | |
float currentScaleSelection = pGraphics->GetDrawScale() - 0.5f; | |
pGraphics->AttachControl(new IVRadioButtonControl(b.GetCentredInside(100), | |
[pGraphics](IControl* pCaller) { | |
int idx = pCaller->As<IVRadioButtonControl>()->GetSelectedIdx(); | |
float newScale = 0.5f + float(idx) * 0.5f; | |
pGraphics->Resize(PLUG_WIDTH, PLUG_HEIGHT, newScale); | |
}, | |
{"Small", "Medium", "Big"} ))->SetValue(currentScaleSelection); | |
}; | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment