iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IControls.h
Go to the documentation of this file.
1/*
2 ==============================================================================
3
4 This file is part of the iPlug 2 library. Copyright (C) the iPlug 2 developers.
5
6 See LICENSE.txt for more info.
7
8 ==============================================================================
9*/
10
11#pragma once
12
19#include "IControl.h"
20
21#include "IColorPickerControl.h"
22#include "ILEDControl.h"
23#include "IPopupMenuControl.h"
24#include "IRTTextControl.h"
25#include "IVKeyboardControl.h"
26#include "IVMeterControl.h"
27#include "IVScopeControl.h"
29#include "IVDisplayControl.h"
30
31BEGIN_IPLUG_NAMESPACE
32BEGIN_IGRAPHICS_NAMESPACE
33
39#pragma mark - Vector Controls
40
43 , public IVectorBase
44{
45public:
46 IVLabelControl(const IRECT& bounds, const char* label, const IVStyle& style = DEFAULT_STYLE.WithDrawFrame(false).WithColor(kSH, COLOR_BLACK).WithShadowOffset(1).WithValueText(DEFAULT_VALUE_TEXT.WithSize(20.f).WithFGColor(COLOR_WHITE)));
47 void Draw(IGraphics& g) override;
48};
49
52 , public IVectorBase
53{
54public:
63 IVButtonControl(const IRECT& bounds, IActionFunction aF = SplashClickActionFunc, const char* label = "", const IVStyle& style = DEFAULT_STYLE, bool labelInButton = true, bool valueInButton = true, EVShape shape = EVShape::Rectangle);
64
65 void Draw(IGraphics& g) override;
66 virtual void DrawWidget(IGraphics& g) override;
67 bool IsHit(float x, float y) const override;
68 void OnResize() override;
69};
70
73 , public IVectorBase
74{
75public:
76 IVSwitchControl(const IRECT& bounds, int paramIdx = kNoParameter, const char* label = "", const IVStyle& style = DEFAULT_STYLE, bool valueInButton = true);
77
78 IVSwitchControl(const IRECT& bounds, IActionFunction aF = SplashClickActionFunc, const char* label = "", const IVStyle& style = DEFAULT_STYLE, int numStates = 2, bool valueInButton = true);
79
80 void Draw(IGraphics& g) override;
81 virtual void DrawWidget(IGraphics& g) override;
82 void OnMouseOut() override { ISwitchControlBase::OnMouseOut(); SetDirty(false); }
83 bool IsHit(float x, float y) const override;
84 void SetDirty(bool push, int valIdx = kNoValIdx) override;
85 void OnResize() override;
86 void OnInit() override;
87};
88
91{
92public:
93 IVToggleControl(const IRECT& bounds, int paramIdx = kNoParameter, const char* label = "", const IVStyle& style = DEFAULT_STYLE, const char* offText = "OFF", const char* onText = "ON");
94
95 IVToggleControl(const IRECT& bounds, IActionFunction aF = SplashClickActionFunc, const char* label = "", const IVStyle& style = DEFAULT_STYLE, const char* offText = "OFF", const char* onText = "ON", bool initialState = false);
96
97 void DrawValue(IGraphics& g, bool mouseOver) override;
98 void DrawWidget(IGraphics& g) override;
99protected:
100 WDL_String mOffText;
101 WDL_String mOnText;
102};
103
106{
107public:
108 IVSlideSwitchControl(const IRECT& bounds, int paramIdx = kNoParameter, const char* label = "", const IVStyle& style = DEFAULT_STYLE, bool valueInButton = false, EDirection direction = EDirection::Horizontal);
109
110 IVSlideSwitchControl(const IRECT& bounds, IActionFunction aF = EmptyClickActionFunc, const char* label = "", const IVStyle& style = DEFAULT_STYLE, bool valueInButton = false, EDirection direction = EDirection::Horizontal, int numStates = 2, int initialState = 0);
111
112 void Draw(IGraphics& g) override;
113 virtual void DrawWidget(IGraphics& g) override;
114 virtual void DrawHandle(IGraphics& g, const IRECT& filledArea);
115 virtual void DrawTrack(IGraphics& g, const IRECT& filledArea);
116
117 void OnResize() override;
118 void OnEndAnimation() override;
119 void SetDirty(bool push, int valIdx = kNoValIdx) override;
120protected:
121 void UpdateRects();
122
123 IRECT mStartRect, mEndRect;
124 IRECT mHandleBounds;
125 EDirection mDirection;
126};
127
130 , public IVectorBase
131{
132public:
133 enum class ETabSegment { Start, Mid, End };
134
143 IVTabSwitchControl(const IRECT& bounds, int paramIdx = kNoParameter, const std::vector<const char*>& options = {}, const char* label = "", const IVStyle & style = DEFAULT_STYLE, EVShape shape = EVShape::Rectangle, EDirection direction = EDirection::Horizontal);
144
153 IVTabSwitchControl(const IRECT& bounds, IActionFunction aF, const std::vector<const char*>& options, const char* label = "", const IVStyle& style = DEFAULT_STYLE, EVShape shape = EVShape::Rectangle, EDirection direction = EDirection::Horizontal);
154
155 virtual ~IVTabSwitchControl() { mTabLabels.Empty(true); }
156 void Draw(IGraphics& g) override;
157 void OnInit() override;
158
159 virtual void DrawWidget(IGraphics& g) override;
160 virtual void DrawButton(IGraphics& g, const IRECT& bounds, bool pressed, bool mouseOver, ETabSegment segment, bool disabled);
161 virtual void DrawButtonText(IGraphics& g, const IRECT& bounds, bool pressed, bool mouseOver, ETabSegment segment, bool disabled, const char* textStr);
162
163 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
164 void OnMouseOver(float x, float y, const IMouseMod& mod) override;
165 void OnMouseOut() override { mMouseOverButton = -1; ISwitchControlBase::OnMouseOut(); SetDirty(false); }
166 void OnResize() override;
167 virtual bool IsHit(float x, float y) const override;
168
170 const char* GetSelectedLabelStr() const;
171protected:
172
174 virtual int GetButtonForPoint(float x, float y) const;
175
176 int mMouseOverButton = -1;
177 WDL_TypedBuf<IRECT> mButtons;
178 WDL_PtrList<WDL_String> mTabLabels;
179 EDirection mDirection;
180};
181
184{
185public:
194 IVRadioButtonControl(const IRECT& bounds, int paramIdx = kNoParameter, const std::initializer_list<const char*>& options = {}, const char* label = "", const IVStyle& style = DEFAULT_STYLE, EVShape shape = EVShape::Ellipse, EDirection direction = EDirection::Vertical, float buttonSize = 10.f);
195
205 IVRadioButtonControl(const IRECT& bounds, IActionFunction aF, const std::initializer_list<const char*>& options, const char* label = "", const IVStyle& style = DEFAULT_STYLE, EVShape shape = EVShape::Ellipse, EDirection direction = EDirection::Vertical, float buttonSize = 10.f);
206
207 virtual void DrawWidget(IGraphics& g) override;
208protected:
210 int GetButtonForPoint(float x, float y) const override;
211
212 float mButtonSize;
213 float mButtonAreaWidth;
214 bool mOnlyButtonsRespondToMouse = false;
215};
216
219 , public IVectorBase
220{
221public:
228 IVMenuButtonControl(const IRECT& bounds, int paramIdx, const char* label = "", const IVStyle& style = DEFAULT_STYLE, EVShape shape = EVShape::Rectangle);
229
230 void OnPopupMenuSelection(IPopupMenu* pSelectedMenu, int valIdx) override;
231 void SetValueFromUserInput(double value, int valIdx) override;
232
233 void SetValueFromDelegate(double value, int valIdx = 0) override;
234 void SetStyle(const IVStyle& style) override;
235
236private:
237 IVButtonControl* mButtonControl = nullptr;
238};
239
242 , public IVectorBase
243{
244public:
245 IVKnobControl(const IRECT& bounds, int paramIdx,
246 const char* label = "",
247 const IVStyle& style = DEFAULT_STYLE,
248 bool valueIsEditable = false, bool valueInWidget = false,
249 float a1 = -135.f, float a2 = 135.f, float aAnchor = -135.f,
250 EDirection direction = EDirection::Vertical, double gearing = DEFAULT_GEARING, float trackSize = 2.f);
251
252 IVKnobControl(const IRECT& bounds, IActionFunction aF,
253 const char* label = "",
254 const IVStyle& style = DEFAULT_STYLE,
255 bool valueIsEditable = false, bool valueInWidget = false,
256 float a1 = -135.f, float a2 = 135.f, float aAnchor = -135.f,
257 EDirection direction = EDirection::Vertical, double gearing = DEFAULT_GEARING, float trackSize = 2.f);
258
259 virtual ~IVKnobControl() {}
260
261 void Draw(IGraphics& g) override;
262 virtual void DrawWidget(IGraphics& g) override;
263 virtual void DrawIndicatorTrack(IGraphics& g, float angle, float cx, float cy, float radius);
264 virtual void DrawPointer(IGraphics& g, float angle, float cx, float cy, float radius);
265
266 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
267 void OnMouseDblClick(float x, float y, const IMouseMod& mod) override;
268 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
269 void OnMouseOver(float x, float y, const IMouseMod& mod) override;
270 void OnMouseOut() override { mValueMouseOver = false; IKnobControlBase::OnMouseOut(); }
271
272 void OnResize() override;
273 bool IsHit(float x, float y) const override;
274 void SetDirty(bool push, int valIdx = kNoValIdx) override;
275 void OnInit() override;
276
277 void SetInnerPointerFrac(float frac) { mInnerPointerFrac = frac; }
278 void SetOuterPointerFrac(float frac) { mOuterPointerFrac = frac; }
279 void SetPointerThickness(float thickness) { mPointerThickness = thickness; }
280
281 float GetRadius() const;
282 IRECT GetTrackBounds() const;
283
284protected:
285 virtual IRECT GetKnobDragBounds() override;
286
287 float mTrackToHandleDistance = 4.f;
288 float mInnerPointerFrac = 0.1f;
289 float mOuterPointerFrac = 1.f;
290 float mPointerThickness = 2.5f;
291 float mAngle1, mAngle2;
292 float mAnchorAngle; // for bipolar arc
293 bool mValueMouseOver = false;
294};
295
298 , public IVectorBase
299{
300public:
301 IVSliderControl(const IRECT& bounds, int paramIdx = kNoParameter, const char* label = "", const IVStyle& style = DEFAULT_STYLE, bool valueIsEditable = false, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING, float handleSize = 8.f, float trackSize = 2.f, bool handleInsideTrack = false, float handleXOffset = 0.f, float handleYOffset = 0.f);
302
303 IVSliderControl(const IRECT& bounds, IActionFunction aF, const char* label = "", const IVStyle& style = DEFAULT_STYLE, bool valueIsEditable = false, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING, float handleSize = 8.f, float trackSize = 2.f, bool handleInsideTrack = false, float handleXOffset = 0.f, float handleYOffset = 0.f);
304
305 virtual ~IVSliderControl() {}
306 void Draw(IGraphics& g) override;
307 virtual void DrawWidget(IGraphics& g) override;
308 virtual void DrawTrack(IGraphics& g, const IRECT& filledArea);
309 virtual void DrawHandle(IGraphics& g, const IRECT& bounds);
310
311 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
312 void OnMouseDblClick(float x, float y, const IMouseMod& mod) override;
313 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
314 void OnMouseOver(float x, float y, const IMouseMod& mod) override;
315 void OnMouseOut() override { mValueMouseOver = false; ISliderControlBase::OnMouseOut(); }
316 bool IsHit(float x, float y) const override;
317 void OnResize() override;
318 void SetDirty(bool push, int valIdx = kNoValIdx) override;
319 void OnInit() override;
320
321 IRECT GetTrackBounds() const
322 {
323 auto offset = -mHandleSize + (mStyle.frameThickness / 2.0f);
324 return mWidgetBounds.GetPadded(mDirection == EDirection::Horizontal ? offset : 0,
325 mDirection == EDirection::Vertical ? offset : 0,
326 mDirection == EDirection::Horizontal ? offset : 0,
327 mDirection == EDirection::Vertical ? offset : 0);
328 }
329
330protected:
331 bool mHandleInsideTrack = false;
332 bool mValueMouseOver = false;
333 float mHandleXOffset = 0.f;
334 float mHandleYOffset = 0.f;
335};
336
339{
340public:
341 IVRangeSliderControl(const IRECT& bounds, const std::initializer_list<int>& params, const char* label = "", const IVStyle& style = DEFAULT_STYLE, EDirection dir = EDirection::Vertical, bool onlyHandle = false, float handleSize = 8.f, float trackSize = 2.f);
342
343 void Draw(IGraphics& g) override;
344 void DrawTrack(IGraphics& g, const IRECT& r, int chIdx) override;
345 void DrawWidget(IGraphics& g) override;
346 void OnMouseOver(float x, float y, const IMouseMod& mod) override;
347 void OnMouseOut() override { mMouseOverHandle = -1; IVTrackControlBase::OnMouseOut(); }
348 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
349 void OnMouseUp(float x, float y, const IMouseMod& mod) override { mMouseIsDown = false; }
350 void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override;
351
352protected:
353 void MakeTrackRects(const IRECT& bounds) override;
354 IRECT GetHandleBounds(int trackIdx);
355
356 int mMouseOverHandle = -1;
357 float mHandleSize;
358 bool mMouseIsDown = false;
359};
360
362class IVXYPadControl : public IControl, public IVectorBase
363{
364public:
365 IVXYPadControl(const IRECT& bounds, const std::initializer_list<int>& params, const char* label = "", const IVStyle& style = DEFAULT_STYLE, float handleRadius = 10.f, bool trackClipsHandle = true, bool drawCross = true);
366
367 void Draw(IGraphics& g) override;
368 void DrawWidget(IGraphics& g) override;
369 virtual void DrawHandle(IGraphics& g, const IRECT& trackBounds, const IRECT& handleBounds);
370 virtual void DrawTrack(IGraphics& g);
371 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
372 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
373 void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override;
374 void OnResize() override;
375protected:
376 float mHandleRadius;
377 bool mMouseDown = false;
378 bool mTrackClipsHandle = true;
379 bool mDrawCross = true;
380};
381
384 , public IVectorBase
385{
386public:
388 using IPlotFunc = std::function<double(double)>;
389
393 struct Plot {
394 IColor color;
395 IPlotFunc func;
396 };
397
408 IVPlotControl(const IRECT& bounds, const std::initializer_list<Plot>& funcs, int numPoints, const char* label = "", const IVStyle& style = DEFAULT_STYLE, float min = -1., float max = 1., bool useLayer = false);
409
410 void Draw(IGraphics& g) override;
411 void OnResize() override;
412
416 void AddPlotFunc(const IColor& color, const IPlotFunc& func);
417
418protected:
419 ILayerPtr mLayer;
420 std::vector<Plot> mPlots;
421 float mMin;
422 float mMax;
423 bool mUseLayer = true;
424 int mHorizontalDivisions = 10;
425 int mVerticalDivisions = 10; // always + 2 when drawing
426
427 std::vector<float> mPoints;
428};
429
432 , public IVectorBase
433{
434public:
442 IVGroupControl(const IRECT& bounds, const char* label = "", float labelOffset = 10.f, const IVStyle& style = DEFAULT_STYLE, IContainerBase::AttachFunc attachFunc = nullptr, IContainerBase::ResizeFunc resizeFunc = nullptr);
443
453 IVGroupControl(const char* label, const char* groupName, float padL = 0.f, float padT = 0.f, float padR = 0.f, float padB = 0.f, const IVStyle& style = DEFAULT_STYLE);
454
455 void Draw(IGraphics& g) override;
456 void DrawWidget(IGraphics& g) override;
457 void OnResize() override;
458 void OnInit() override;
459
466 void SetBoundsBasedOnGroup(const char* groupName, float padL, float padT, float padR, float padB);
467protected:
468 WDL_String mGroupName;
469 float mPadL = 0.f;
470 float mPadT = 0.f;
471 float mPadR = 0.f;
472 float mPadB = 0.f;
473 float mLabelOffset = 10.f;
474 float mLabelPadding = 10.f;
475};
476
479 , public IVectorBase
480{
481public:
482 IVPanelControl(const IRECT& bounds, const char* label = "", const IVStyle& style = DEFAULT_STYLE.WithColor(kFG, COLOR_TRANSLUCENT).WithEmboss(true))
483 : IContainerBase(bounds)
484 , IVectorBase(style)
485 {
486 mIgnoreMouse = true;
487 AttachIControl(this, label);
488 }
489
490 void Draw(IGraphics& g) override
491 {
492 DrawBackground(g, mRECT);
493 DrawWidget(g);
494 DrawLabel(g);
496 }
497
498 void DrawWidget(IGraphics& g) override
499 {
500 DrawPressableRectangle(g, mWidgetBounds, false, false, false);
501 }
502
503 void OnAttached() override
504 {
505 if (mAttachFunc)
506 mAttachFunc(this, mWidgetBounds);
507 }
508
509 void OnResize() override
510 {
511 SetTargetRECT(MakeRects(mRECT));
512
513 if (mResizeFunc && mChildren.GetSize())
514 mResizeFunc(this, mWidgetBounds);
515 }
516};
517
520 , public IVectorBase
521{
522public:
523 enum class ECellLayout { kGrid, kHorizontal, kVertical };
524
525 using ColorChosenFunc = std::function<void(int, IColor)>;
526
527 IVColorSwatchControl(const IRECT& bounds, const char* label = "", ColorChosenFunc func = nullptr, const IVStyle& spec = DEFAULT_STYLE, ECellLayout layout = ECellLayout::kGrid,
528 const std::initializer_list<EVColor>& colorIDs = { kBG, kFG, kPR, kFR, kHL, kSH, kX1, kX2, kX3 },
529 const std::initializer_list<const char*>& labelsForIDs = { kVColorStrs[kBG],kVColorStrs[kFG],kVColorStrs[kPR],kVColorStrs[kFR],kVColorStrs[kHL],kVColorStrs[kSH],kVColorStrs[kX1],kVColorStrs[kX2],kVColorStrs[kX3] });
530
531 virtual ~IVColorSwatchControl() { mLabels.Empty(true); }
532
533 void Draw(IGraphics& g) override;
534 void OnMouseOver(float x, float y, const IMouseMod& mod) override;
535 void OnMouseOut() override;
536 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
537 void OnResize() override;
538
539 void DrawWidget(IGraphics& g) override;
540
541private:
542 ColorChosenFunc mColorChosenFunc = nullptr;
543 int mCellOver = -1;
544 ECellLayout mLayout = ECellLayout::kVertical;
545 WDL_TypedBuf<IRECT> mCellRects;
546 WDL_PtrList<WDL_String> mLabels;
547 std::vector<EVColor> mColorIdForCells;
548};
549
550#pragma mark - SVG Vector Controls
551
554{
555public:
556 ISVGKnobControl(const IRECT& bounds, const ISVG& svg, int paramIdx = kNoParameter);
557
558 void Draw(IGraphics& g) override;
559 void SetSVG(ISVG& svg);
560
561private:
562 ISVG mSVG;
563 float mStartAngle = -135.f;
564 float mEndAngle = 135.f;
565};
566
569{
570public:
576 ISVGButtonControl(const IRECT& bounds, IActionFunction aF, const ISVG& offImage, const ISVG& onImage);
577
584 ISVGButtonControl(const IRECT& bounds, IActionFunction aF, const ISVG& image, const std::array<IColor, 4> colors = {COLOR_BLACK, COLOR_WHITE, COLOR_DARK_GRAY, COLOR_LIGHT_GRAY}, EColorReplacement colorReplacement = EColorReplacement::Fill);
585
586 void Draw(IGraphics& g) override;
587
588protected:
589 ISVG mOffSVG;
590 ISVG mOnSVG;
591 std::array<IColor, 4> mColors;
592 EColorReplacement mColorReplacement = EColorReplacement::None;
593};
594
597{
598public:
604 ISVGToggleControl(const IRECT& bounds, IActionFunction aF, const ISVG& offImage, const ISVG& onImage);
605
611 ISVGToggleControl(const IRECT& bounds, int paramIdx, const ISVG& offImage, const ISVG& onImage);
612
619 ISVGToggleControl(const IRECT& bounds, IActionFunction aF, const ISVG& image, const std::array<IColor, 4> colors = {COLOR_BLACK, COLOR_WHITE, COLOR_DARK_GRAY, COLOR_LIGHT_GRAY}, EColorReplacement colorReplacement = EColorReplacement::Fill);
620
627 ISVGToggleControl(const IRECT& bounds, int paramIdx, const ISVG& image, const std::array<IColor, 4> colors = {COLOR_BLACK, COLOR_WHITE, COLOR_DARK_GRAY, COLOR_LIGHT_GRAY}, EColorReplacement colorReplacement = EColorReplacement::Fill);
628
629 void Draw(IGraphics& g) override;
630
631protected:
632 ISVG mOffSVG;
633 ISVG mOnSVG;
634 std::array<IColor, 4> mColors;
635 EColorReplacement mColorReplacement = EColorReplacement::None;
636};
637
640{
641public:
647 ISVGSwitchControl(const IRECT& bounds, const std::initializer_list<ISVG>& svgs, int paramIdx = kNoParameter, IActionFunction aF = nullptr);
648
649 void Draw(IGraphics& g) override;
650
651protected:
652 std::vector<ISVG> mSVGs;
653};
654
657{
658public:
666 ISVGSliderControl(const IRECT& bounds, const ISVG& handleSvg, const ISVG& trackSVG, int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING);
667
668 void Draw(IGraphics& g) override;
669 void OnResize() override;
670
671protected:
672 IRECT GetHandleBounds(double value = -1.0) const;
673
674 IRECT mTrackSVGBounds;
675 IRECT mHandleBoundsAtMax;
676 ISVG mHandleSVG;
677 ISVG mTrackSVG;
678};
679
680#pragma mark - Bitmap Controls
681
684 , public IBitmapBase
685{
686public:
687 IBButtonControl(float x, float y, const IBitmap& bitmap, IActionFunction aF = DefaultClickActionFunc);
688
689 IBButtonControl(const IRECT& bounds, const IBitmap& bitmap, IActionFunction aF = DefaultClickActionFunc);
690
691 void Draw(IGraphics& g) override { DrawBitmap(g); }
692 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
693};
694
697 , public IBitmapBase
698{
699public:
705 IBSwitchControl(float x, float y, const IBitmap& bitmap, int paramIdx = kNoParameter);
706
711 IBSwitchControl(const IRECT& bounds, const IBitmap& bitmap, int paramIdx = kNoParameter);
712
713 virtual ~IBSwitchControl() {}
714 void Draw(IGraphics& g) override { DrawBitmap(g); }
715 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
716 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
717};
718
721 , public IBitmapBase
722{
723public:
724 IBKnobControl(float x, float y, const IBitmap& bitmap, int paramIdx, EDirection direction = EDirection::Vertical, double gearing = DEFAULT_GEARING)
725 : IKnobControlBase(IRECT(x, y, bitmap), paramIdx, direction, gearing)
726 , IBitmapBase(bitmap) { AttachIControl(this); }
727
728 IBKnobControl(const IRECT& bounds, const IBitmap& bitmap, int paramIdx, EDirection direction = EDirection::Vertical, double gearing = DEFAULT_GEARING)
729 : IKnobControlBase(bounds.GetCentredInside(bitmap), paramIdx, direction, gearing)
730 , IBitmapBase(bitmap) { AttachIControl(this); }
731
732 virtual ~IBKnobControl() {}
733 void Draw(IGraphics& g) override { DrawBitmap(g); }
734 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
735};
736
739{
740public:
741 IBKnobRotaterControl(float x, float y, const IBitmap& bitmap, int paramIdx)
742 : IBKnobControl(IRECT(x, y, bitmap), bitmap, paramIdx) {}
743
744 IBKnobRotaterControl(const IRECT& bounds, const IBitmap& bitmap, int paramIdx)
745 : IBKnobControl(bounds.GetCentredInside(bitmap), bitmap, paramIdx) {}
746
747 virtual ~IBKnobRotaterControl() {}
748 void Draw(IGraphics& g) override;
749};
750
753 , public IBitmapBase
754{
755public:
756 IBSliderControl(float x, float y, float trackLength, const IBitmap& handleBitmap, const IBitmap& trackBitmap = IBitmap(), int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING);
757
758 IBSliderControl(const IRECT& bounds, const IBitmap& handleBitmap, const IBitmap& trackBitmap = IBitmap(), int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING);
759
760 virtual ~IBSliderControl() {}
761
762 void Draw(IGraphics& g) override;
763 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
764 void OnResize() override;
765
766 IRECT GetHandleBounds(double value = -1.0) const;
767
768protected:
769 IBitmap mTrackBitmap;
770};
771
774 , public IBitmapBase
775{
776public:
777 IBTextControl(const IRECT& bounds, const IBitmap& bitmap, const IText& text = DEFAULT_TEXT, const char* str = "", int charWidth = 6, int charHeight = 12, int charOffset = 0, bool multiLine = false, bool vCenter = true, EBlend blend = EBlend::Default);
778 virtual ~IBTextControl() {}
779
780 void Draw(IGraphics& g) override;
781 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
782
783protected:
784 int mCharWidth, mCharHeight, mCharOffset;
785 bool mMultiLine;
786 bool mVCentre;
787};
788
791{
792public:
793 enum class EResponse {
794 Linear,
795 Log,
796 };
797
802 IBMeterControl(float x, float y, const IBitmap& bitmap, EResponse response = EResponse::Log, float lowRangeDB = -72.f, float highRangeDB = 12.f)
803 : IBitmapControl(x, y, bitmap)
804 , mResponse(response)
805 , mLowRangeDB(lowRangeDB)
806 , mHighRangeDB(highRangeDB)
807 {}
808
812 IBMeterControl(const IRECT& bounds, const IBitmap& bitmap, EResponse response = EResponse::Log, float lowRangeDB = -72.f, float highRangeDB = 12.f)
813 : IBitmapControl(bounds, bitmap)
814 , mResponse(response)
815 , mLowRangeDB(lowRangeDB)
816 , mHighRangeDB(highRangeDB)
817 {}
818
819 virtual ~IBMeterControl() {}
820 void Draw(IGraphics& g) override { DrawBitmap(g); }
821 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
822 void OnMsgFromDelegate(int msgTag, int dataSize, const void* pData) override;
823
824protected:
825 float mHighRangeDB;
826 float mLowRangeDB;
827 EResponse mResponse = EResponse::Linear;
828};
829
830END_IGRAPHICS_NAMESPACE
831END_IPLUG_NAMESPACE
832
833// These meta controls depend on the other controls
834#include "IAboutBoxControl.h"
836#include "IVNumberBoxControl.h"
837#include "IVTabbedPagesControl.h"
838
This file contains the base IControl implementation, along with some base classes for specific types ...
Includes meta controls for basic preset managers.
A bitmap button/momentary switch control.
Definition: IControls.h:685
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.h:691
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:692
A bitmap knob/dial control that draws a frame from a stacked bitmap.
Definition: IControls.h:722
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:734
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.h:733
A bitmap knob/dial control that rotates an image.
Definition: IControls.h:739
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1730
A bitmap meter control, that can be used for VUMeters.
Definition: IControls.h:791
void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData) override
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate()
Definition: IControls.cpp:1753
IBMeterControl(float x, float y, const IBitmap &bitmap, EResponse response=EResponse::Log, float lowRangeDB=-72.f, float highRangeDB=12.f)
Constructs a bitmap meter control.
Definition: IControls.h:802
IBMeterControl(const IRECT &bounds, const IBitmap &bitmap, EResponse response=EResponse::Log, float lowRangeDB=-72.f, float highRangeDB=12.f)
Constructs a bitmap meter control.
Definition: IControls.h:812
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:821
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.h:820
A bitmap slider/fader control.
Definition: IControls.h:754
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1704
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1681
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:763
A bitmap switch control.
Definition: IControls.h:698
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:715
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControls.cpp:1648
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.h:714
A control to display text using a monospace bitmap font.
Definition: IControls.h:775
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1748
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:781
A base interface to be combined with IControl for bitmap-based controls "IBControls",...
Definition: IControl.h:719
void AttachIControl(IControl *pControl)
Call in the constructor of your IBControl to link the IBitmapBase and IControl.
Definition: IControl.h:732
void DrawBitmap(IGraphics &g)
Draw a frame of a multi-frame bitmap based on the IControl value.
Definition: IControl.h:736
A basic control to draw a bitmap, or one frame of a stacked bitmap depending on the current value.
Definition: IControl.h:2081
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
A base class for buttons/momentary switches - cannot be linked to parameters.
Definition: IControl.h:1863
IContainerBase allows a control to nest sub controls and it clips the drawing of those subcontrols In...
Definition: IControl.h:606
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
IGraphics * GetUI()
Definition: IControl.h:467
virtual void OnMouseOut()
Implement this method to respond to a mouseout event on this control.
Definition: IControl.cpp:275
bool mMouseIsOver
if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control.
Definition: IControl.h:560
void SetTargetRECT(const IRECT &bounds)
Set the rectangular mouse tracking target area, within the graphics context for this control.
Definition: IControl.h:323
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
Definition: IControl.cpp:198
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
IBitmap GetScaledBitmap(IBitmap &inBitmap)
Get a version of the input bitmap from the cache that corresponds to the current screen scale For exa...
Definition: IGraphics.cpp:1520
A base class for knob/dial controls, to handle mouse action and Sender.
Definition: IControl.h:1368
A class for setting the contents of a pop up menu.
A vector button/momentary switch control which shows an SVG image.
Definition: IControls.h:569
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1440
A vector knob/dial control which rotates an SVG image.
Definition: IControls.h:554
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1531
A Slider control with and SVG for track and handle.
Definition: IControls.h:657
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1560
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1566
A vector switch control which shows one of multiple SVG states.
Definition: IControls.h:640
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1548
A vector toggle switch control which shows an SVG image.
Definition: IControls.h:597
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1499
A base class for slider/fader controls, to handle mouse action and Sender.
Definition: IControl.h:1398
A base class for switch controls.
Definition: IControl.h:1874
A basic control to display some text.
Definition: IControl.h:2152
A vector button/momentary switch control.
Definition: IControls.h:53
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:63
bool IsHit(float x, float y) const override
Hit test the control.
Definition: IControls.cpp:83
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:71
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:77
A control to show a color swatch of up to 9 colors.
Definition: IControls.h:521
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.cpp:1390
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1343
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1322
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControls.cpp:1396
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:1328
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
Definition: IControls.cpp:1374
A control to draw a rectangle around a named IControl group.
Definition: IControls.h:433
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1243
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:1252
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControls.cpp:1235
void SetBoundsBasedOnGroup(const char *groupName, float padL, float padT, float padR, float padB)
Set the bounds of the group control based on the area occupied by the controls in a particular group.
Definition: IControls.cpp:1289
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1279
A vector knob control drawn using graphics primitives.
Definition: IControls.h:243
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControls.cpp:742
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.h:270
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:613
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
Definition: IControls.cpp:705
bool IsHit(float x, float y) const override
Hit test the control.
Definition: IControls.cpp:721
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:715
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:652
void OnMouseDblClick(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse double click event on this control.
Definition: IControls.cpp:690
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControls.cpp:699
virtual IRECT GetKnobDragBounds() override
Get the area for which mouse deltas will be used to calculate the amount dragging changes the control...
Definition: IControls.cpp:621
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControls.cpp:676
void SetDirty(bool push, int valIdx=kNoValIdx) override
Mark the control as dirty, i.e.
Definition: IControls.cpp:732
A vector label control that can display text with a shadow.
Definition: IControls.h:44
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:38
A vector button that pops up a menu.
Definition: IControls.h:220
void SetValueFromDelegate(double value, int valIdx=0) override
Set the control's value from the delegate This method is called from the class implementing the IEdit...
Definition: IControls.cpp:552
void SetValueFromUserInput(double value, int valIdx) override
Set the control's value after user input.
Definition: IControls.cpp:569
void SetStyle(const IVStyle &style) override
Set the Style of this IVControl.
Definition: IControls.cpp:546
void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx) override
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControlPromptU...
Definition: IControls.cpp:560
A panel control which can be styled with emboss etc.
Definition: IControls.h:480
void OnAttached() override
Called after the control has been attached, and its delegate and graphics member variable set.
Definition: IControls.h:503
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.h:490
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.h:509
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.h:498
A vector plot to display functions and waveforms.
Definition: IControls.h:385
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1154
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1198
void AddPlotFunc(const IColor &color, const IPlotFunc &func)
add a new function to the plot
Definition: IControls.cpp:1204
std::function< double(double)> IPlotFunc
IVPlotControl passes values between 0 and 1 to this object, that are the plot normalized x values.
Definition: IControls.h:388
Groups a plot function and color.
Definition: IControls.h:393
A vector "radio buttons" switch control.
Definition: IControls.h:184
int GetButtonForPoint(float x, float y) const override
Definition: IControls.cpp:504
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:486
A vector range slider control, with two handles.
Definition: IControls.h:339
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
Definition: IControls.cpp:1013
void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod &mod) override
Implement this method to respond to a mouse drag event on this control.
Definition: IControls.cpp:1040
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControls.cpp:1034
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.h:347
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControls.h:349
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:931
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:990
A switch with a slide animation when clicked.
Definition: IControls.h:106
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:273
void SetDirty(bool push, int valIdx=kNoValIdx) override
Mark the control as dirty, i.e.
Definition: IControls.cpp:290
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:263
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:250
A vector slider control.
Definition: IControls.h:299
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:876
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.h:315
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
Definition: IControls.cpp:867
void SetDirty(bool push, int valIdx=kNoValIdx) override
Mark the control as dirty, i.e.
Definition: IControls.cpp:901
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControls.cpp:861
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControls.cpp:840
void OnMouseDblClick(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse double click event on this control.
Definition: IControls.cpp:852
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:807
bool IsHit(float x, float y) const override
Hit test the control.
Definition: IControls.cpp:888
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControls.cpp:911
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:785
A vector switch control.
Definition: IControls.h:74
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControls.cpp:144
bool IsHit(float x, float y) const override
Hit test the control.
Definition: IControls.cpp:139
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:118
void SetDirty(bool push, int valIdx=kNoValIdx) override
Mark the control as dirty, i.e.
Definition: IControls.cpp:123
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:133
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:110
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.h:82
A vector "tab" multi switch control.
Definition: IControls.h:131
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.h:165
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:449
virtual bool IsHit(float x, float y) const override
Hit test the control.
Definition: IControls.cpp:426
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControls.cpp:431
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:387
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:350
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
Definition: IControls.cpp:440
virtual int GetButtonForPoint(float x, float y) const
Definition: IControls.cpp:415
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControls.cpp:332
const char * GetSelectedLabelStr() const
returns the label string on the selected tab
Definition: IControls.cpp:463
A vector toggle control.
Definition: IControls.h:91
void DrawValue(IGraphics &g, bool mouseOver) override
Draw the IVControl value text.
Definition: IControls.cpp:180
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:175
A base class for mult-strip/track controls, such as multi-sliders, meters Track refers to the channel...
Definition: IControl.h:1426
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControl.h:1522
A vector XY Pad slider control.
Definition: IControls.h:363
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControls.cpp:1103
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:1073
void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod &mod) override
Implement this method to respond to a mouse drag event on this control.
Definition: IControls.cpp:1121
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1131
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1062
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControls.cpp:1112
A base interface to be combined with IControl for vectorial controls "IVControls",...
Definition: IControl.h:757
IRECT MakeRects(const IRECT &parent, bool hasHandle=false)
Calculate the rectangles for the various areas, depending on the style.
Definition: IControl.h:1158
virtual void DrawBackground(IGraphics &g, const IRECT &rect)
Draw the IVControl background (usually transparent)
Definition: IControl.h:876
virtual void DrawValue(IGraphics &g, bool mouseOver)
Draw the IVControl value text.
Definition: IControl.h:899
void AttachIControl(IControl *pControl, const char *label)
Call in the constructor of your IVControl to link the IVectorBase and IControl.
Definition: IControl.h:775
IRECT DrawPressableRectangle(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, bool disabled, bool rtl=true, bool rtr=true, bool rbl=true, bool rbr=true)
Draw a rectangle-shaped vector button.
Definition: IControl.h:1020
virtual void DrawLabel(IGraphics &g)
Draw the IVControl label text.
Definition: IControl.h:889
void EmptyClickActionFunc(IControl *pCaller)
A click action function that does nothing.
Definition: IControl.cpp:43
void DefaultClickActionFunc(IControl *pCaller)
A click action function that triggers the default animation function for DEFAULT_ANIMATION_DURATION.
Definition: IControl.cpp:45
void SplashClickActionFunc(IControl *pCaller)
The splash click action function is used by IVControls to start SplashAnimationFunc.
Definition: IControl.cpp:47
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
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 GetCentredInside(const IRECT &sr) const
Get a rectangle the size of sr but with the same center point as this rectangle.
IRECT GetPadded(float padding) const
Get a copy of this IRECT with each value padded by padding N.B.
User-facing SVG abstraction that you use to manage SVG data ISVG doesn't actually own the image data.
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.