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"
28#include "IVScopeControl.h"
30#include "IVDisplayControl.h"
31
32BEGIN_IPLUG_NAMESPACE
33BEGIN_IGRAPHICS_NAMESPACE
34
40#pragma mark - Vector Controls
41
44 , public IVectorBase
45{
46public:
47 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)));
48 void Draw(IGraphics& g) override;
49};
50
53 , public IVectorBase
54{
55public:
64 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);
65
66 void Draw(IGraphics& g) override;
67 virtual void DrawWidget(IGraphics& g) override;
68 bool IsHit(float x, float y) const override;
69 void OnResize() override;
70};
71
74 , public IVectorBase
75{
76public:
77 IVSwitchControl(const IRECT& bounds, int paramIdx = kNoParameter, const char* label = "", const IVStyle& style = DEFAULT_STYLE, bool valueInButton = true);
78
79 IVSwitchControl(const IRECT& bounds, IActionFunction aF = SplashClickActionFunc, const char* label = "", const IVStyle& style = DEFAULT_STYLE, int numStates = 2, bool valueInButton = true);
80
81 void Draw(IGraphics& g) override;
82 virtual void DrawWidget(IGraphics& g) override;
83 void OnMouseOut() override { ISwitchControlBase::OnMouseOut(); SetDirty(false); }
84 bool IsHit(float x, float y) const override;
85 void SetDirty(bool push, int valIdx = kNoValIdx) override;
86 void OnResize() override;
87 void OnInit() override;
88};
89
92{
93public:
94 IVToggleControl(const IRECT& bounds, int paramIdx = kNoParameter, const char* label = "", const IVStyle& style = DEFAULT_STYLE, const char* offText = "OFF", const char* onText = "ON");
95
96 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);
97
98 void DrawValue(IGraphics& g, bool mouseOver) override;
99 void DrawWidget(IGraphics& g) override;
100protected:
101 WDL_String mOffText;
102 WDL_String mOnText;
103};
104
107{
108public:
116 IVSlideSwitchControl(const IRECT& bounds, int paramIdx = kNoParameter, const char* label = "", const IVStyle& style = DEFAULT_STYLE, bool valueInButton = false, EDirection direction = EDirection::Horizontal);
117
127 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);
128
129 void Draw(IGraphics& g) override;
130 virtual void DrawWidget(IGraphics& g) override;
131 virtual void DrawHandle(IGraphics& g, const IRECT& filledArea);
132 virtual void DrawTrack(IGraphics& g, const IRECT& filledArea);
133
134 void OnResize() override;
135 void OnEndAnimation() override;
136 void SetDirty(bool push, int valIdx = kNoValIdx) override;
137protected:
138 void UpdateRects();
139
140 IRECT mStartRect, mEndRect;
141 IRECT mHandleBounds;
142 EDirection mDirection;
143};
144
147 , public IVectorBase
148{
149public:
150 enum class ETabSegment { Start, Mid, End };
151
160 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);
161
170 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);
171
172 virtual ~IVTabSwitchControl() { mTabLabels.Empty(true); }
173 void Draw(IGraphics& g) override;
174 void OnInit() override;
175
176 virtual void DrawWidget(IGraphics& g) override;
177 virtual void DrawButton(IGraphics& g, const IRECT& bounds, bool pressed, bool mouseOver, ETabSegment segment, bool disabled);
178 virtual void DrawButtonText(IGraphics& g, const IRECT& bounds, bool pressed, bool mouseOver, ETabSegment segment, bool disabled, const char* textStr);
179
180 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
181 void OnMouseOver(float x, float y, const IMouseMod& mod) override;
182 void OnMouseOut() override { mMouseOverButton = -1; ISwitchControlBase::OnMouseOut(); SetDirty(false); }
183 void OnResize() override;
184 virtual bool IsHit(float x, float y) const override;
185
187 const char* GetSelectedLabelStr() const;
188protected:
189
191 virtual int GetButtonForPoint(float x, float y) const;
192
193 int mMouseOverButton = -1;
194 WDL_TypedBuf<IRECT> mButtons;
195 WDL_PtrList<WDL_String> mTabLabels;
196 EDirection mDirection;
197};
198
201{
202public:
211 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);
212
222 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);
223
224 virtual void DrawWidget(IGraphics& g) override;
225protected:
227 int GetButtonForPoint(float x, float y) const override;
228
229 float mButtonSize;
230 float mButtonAreaWidth;
231 bool mOnlyButtonsRespondToMouse = false;
232};
233
236 , public IVectorBase
237{
238public:
245 IVMenuButtonControl(const IRECT& bounds, int paramIdx, const char* label = "", const IVStyle& style = DEFAULT_STYLE, EVShape shape = EVShape::Rectangle);
246
247 void OnPopupMenuSelection(IPopupMenu* pSelectedMenu, int valIdx) override;
248 void SetValueFromUserInput(double value, int valIdx) override;
249
250 void SetValueFromDelegate(double value, int valIdx = 0) override;
251 void SetStyle(const IVStyle& style) override;
252
253private:
254 IVButtonControl* mButtonControl = nullptr;
255};
256
259 , public IVectorBase
260{
261public:
262 IVKnobControl(const IRECT& bounds, int paramIdx,
263 const char* label = "",
264 const IVStyle& style = DEFAULT_STYLE,
265 bool valueIsEditable = false, bool valueInWidget = false,
266 float a1 = -135.f, float a2 = 135.f, float aAnchor = -135.f,
267 EDirection direction = EDirection::Vertical, double gearing = DEFAULT_GEARING, float trackSize = 2.f);
268
269 IVKnobControl(const IRECT& bounds, IActionFunction aF,
270 const char* label = "",
271 const IVStyle& style = DEFAULT_STYLE,
272 bool valueIsEditable = false, bool valueInWidget = false,
273 float a1 = -135.f, float a2 = 135.f, float aAnchor = -135.f,
274 EDirection direction = EDirection::Vertical, double gearing = DEFAULT_GEARING, float trackSize = 2.f);
275
276 virtual ~IVKnobControl() {}
277
278 void Draw(IGraphics& g) override;
279 virtual void DrawWidget(IGraphics& g) override;
280 virtual void DrawHandle(IGraphics& g, const IRECT& bounds);
281 virtual void DrawIndicatorTrack(IGraphics& g, float angle, float cx, float cy, float radius);
282 virtual void DrawPointer(IGraphics& g, float angle, float cx, float cy, float radius);
283
284 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
285 void OnMouseDblClick(float x, float y, const IMouseMod& mod) override;
286 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
287 void OnMouseOver(float x, float y, const IMouseMod& mod) override;
288 void OnMouseOut() override { mValueMouseOver = false; IKnobControlBase::OnMouseOut(); }
289
290 void OnResize() override;
291 bool IsHit(float x, float y) const override;
292 void SetDirty(bool push, int valIdx = kNoValIdx) override;
293 void OnInit() override;
294
295 void SetInnerPointerFrac(float frac) { mInnerPointerFrac = frac; }
296 void SetOuterPointerFrac(float frac) { mOuterPointerFrac = frac; }
297 void SetPointerThickness(float thickness) { mPointerThickness = thickness; }
298
299 float GetRadius() const;
300 IRECT GetTrackBounds() const;
301
302protected:
303 virtual IRECT GetKnobDragBounds() override;
304
305 float mTrackToHandleDistance = 4.f;
306 float mInnerPointerFrac = 0.1f;
307 float mOuterPointerFrac = 1.f;
308 float mPointerThickness = 2.5f;
309 float mAngle1, mAngle2;
310 float mAnchorAngle; // for bipolar arc
311 bool mValueMouseOver = false;
312};
313
316 , public IVectorBase
317{
318public:
319 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);
320
321 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);
322
323 virtual ~IVSliderControl() {}
324 void Draw(IGraphics& g) override;
325 virtual void DrawWidget(IGraphics& g) override;
326 virtual void DrawTrack(IGraphics& g, const IRECT& filledArea);
327 virtual void DrawHandle(IGraphics& g, const IRECT& bounds);
328
329 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
330 void OnMouseDblClick(float x, float y, const IMouseMod& mod) override;
331 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
332 void OnMouseOver(float x, float y, const IMouseMod& mod) override;
333 void OnMouseOut() override { mValueMouseOver = false; ISliderControlBase::OnMouseOut(); }
334 bool IsHit(float x, float y) const override;
335 void OnResize() override;
336 void SetDirty(bool push, int valIdx = kNoValIdx) override;
337 void OnInit() override;
338
339 IRECT GetTrackBounds() const
340 {
341 auto offset = -mHandleSize + (mStyle.frameThickness / 2.0f);
342 return mWidgetBounds.GetPadded(mDirection == EDirection::Horizontal ? offset : 0,
343 mDirection == EDirection::Vertical ? offset : 0,
344 mDirection == EDirection::Horizontal ? offset : 0,
345 mDirection == EDirection::Vertical ? offset : 0);
346 }
347
348protected:
349 bool mHandleInsideTrack = false;
350 bool mValueMouseOver = false;
351 float mHandleXOffset = 0.f;
352 float mHandleYOffset = 0.f;
353};
354
357{
358public:
359 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);
360
361 void Draw(IGraphics& g) override;
362 void DrawTrack(IGraphics& g, const IRECT& r, int chIdx) override;
363 void DrawWidget(IGraphics& g) override;
364 void OnMouseOver(float x, float y, const IMouseMod& mod) override;
365 void OnMouseOut() override { mMouseOverHandle = -1; IVTrackControlBase::OnMouseOut(); }
366 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
367 void OnMouseUp(float x, float y, const IMouseMod& mod) override { mMouseIsDown = false; }
368 void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override;
369
370protected:
371 void MakeTrackRects(const IRECT& bounds) override;
372 IRECT GetHandleBounds(int trackIdx);
373
374 int mMouseOverHandle = -1;
375 float mHandleSize;
376 bool mMouseIsDown = false;
377};
378
380class IVXYPadControl : public IControl, public IVectorBase
381{
382public:
383 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);
384
385 void Draw(IGraphics& g) override;
386 void DrawWidget(IGraphics& g) override;
387 virtual void DrawHandle(IGraphics& g, const IRECT& trackBounds, const IRECT& handleBounds);
388 virtual void DrawTrack(IGraphics& g);
389 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
390 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
391 void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override;
392 void OnResize() override;
393protected:
394 float mHandleRadius;
395 bool mMouseDown = false;
396 bool mTrackClipsHandle = true;
397 bool mDrawCross = true;
398};
399
402 , public IVectorBase
403{
404public:
406 using IPlotFunc = std::function<double(double)>;
407
411 struct Plot {
412 IColor color;
413 IPlotFunc func;
414 };
415
426 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);
427
428 void Draw(IGraphics& g) override;
429 void OnResize() override;
430
434 void AddPlotFunc(const IColor& color, const IPlotFunc& func);
435
436protected:
437 ILayerPtr mLayer;
438 std::vector<Plot> mPlots;
439 float mMin;
440 float mMax;
441 bool mUseLayer = true;
442 int mHorizontalDivisions = 10;
443 int mVerticalDivisions = 10; // always + 2 when drawing
444
445 std::vector<float> mPoints;
446};
447
450 , public IVectorBase
451{
452public:
460 IVGroupControl(const IRECT& bounds, const char* label = "", float labelOffset = 10.f, const IVStyle& style = DEFAULT_STYLE, IContainerBase::AttachFunc attachFunc = nullptr, IContainerBase::ResizeFunc resizeFunc = nullptr);
461
471 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);
472
473 void Draw(IGraphics& g) override;
474 void DrawWidget(IGraphics& g) override;
475 void OnResize() override;
476 void OnInit() override;
477
484 void SetBoundsBasedOnGroup(const char* groupName, float padL, float padT, float padR, float padB);
485protected:
486 WDL_String mGroupName;
487 float mPadL = 0.f;
488 float mPadT = 0.f;
489 float mPadR = 0.f;
490 float mPadB = 0.f;
491 float mLabelOffset = 10.f;
492 float mLabelPadding = 10.f;
493};
494
497 , public IVectorBase
498{
499public:
500 IVPanelControl(const IRECT& bounds, const char* label = "", const IVStyle& style = DEFAULT_STYLE.WithColor(kFG, COLOR_TRANSLUCENT).WithEmboss(true))
501 : IContainerBase(bounds)
502 , IVectorBase(style)
503 {
504 mIgnoreMouse = true;
505 AttachIControl(this, label);
506 }
507
508 void Draw(IGraphics& g) override
509 {
510 DrawBackground(g, mRECT);
511 DrawWidget(g);
512 DrawLabel(g);
514 }
515
516 void DrawWidget(IGraphics& g) override
517 {
518 DrawPressableRectangle(g, mWidgetBounds, false, false, false);
519 }
520
521 void OnAttached() override
522 {
523 if (mAttachFunc)
524 mAttachFunc(this, mWidgetBounds);
525 }
526
527 void OnResize() override
528 {
529 SetTargetRECT(MakeRects(mRECT));
530
531 if (mResizeFunc && mChildren.GetSize())
532 mResizeFunc(this, mWidgetBounds);
533 }
534};
535
538 , public IVectorBase
539{
540public:
541 enum class ECellLayout { kGrid, kHorizontal, kVertical };
542
543 using ColorChosenFunc = std::function<void(int, IColor)>;
544
545 IVColorSwatchControl(const IRECT& bounds, const char* label = "", ColorChosenFunc func = nullptr, const IVStyle& spec = DEFAULT_STYLE, ECellLayout layout = ECellLayout::kGrid,
546 const std::initializer_list<EVColor>& colorIDs = { kBG, kFG, kPR, kFR, kHL, kSH, kX1, kX2, kX3 },
547 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] });
548
549 virtual ~IVColorSwatchControl() { mLabels.Empty(true); }
550
551 void Draw(IGraphics& g) override;
552 void OnMouseOver(float x, float y, const IMouseMod& mod) override;
553 void OnMouseOut() override;
554 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
555 void OnResize() override;
556
557 void DrawWidget(IGraphics& g) override;
558
559private:
560 ColorChosenFunc mColorChosenFunc = nullptr;
561 int mCellOver = -1;
562 ECellLayout mLayout = ECellLayout::kVertical;
563 WDL_TypedBuf<IRECT> mCellRects;
564 WDL_PtrList<WDL_String> mLabels;
565 std::vector<EVColor> mColorIdForCells;
566};
567
568#pragma mark - SVG Vector Controls
569
572{
573public:
574 ISVGKnobControl(const IRECT& bounds, const ISVG& svg, int paramIdx = kNoParameter);
575
576 void Draw(IGraphics& g) override;
577 void SetSVG(ISVG& svg);
578
579private:
580 ISVG mSVG;
581 float mStartAngle = -135.f;
582 float mEndAngle = 135.f;
583};
584
587{
588public:
594 ISVGButtonControl(const IRECT& bounds, IActionFunction aF, const ISVG& offImage, const ISVG& onImage);
595
602 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);
603
604 void Draw(IGraphics& g) override;
605
606protected:
607 ISVG mOffSVG;
608 ISVG mOnSVG;
609 std::array<IColor, 4> mColors;
610 EColorReplacement mColorReplacement = EColorReplacement::None;
611};
612
615{
616public:
622 ISVGToggleControl(const IRECT& bounds, IActionFunction aF, const ISVG& offImage, const ISVG& onImage);
623
629 ISVGToggleControl(const IRECT& bounds, int paramIdx, const ISVG& offImage, const ISVG& onImage);
630
637 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);
638
645 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);
646
647 void Draw(IGraphics& g) override;
648
649protected:
650 ISVG mOffSVG;
651 ISVG mOnSVG;
652 std::array<IColor, 4> mColors;
653 EColorReplacement mColorReplacement = EColorReplacement::None;
654};
655
658{
659public:
665 ISVGSwitchControl(const IRECT& bounds, const std::initializer_list<ISVG>& svgs, int paramIdx = kNoParameter, IActionFunction aF = nullptr);
666
667 void Draw(IGraphics& g) override;
668
669protected:
670 std::vector<ISVG> mSVGs;
671};
672
675{
676public:
684 ISVGSliderControl(const IRECT& bounds, const ISVG& handleSvg, const ISVG& trackSVG, int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING);
685
686 void Draw(IGraphics& g) override;
687 void OnResize() override;
688
689protected:
690 IRECT GetHandleBounds(double value = -1.0) const;
691
692 IRECT mTrackSVGBounds;
693 IRECT mHandleBoundsAtMax;
694 ISVG mHandleSVG;
695 ISVG mTrackSVG;
696};
697
698#pragma mark - Bitmap Controls
699
702 , public IBitmapBase
703{
704public:
705 IBButtonControl(float x, float y, const IBitmap& bitmap, IActionFunction aF = DefaultClickActionFunc);
706
707 IBButtonControl(const IRECT& bounds, const IBitmap& bitmap, IActionFunction aF = DefaultClickActionFunc);
708
709 void Draw(IGraphics& g) override { DrawBitmap(g); }
710 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
711};
712
715 , public IBitmapBase
716{
717public:
723 IBSwitchControl(float x, float y, const IBitmap& bitmap, int paramIdx = kNoParameter);
724
729 IBSwitchControl(const IRECT& bounds, const IBitmap& bitmap, int paramIdx = kNoParameter);
730
731 virtual ~IBSwitchControl() {}
732 void Draw(IGraphics& g) override { DrawBitmap(g); }
733 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
734 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
735};
736
739 , public IBitmapBase
740{
741public:
742 IBKnobControl(float x, float y, const IBitmap& bitmap, int paramIdx, EDirection direction = EDirection::Vertical, double gearing = DEFAULT_GEARING)
743 : IKnobControlBase(IRECT(x, y, bitmap), paramIdx, direction, gearing)
744 , IBitmapBase(bitmap) { AttachIControl(this); }
745
746 IBKnobControl(const IRECT& bounds, const IBitmap& bitmap, int paramIdx, EDirection direction = EDirection::Vertical, double gearing = DEFAULT_GEARING)
747 : IKnobControlBase(bounds.GetCentredInside(bitmap), paramIdx, direction, gearing)
748 , IBitmapBase(bitmap) { AttachIControl(this); }
749
750 virtual ~IBKnobControl() {}
751 void Draw(IGraphics& g) override { DrawBitmap(g); }
752 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
753};
754
757{
758public:
759 IBKnobRotaterControl(float x, float y, const IBitmap& bitmap, int paramIdx)
760 : IBKnobControl(IRECT(x, y, bitmap), bitmap, paramIdx) {}
761
762 IBKnobRotaterControl(const IRECT& bounds, const IBitmap& bitmap, int paramIdx)
763 : IBKnobControl(bounds.GetCentredInside(bitmap), bitmap, paramIdx) {}
764
765 virtual ~IBKnobRotaterControl() {}
766 void Draw(IGraphics& g) override;
767};
768
771 , public IBitmapBase
772{
773public:
774 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);
775
776 IBSliderControl(const IRECT& bounds, const IBitmap& handleBitmap, const IBitmap& trackBitmap = IBitmap(), int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING);
777
778 virtual ~IBSliderControl() {}
779
780 void Draw(IGraphics& g) override;
781 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
782 void OnResize() override;
783
784 IRECT GetHandleBounds(double value = -1.0) const;
785
786protected:
787 IBitmap mTrackBitmap;
788};
789
792 , public IBitmapBase
793{
794public:
795 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);
796 virtual ~IBTextControl() {}
797
798 void Draw(IGraphics& g) override;
799 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
800
801protected:
802 int mCharWidth, mCharHeight, mCharOffset;
803 bool mMultiLine;
804 bool mVCentre;
805};
806
809{
810public:
811 enum class EResponse {
812 Linear,
813 Log,
814 };
815
820 IBMeterControl(float x, float y, const IBitmap& bitmap, EResponse response = EResponse::Log, float lowRangeDB = -72.f, float highRangeDB = 12.f)
821 : IBitmapControl(x, y, bitmap)
822 , mResponse(response)
823 , mLowRangeDB(lowRangeDB)
824 , mHighRangeDB(highRangeDB)
825 {}
826
830 IBMeterControl(const IRECT& bounds, const IBitmap& bitmap, EResponse response = EResponse::Log, float lowRangeDB = -72.f, float highRangeDB = 12.f)
831 : IBitmapControl(bounds, bitmap)
832 , mResponse(response)
833 , mLowRangeDB(lowRangeDB)
834 , mHighRangeDB(highRangeDB)
835 {}
836
837 virtual ~IBMeterControl() {}
838 void Draw(IGraphics& g) override { DrawBitmap(g); }
839 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
840 void OnMsgFromDelegate(int msgTag, int dataSize, const void* pData) override;
841
842protected:
843 float mHighRangeDB;
844 float mLowRangeDB;
845 EResponse mResponse = EResponse::Linear;
846};
847
848END_IGRAPHICS_NAMESPACE
849END_IPLUG_NAMESPACE
850
851// These meta controls depend on the other controls
852#include "IAboutBoxControl.h"
854#include "IVNumberBoxControl.h"
855#include "IVTabbedPagesControl.h"
856
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:703
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.h:709
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:710
A bitmap knob/dial control that draws a frame from a stacked bitmap.
Definition: IControls.h:740
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:752
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.h:751
A bitmap knob/dial control that rotates an image.
Definition: IControls.h:757
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1735
A bitmap meter control, that can be used for VUMeters.
Definition: IControls.h:809
void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData) override
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate()
Definition: IControls.cpp:1758
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:820
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:830
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:839
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.h:838
A bitmap slider/fader control.
Definition: IControls.h:772
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1709
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1686
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:781
A bitmap switch control.
Definition: IControls.h:716
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:733
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:1653
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.h:732
A control to display text using a monospace bitmap font.
Definition: IControls.h:793
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1753
void OnRescale() override
Implement to do something when graphics is scaled globally (e.g.
Definition: IControls.h:799
A base interface to be combined with IControl for bitmap-based controls "IBControls",...
Definition: IControl.h:724
void AttachIControl(IControl *pControl)
Call in the constructor of your IBControl to link the IBitmapBase and IControl.
Definition: IControl.h:737
void DrawBitmap(IGraphics &g)
Draw a frame of a multi-frame bitmap based on the IControl value.
Definition: IControl.h:741
A basic control to draw a bitmap, or one frame of a stacked bitmap depending on the current value.
Definition: IControl.h:2086
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:1868
IContainerBase allows a control to nest sub controls and it clips the drawing of those subcontrols In...
Definition: IControl.h:611
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
IGraphics * GetUI()
Definition: IControl.h:472
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:565
void SetTargetRECT(const IRECT &bounds)
Set the rectangular mouse tracking target area, within the graphics context for this control.
Definition: IControl.h:328
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:1531
A base class for knob/dial controls, to handle mouse action and Sender.
Definition: IControl.h:1373
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:587
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1445
A vector knob/dial control which rotates an SVG image.
Definition: IControls.h:572
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1536
A Slider control with and SVG for track and handle.
Definition: IControls.h:675
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1565
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1571
A vector switch control which shows one of multiple SVG states.
Definition: IControls.h:658
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1553
A vector toggle switch control which shows an SVG image.
Definition: IControls.h:615
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1504
A base class for slider/fader controls, to handle mouse action and Sender.
Definition: IControl.h:1403
A base class for switch controls.
Definition: IControl.h:1879
A basic control to display some text.
Definition: IControl.h:2157
A vector button/momentary switch control.
Definition: IControls.h:54
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:539
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.cpp:1395
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1348
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1327
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:1401
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:1333
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:1379
A control to draw a rectangle around a named IControl group.
Definition: IControls.h:451
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1248
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:1257
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControls.cpp:1240
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:1294
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1284
A vector knob control drawn using graphics primitives.
Definition: IControls.h:260
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControls.cpp:747
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.h:288
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:710
bool IsHit(float x, float y) const override
Hit test the control.
Definition: IControls.cpp:726
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:720
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:695
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:704
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:681
void SetDirty(bool push, int valIdx=kNoValIdx) override
Mark the control as dirty, i.e.
Definition: IControls.cpp:737
A vector label control that can display text with a shadow.
Definition: IControls.h:45
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:237
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:498
void OnAttached() override
Called after the control has been attached, and its delegate and graphics member variable set.
Definition: IControls.h:521
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.h:508
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.h:527
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.h:516
A vector plot to display functions and waveforms.
Definition: IControls.h:403
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1159
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1203
void AddPlotFunc(const IColor &color, const IPlotFunc &func)
add a new function to the plot
Definition: IControls.cpp:1209
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:406
Groups a plot function and color.
Definition: IControls.h:411
A vector "radio buttons" switch control.
Definition: IControls.h:201
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:357
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:1018
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:1045
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:1039
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.h:365
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:367
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:936
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:995
A switch with a slide animation when clicked.
Definition: IControls.h:107
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:317
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:881
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.h:333
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:872
void SetDirty(bool push, int valIdx=kNoValIdx) override
Mark the control as dirty, i.e.
Definition: IControls.cpp:906
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:866
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:845
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:857
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:812
bool IsHit(float x, float y) const override
Hit test the control.
Definition: IControls.cpp:893
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControls.cpp:916
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:790
A vector switch control.
Definition: IControls.h:75
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:83
A vector "tab" multi switch control.
Definition: IControls.h:148
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControls.h:182
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:92
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:1431
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControl.h:1527
A vector XY Pad slider control.
Definition: IControls.h:381
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:1108
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControls.cpp:1078
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:1126
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControls.cpp:1136
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControls.cpp:1067
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:1117
A base interface to be combined with IControl for vectorial controls "IVControls",...
Definition: IControl.h:762
IRECT MakeRects(const IRECT &parent, bool hasHandle=false)
Calculate the rectangles for the various areas, depending on the style.
Definition: IControl.h:1163
virtual void DrawBackground(IGraphics &g, const IRECT &rect)
Draw the IVControl background (usually transparent)
Definition: IControl.h:881
virtual void DrawValue(IGraphics &g, bool mouseOver)
Draw the IVControl value text.
Definition: IControl.h:904
void AttachIControl(IControl *pControl, const char *label)
Call in the constructor of your IVControl to link the IVectorBase and IControl.
Definition: IControl.h:780
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:1025
virtual void DrawLabel(IGraphics &g)
Draw the IVControl label text.
Definition: IControl.h:894
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.