Created
April 5, 2021 19:30
-
-
Save olilarkin/7168fa26ad99f7644164fe0ce6cde7a4 to your computer and use it in GitHub Desktop.
Storing and restoring text in an editable text control
This file contains 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, "%"); | |
mMakeGraphicsFunc = [&]() { | |
return MakeGraphics(*this, PLUG_WIDTH, PLUG_HEIGHT, PLUG_FPS, GetScaleForScreen(PLUG_WIDTH, PLUG_HEIGHT)); | |
}; | |
mLayoutFunc = [&](IGraphics* pGraphics) { | |
pGraphics->AttachCornerResizer(EUIResizerMode::Scale, false); | |
pGraphics->AttachPanelBackground(COLOR_GRAY); | |
pGraphics->LoadFont("Roboto-Regular", ROBOTO_FN); | |
pGraphics->EnableTooltips(true); | |
const IRECT b = pGraphics->GetBounds(); | |
pGraphics->AttachControl(new IEditableTextControl(b.GetCentredInside(300, 20), mStringToStore.Get()))->SetActionFunction([&](IControl* pCaller) { | |
mStringToStore.Set(pCaller->As<IEditableTextControl>()->GetStr()); | |
}); | |
}; | |
} | |
void IPlugEffect::ProcessBlock(sample** inputs, sample** outputs, int nFrames) | |
{ | |
const double gain = GetParam(kGain)->Value() / 100.; | |
const int nChans = NOutChansConnected(); | |
for (int s = 0; s < nFrames; s++) { | |
for (int c = 0; c < nChans; c++) { | |
outputs[c][s] = inputs[c][s] * gain; | |
} | |
} | |
} |
This file contains 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
#pragma once | |
#include "IPlug_include_in_plug_hdr.h" | |
const int kNumPresets = 1; | |
enum EParams | |
{ | |
kGain = 0, | |
kNumParams | |
}; | |
using namespace iplug; | |
using namespace igraphics; | |
class IPlugEffect final : public Plugin | |
{ | |
public: | |
IPlugEffect(const InstanceInfo& info); | |
void ProcessBlock(sample** inputs, sample** outputs, int nFrames) override; | |
WDL_String mStringToStore{ "initial text" }; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment