24BEGIN_IGRAPHICS_NAMESPACE
33 enum class ESubControl
41 const IVStyle& style = DEFAULT_STYLE.WithDrawShadows(
false).WithLabelText(DEFAULT_LABEL_TEXT.WithVAlign(EVAlign::Middle)))
54 void RestorePreset(
IPluginBase* pluginBase,
int presetIdx)
59 str.SetFormatted(32,
"Preset %i: %s", presetIdx + 1, pluginBase->
GetPresetName(presetIdx));
60 mPresetNameButton->SetLabelStr(str.Get());
72 RestorePreset(pluginBase, pSelectedMenu->GetChosenItemIdx());
79 auto prevPresetFunc = [&](
IControl* pCaller) {
83 int nPresets = pluginBase->
NPresets();
88 presetIdx = nPresets - 1;
90 RestorePreset(pluginBase, presetIdx);
93 auto nextPresetFunc = [&](
IControl* pCaller) {
97 int nPresets = pluginBase->
NPresets();
101 if (presetIdx >= nPresets)
104 RestorePreset(pluginBase, presetIdx);
107 auto choosePresetFunc = [&](
IControl* pCaller) {
113 int nPresets = pluginBase->
NPresets();
115 for (
int i = 0; i < nPresets; i++)
118 if (i == currentPresetIdx)
119 mMenu.AddItem(str, -1, IPopupMenu::Item::kChecked);
124 pCaller->GetUI()->CreatePopupMenu(*
this, mMenu, pCaller->GetRECT());
140 ForAllChildrenFunc([&](
int childIdx,
IControl* pChild){
146 IRECT GetSubControlBounds(ESubControl control)
148 auto sections = mWidgetBounds;
150 std::array<IRECT, 3> rects = {
156 return rects[(int) control];
171 enum class ESubControl
179 IVDiskPresetManagerControl(
const IRECT& bounds,
const char* presetPath,
const char* fileExtension,
bool showFileExtensions =
true,
const char* label =
"",
const IVStyle& style = DEFAULT_STYLE.WithDrawShadows(
false).WithLabelText(DEFAULT_LABEL_TEXT.WithVAlign(EVAlign::Middle)))
202 mSelectedItemIndex = mItems.Find(pItem);
203 LoadPresetAtCurrentIndex();
210 auto prevPresetFunc = [&](
IControl* pCaller) {
213 mSelectedItemIndex--;
215 if (mSelectedItemIndex < 0)
216 mSelectedItemIndex = NItems() - 1;
218 LoadPresetAtCurrentIndex();
222 auto nextPresetFunc = [&](
IControl* pCaller) {
225 mSelectedItemIndex++;
227 if (mSelectedItemIndex >= NItems())
228 mSelectedItemIndex = 0;
230 LoadPresetAtCurrentIndex();
234 auto loadPresetFunc = [&](
IControl* pCaller) {
235 WDL_String fileName, path;
236 pCaller->GetUI()->PromptForFile(fileName, path, EFileAction::Open, mExtension.Get());
238 if (path.GetLength())
245 if (fileName.GetLength())
248 LoadPresetAtCurrentIndex();
252 auto choosePresetFunc = [&](
IControl* pCaller) {
254 pCaller->GetUI()->CreatePopupMenu(*
this, mMainMenu, pCaller->GetRECT());
269 ForAllChildrenFunc([&](
int childIdx,
IControl* pChild){
274 void LoadPresetAtCurrentIndex()
276 if (mSelectedItemIndex > -1 &&
277 mSelectedItemIndex < mItems.GetSize())
281 if (!mShowFileExtensions)
283 fileName.remove_fileext();
285 mPresetNameButton->SetLabelStr(fileName.get_filepart());
291 if (!mMainMenu.HasSubMenus())
293 mMainMenu.SetChosenItemIdx(mSelectedItemIndex);
299 IRECT GetSubControlBounds(ESubControl control)
301 auto sections = mWidgetBounds;
303 std::array<IRECT, 4> rects = {
310 return rects[(int) control];
316END_IGRAPHICS_NAMESPACE
This file contains the base IControl implementation, along with some base classes for specific types ...
IContainerBase allows a control to nest sub controls and it clips the drawing of those subcontrols In...
The lowest level base class of an IGraphics control.
IGEditorDelegate * GetDelegate()
Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes...
IControl * SetAnimationEndActionFunction(IActionFunction actionFunc)
Set an Action Function to be called at the end of an animation.
void SetTargetAndDrawRECTs(const IRECT &bounds)
Set BOTH the draw rect and the target area, within the graphics context for this control.
An abstract IControl base class that you can inherit from in order to make a control that pops up a m...
void ClearPathList()
Clear the menu.
void CheckSelectedItem()
Check the currently selected menu item.
void SetupMenu()
Call after adding one or more paths, to populate the menu.
void GetSelectedFile(WDL_String &path) const
Get the full path to the file if something has been selected in the menu.
void SetSelectedFile(const char *filePath)
Set the selected file based on a file path.
void AddPath(const char *path, const char *displayText)
Used to add a path to scan for files.
The lowest level base class of an IGraphics context.
Base class that contains plug-in info and state manipulation methods.
int GetCurrentPresetIdx() const
Get the index of the current, active preset.
bool RestorePreset(int idx)
Restore a preset by index.
const char * GetPresetName(int idx) const
Get the name a preset.
int NPresets() const
Gets the number of factory presets.
A "meta control" for a "preset manager" for "baked in" factory presets It adds several child buttons.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnAttached() override
Called after the control has been attached, and its delegate and graphics member variable set.
void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx) override
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControlPromptU...
void OnResize() override
Called when IControl is constructed or resized using SetRect().
A "meta control" for a "preset manager" for disk-based preset files It adds several child buttons.
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.
void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx) override
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControlPromptU...
void OnResize() override
Called when IControl is constructed or resized using SetRect().
A base interface to be combined with IControl for vectorial controls "IVControls",...
IRECT MakeRects(const IRECT &parent, bool hasHandle=false)
Calculate the rectangles for the various areas, depending on the style.
void AttachIControl(IControl *pControl, const char *label)
Call in the constructor of your IVControl to link the IVectorBase and IControl.
virtual void DrawLabel(IGraphics &g)
Draw the IVControl label text.
void SplashClickActionFunc(IControl *pCaller)
The splash click action function is used by IVControls to start SplashAnimationFunc.
Used to manage a rectangular area, independent of draw class/platform.
IRECT ReduceFromRight(float amount)
Reduce in width from the right edge by 'amount' and return the removed region.
IRECT ReduceFromLeft(float amount)
Reduce in width from the left edge by 'amount' and return the removed region.
A struct encapsulating a set of properties used to configure IVControls.