37 for (
const char* str : {
"Sine",
"Triangle",
"Sawtooth",
"Square",
"Noise",
"Sample"})
38 mSimpleMenu.AddItem(str);
40 mSimpleMenu.SetNItemsPerColumn(2);
42 mSimpleMenu.CheckItemAlone(1);
47 pBassMenu->AddSeparator();
48 pBassMenu->AddItem(
"More", pMoreBassMenu);
50 IPopupMenu* pOptionsMenu =
new IPopupMenu(
"Options", 0,
true, {
"Oversample",
"Limiter",
"Mono"});
51 pOptionsMenu->CheckItem(1,
true);
53 pEmptyMenu->AddItem(
"No presets", -1, IPopupMenu::Item::kDisabled);
55 mSubMenusMenu.AddItem(
"Presets", -1, IPopupMenu::Item::kTitle);
56 mSubMenusMenu.AddItem(
"Init Patch");
57 mSubMenusMenu.AddItem(
"Bass", pBassMenu);
58 mSubMenusMenu.AddItem(
"Pads", pPadsMenu);
59 mSubMenusMenu.AddItem(
"User", pEmptyMenu);
60 mSubMenusMenu.AddSeparator();
61 mSubMenusMenu.AddItem(
"Options", pOptionsMenu);
62 mSubMenusMenu.AddSeparator();
63 mSubMenusMenu.AddItem(
"Paste", -1, IPopupMenu::Item::kDisabled);
64 mSubMenusMenu.AddItem(
"Save Preset As...");
67 for (
int i = 0; i < 200; i++)
70 str.SetFormatted(32,
"Preset %c%i",
'A' + (i / 25), (i % 25) + 1);
71 mLongMenu.AddItem(str.Get());
74 mLongMenu.SetPrefix(3);
75 mLongMenu.CheckItemAlone(120);
78 mWideMenu.AddItem(
"A menu item with a rather long piece of text in it");
79 mWideMenu.AddItem(
"Short");
80 mWideMenu.AddItem(
"Sub-menu that has to open on the left",
new IPopupMenu(
"", {
"One",
"Two",
"Three with some more text"}));
82 for (
const char* str : {
"Cut",
"Copy",
"Paste"})
83 mContextMenu.AddItem(str);
85 mContextMenu.AddSeparator();
86 mContextMenu.AddItem(
"Select All");
98 const IVStyle style = DEFAULT_STYLE.WithLabelText(
IText(14.f, EVAlign::Middle));
99 const IVStyle toggleStyle = DEFAULT_STYLE.WithLabelText(
IText(12.f)).WithValueText(
IText(12.f));
101 auto addMenuButton = [&](
const char* str,
IPopupMenu& menu) {
105 }, str, style,
true,
false));
108 auto addToggle = [&](
const char* str,
bool& option) {
112 }, str, toggleStyle,
"OFF",
"ON", option));
116 addMenuButton(
"Simple", mSimpleMenu);
117 addMenuButton(
"Sub-menus", mSubMenusMenu);
118 addMenuButton(
"Long, numbered", mLongMenu);
119 addMenuButton(
"Wide", mWideMenu);
120 addToggle(
"Callout", mCallout);
121 addToggle(
"Beside", mBeside);
122 addToggle(
"Dark", mDark);
123 addToggle(
"Large font", mLargeFont);
124 addToggle(
"Columns", mColumns);
125 addToggle(
"Platform", mPlatform);
133 if (NChildren() < kNumChildren)
137 const float w = 130.f;
138 const float h = 30.f;
145 const int nToggles = kNumChildren - 4;
148 for (
int i = 0; i < nToggles; i++)
159 g.
DrawText(
IText(12.f, COLOR_DARK_GRAY),
"Right-click the background for a context menu. Tab reaches the buttons, to try the keyboard.", mHintRect);
174 if (pMenu->GetCanMultiCheck())
175 pItem->SetChecked(!pItem->GetChecked());
176 else if (pMenu == &mSimpleMenu || pMenu == &mLongMenu)
177 pMenu->CheckItemAlone(pMenu->GetChosenItemIdx());
179 mResult.SetFormatted(256,
"Chose \"%s\" (item %i of \"%s\")", pItem->GetText(), pMenu->GetChosenItemIdx(), pMenu->GetRootTitle());
182 mResult.Set(
"Dismissed");
217 enum { kNumChildren = 10 };
224 WDL_String mResult {
"Nothing chosen yet"};
227 bool mCallout =
false;
228 bool mBeside =
false;
230 bool mLargeFont =
false;
231 bool mColumns =
false;
232 bool mPlatform =
false;
This file contains the base IControl implementation, along with some base classes for specific types ...
A collection of IControls for common UI widgets, such as knobs, sliders, switches.
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.
const IRECT & GetRECT() const
Get the rectangular draw area for this control, within the graphics context.
IControl * SetTooltip(const char *str)
Set a tooltip for the control.
double GetValue(int valIdx=0) const
Get the control's value.
void SetTargetAndDrawRECTs(const IRECT &bounds)
Set BOTH the draw rect and the target area, within the graphics context for this control.
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
The lowest level base class of an IGraphics context.
void AttachPopupMenuControl(const IText &text=DEFAULT_TEXT, const IRECT &bounds=IRECT())
Attach a control for pop-up menus, to override platform style menus.
void DrawText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend=0)
Draw some text to the graphics context in a specific rectangle.
void CreatePopupMenu(IControl &control, IPopupMenu &menu, const IRECT &bounds, int valIdx=0)
Shows a pop up/contextual menu in relation to a rectangular region of the graphics context.
virtual void DrawDottedRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f, float dashLen=2.f)
Draw a dotted rectangle to the graphics context.
void RemovePopupMenuControl()
Remove the IGraphics popup menu, use platform popup menu if available.
IPopupMenuControl * GetPopupMenuControl()
void SplashClickActionFunc(IControl *pCaller)
The splash click action function is used by IVControls to start SplashAnimationFunc.
Used to manage color data, independent of draw class/platform.
Used to manage mouse modifiers i.e.
Used to manage a rectangular area, independent of draw class/platform.
IRECT GetFromTRHC(float w, float h) const
Get a subrect of this IRECT expanding from the top-right corner.
IRECT GetFromTLHC(float w, float h) const
Get a subrect of this IRECT expanding from the top-left corner.
IRECT GetCentredInside(const IRECT &sr) const
Get a rectangle the size of sr but with the same center point as this rectangle.
IRECT GetFromBLHC(float w, float h) const
Get a subrect of this IRECT expanding from the bottom-left corner.
IRECT GetGridCell(int row, int col, int nRows, int nColumns) const
Get a subrect (by row, column) of this IRECT which is a cell in a grid of size (nRows * nColumns)
IRECT GetVShifted(float y) const
Get a copy of this rectangle translated on the Y axis.
IRECT GetFromBRHC(float w, float h) const
Get a subrect of this IRECT expanding from the bottom-right corner.
IRECT GetPadded(float padding) const
Get a copy of this IRECT with each value padded by padding N.B.
IText is used to manage font and text/text entry style for a piece of text on the UI,...
A struct encapsulating a set of properties used to configure IVControls.