23 BEGIN_IGRAPHICS_NAMESPACE
40 void RestorePreset(
IPluginBase* pluginBase,
int presetIdx)
45 str.SetFormatted(32,
"Preset %i: %s", presetIdx + 1, pluginBase->
GetPresetName(presetIdx));
46 mPresetNameButton->SetLabelStr(str.Get());
58 RestorePreset(pluginBase, pSelectedMenu->GetChosenItemIdx());
67 auto prevPresetFunc = [&](
IControl* pCaller) {
71 int nPresets = pluginBase->
NPresets();
76 presetIdx = nPresets - 1;
78 RestorePreset(pluginBase, presetIdx);
81 auto nextPresetFunc = [&](
IControl* pCaller) {
85 int nPresets = pluginBase->
NPresets();
89 if (presetIdx >= nPresets)
92 RestorePreset(pluginBase, presetIdx);
95 auto choosePresetFunc = [&](
IControl* pCaller) {
101 int nPresets = pluginBase->
NPresets();
103 for (
int i = 0; i < nPresets; i++) {
105 if (i == currentPresetIdx)
106 mMenu.AddItem(str, -1, IPopupMenu::Item::kChecked);
111 pCaller->GetUI()->CreatePopupMenu(*
this, mMenu, pCaller->GetRECT());
137 AddPath(presetPath,
"");
151 mSelectedIndex = mItems.Find(pItem);
152 LoadPresetAtCurrentIndex();
161 auto prevPresetFunc = [&](
IControl* pCaller) {
164 if (mSelectedIndex < 0)
165 mSelectedIndex = NItems() - 1;
167 LoadPresetAtCurrentIndex();
170 auto nextPresetFunc = [&](
IControl* pCaller) {
173 if (mSelectedIndex >= NItems())
176 LoadPresetAtCurrentIndex();
179 auto loadPresetFunc = [&](
IControl* pCaller) {
182 pCaller->GetUI()->PromptForFile(fileName, path, EFileAction::Open, mExtension.Get());
184 if (fileName.GetLength())
185 mPresetNameButton->SetLabelStr(fileName.Get());
188 auto choosePresetFunc = [&](
IControl* pCaller) { pCaller->GetUI()->CreatePopupMenu(*
this, mMainMenu, pCaller->GetRECT()); };
196 void LoadPresetAtCurrentIndex()
198 if (mSelectedIndex > -1 && mSelectedIndex < mItems.GetSize())
206 mPresetNameButton->SetLabelStr(pItem->GetText());
216 END_IGRAPHICS_NAMESPACE
void Draw(IGraphics &g) override
Draw the control to the graphics context.
const char * GetPresetName(int idx) const
Get the name a preset.
The lowest level base class of an IGraphics control.
Used to manage a rectangular area, independent of draw class/platform.
IGEditorDelegate * GetDelegate()
Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes...
void OnAttached() override
Called after the control has been attached, and its delegate and graphics member variable set...
int NPresets() const
Gets the number of factory presets.
IControl * SetAnimationEndActionFunction(IActionFunction actionFunc)
Set an Action Function to be called at the end of an animation.
IRECT ReduceFromRight(float amount)
Reduce in width from the right edge by 'amount' and return the removed region.
This file contains the base IControl implementation, along with some base classes for specific types ...
A "meta control" for a "preset manager" for "baked in" factory presets It adds several child buttons...
void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx) override
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControl::Promp...
A "meta control" for a "preset manager" for disk-based preset files It adds several child buttons...
Base class that contains plug-in info and state manipulation methods.
IControl(const IRECT &bounds, int paramIdx=kNoParameter, IActionFunction actionFunc=nullptr)
Constructor.
void OnAttached() override
Called after the control has been attached, and its delegate and graphics member variable set...
void Draw(IGraphics &g) override
Draw the control to the graphics context.
The lowest level base class of an IGraphics context.
int GetCurrentPresetIdx() const
Get the index of the current, active preset.
IRECT ReduceFromLeft(float amount)
Reduce in width from the left edge by 'amount' and return the removed region.
void SplashClickActionFunc(IControl *pCaller)
The splash click action function is used by IVControls to start SplashAnimationFunc.
bool RestorePreset(int idx)
Restore a preset by index.
void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx) override
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControl::Promp...
An abstract IControl base class that you can inherit from in order to make a control that pops up a m...
IControl * AttachControl(IControl *pControl, int ctrlTag=kNoTag, const char *group="")
Attach an IControl to the graphics context and add it to the top of the control stack.
IRECT GetPadded(float padding) const
Get a copy of this IRECT with each value padded by padding N.B.
Base class that contains plug-in info and state manipulation methods.
A struct encapsulating a set of properties used to configure IVControls.