iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IControl.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
18#include <cstring>
19#include <cstdlib>
20#include <vector>
21#include <unordered_map>
22
23#if defined VST3_API || defined VST3C_API
24#undef stricmp
25#undef strnicmp
26#include "pluginterfaces/vst/ivstcontextmenu.h"
27#include "base/source/fobject.h"
28#endif
29
30#include "IPlugPlatform.h"
31
32#include "wdlstring.h"
33#include "ptrlist.h"
34
35#include "IGraphics.h"
36
37BEGIN_IPLUG_NAMESPACE
38BEGIN_IGRAPHICS_NAMESPACE
39
40class IContainerBase;
41
45#if defined VST3_API || defined VST3C_API
46: public Steinberg::Vst::IContextMenuTarget
47, public Steinberg::FObject
48#endif
49{
50public:
58 IControl(const IRECT& bounds, int paramIdx = kNoParameter, IActionFunction actionFunc = nullptr);
59
67 IControl(const IRECT& bounds, const std::initializer_list<int>& params, IActionFunction actionFunc = nullptr);
68
75 IControl(const IRECT& bounds, IActionFunction actionFunc);
76
77 IControl(const IControl&) = delete;
78 void operator=(const IControl&) = delete;
79
81 virtual ~IControl() {}
82
87 virtual void OnMouseDown(float x, float y, const IMouseMod& mod);
88
93 virtual void OnMouseUp(float x, float y, const IMouseMod& mod) {}
94
101 virtual void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) {}
102
107 virtual void OnMouseDblClick(float x, float y, const IMouseMod& mod);
108
114 virtual void OnMouseWheel(float x, float y, const IMouseMod& mod, float d) {};
115
120 virtual bool OnKeyDown(float x, float y, const IKeyPress& key) { return false; }
121
126 virtual bool OnKeyUp(float x, float y, const IKeyPress& key) { return false; }
127
132 virtual void OnMouseOver(float x, float y, const IMouseMod& mod);
133
135 virtual void OnMouseOut();
136
141 virtual void OnTouchCancelled(float x, float y, const IMouseMod& mod) {}
142
144 virtual void OnDrop(const char* str) {};
145
147 virtual void OnDropMultiple(const std::vector<const char*>& paths) { OnDrop(paths[0]); }
148
150 virtual void OnRescale() {}
151
153 virtual void OnResize() {}
154
156 virtual void OnInit() {}
157
159 virtual void OnAttached() {}
160
162 virtual void OnMsgFromDelegate(int msgTag, int dataSize, const void* pData) {};
163
165 virtual void OnMidi(const IMidiMsg& msg) {};
166
168 virtual bool OnGesture(const IGestureInfo& info);
169
171 virtual void CreateContextMenu(IPopupMenu& contextMenu) {}
172
176 virtual void OnPopupMenuSelection(IPopupMenu* pSelectedMenu, int valIdx);
177
181 virtual void OnDeleteFromPopupMenu(IPopupMenu* pMenu, int itemIdx) {}
182
186 virtual void OnTextEntryCompletion(const char* str, int valIdx) {}
187
189 virtual void OnContextSelection(int itemSelected) {}
190
193 virtual void Draw(IGraphics& g) = 0;
194
197 virtual void DrawPTHighlight(IGraphics& g);
198
201 void PromptUserInput(int valIdx = 0);
202
206 void PromptUserInput(const IRECT& bounds, int valIdx = 0);
207
211 inline IControl* SetActionFunction(IActionFunction actionFunc) { mActionFunc = actionFunc; return this; }
212
216 inline IControl* SetAnimationEndActionFunction(IActionFunction actionFunc) { mAnimationEndActionFunc = actionFunc; return this; }
217
221 inline IControl* SetTooltip(const char* str) { mTooltip.Set(str); return this; }
222
224 inline const char* GetTooltip() const { return mTooltip.Get(); }
225
230 int GetParamIdx(int valIdx = 0) const;
231
236 virtual void SetParamIdx(int paramIdx, int valIdx = 0);
237
241 int LinkedToParam(int paramIdx) const;
242
244 int NVals() const { return (int) mVals.size(); }
245
250 virtual int GetValIdxForPos(float x, float y) const { return mVals.size() == 1 ? 0 : kNoValIdx; }
251
254 const IParam* GetParam(int valIdx = 0) const;
255
260 virtual void SetValueFromDelegate(double value, int valIdx = 0);
261
266 virtual void SetValueFromUserInput(double value, int valIdx = 0);
267
271 virtual void SetValueToDefault(int valIdx = kNoValIdx);
272
276 virtual void SetValue(double value, int valIdx = 0);
277
281 double GetValue(int valIdx = 0) const;
282
285 void SetGroup(const char* groupName) { mGroup.Set(groupName); }
286
289 const char* GetGroup() const { return mGroup.Get(); }
290
293 const IText& GetText() const { return mText; }
294
297 virtual void SetText(const IText& txt) { mText = txt; }
298
301 void SetBlend(const IBlend& blend) { mBlend = blend; }
302
304 IBlend GetBlend() const { return mBlend; }
305
308 int GetTextEntryLength() const { return mTextEntryLength; }
309
312 void SetTextEntryLength(int len) { mTextEntryLength = len; }
313
316 const IRECT& GetRECT() const { return mRECT; }
317
320 void SetRECT(const IRECT& bounds) { mRECT = bounds; mMouseIsOver = false; OnResize(); }
321
324 const IRECT& GetTargetRECT() const { return mTargetRECT; } // The mouse target area (default = draw area).
325
328 void SetTargetRECT(const IRECT& bounds) { mTargetRECT = bounds; mMouseIsOver = false; }
329
332 void SetTargetAndDrawRECTs(const IRECT& bounds) { mRECT = mTargetRECT = bounds; mMouseIsOver = false; OnResize(); }
333
337 virtual void SetPosition(float x, float y);
338
342 virtual void SetSize(float w, float h);
343
347 void SetPTParameterHighlight(bool isHighlighted, int color);
348
353 bool GetMouseDblAsSingleClick() const { return mDblAsSingleClick; }
354
357 virtual void Hide(bool hide);
358
360 bool IsHidden() const { return mHide; }
361
364 virtual void SetDisabled(bool disable);
365
367 bool IsDisabled() const { return mDisabled; }
368
371 void SetMouseOverWhenDisabled(bool allow) { mMouseOverWhenDisabled = allow; }
372
375 void SetMouseEventsWhenDisabled(bool allow) { mMouseEventsWhenDisabled = allow; }
376
378 bool GetMouseOverWhenDisabled() const { return mMouseOverWhenDisabled; }
379
381 bool GetMouseEventsWhenDisabled() const { return mMouseEventsWhenDisabled; }
382
384 bool GetIgnoreMouse() const { return mIgnoreMouse; }
385
388 virtual void SetIgnoreMouse(bool ignore) { mIgnoreMouse = ignore; }
389
391 bool GetPromptShowsParamLabel() const { return mPromptShowsParamLabel; }
392
394 void SetPromptShowsParamLabel(bool enable) { mPromptShowsParamLabel = enable; }
395
400 virtual bool IsHit(float x, float y) const { return mTargetRECT.Contains(x, y); }
401
406 virtual void SetDirty(bool triggerAction = true, int valIdx = kNoValIdx);
407
408 /* Set the control clean, i.e. Called by IGraphics draw loop after control has been drawn */
409 virtual void SetClean() { mDirty = false; }
410
411 /* Called at each display refresh by the IGraphics draw loop, triggers the control's AnimationFunc if it is set */
412 void Animate();
413
416 virtual bool IsDirty();
417
420 void DisablePrompt(bool disable) { mDisablePrompt = disable; }
421
423 virtual void OnGUIIdle() {}
424
426 int GetTag() const { return GetUI()->GetControlTag(this); }
427
429 void SetWantsMidi(bool enable = true) { mWantsMidi = enable; }
430
432 bool GetWantsMidi() const { return mWantsMidi; }
433
435 void SetWantsMultiTouch(bool enable = true) { mWantsMultiTouch = enable; }
436
438 bool GetWantsMultiTouch() const { return mWantsMultiTouch; }
439
443 IControl* AttachGestureRecognizer(EGestureType type, IGestureFunc func);
444
446 virtual bool GetWantsGestures() const { return mGestureFuncs.size() > 0 && !mAnimationFunc; }
447
449 EGestureType GetLastGesture() const { return mLastGesture; }
450
454 IGEditorDelegate* GetDelegate() { return mDelegate; }
455
458 {
459 mDelegate = &dlg;
460 mGraphics = dlg.GetUI();
461 OnInit();
462 OnResize();
463 OnRescale();
464 }
465
467 IContainerBase* GetParent() const { return mParent; }
468
469 void SetParent(IContainerBase* pParent) { mParent = pParent; }
470
472 IGraphics* GetUI() { return mGraphics; }
473
475 const IGraphics* GetUI() const { return mGraphics; }
476
479 bool GetMouseIsOver() const { return mMouseIsOver; }
480
487 virtual void SnapToMouse(float x, float y, EDirection direction, const IRECT& bounds, int valIdx = -1, double minClip = 0., double maxClip = 1.);
488
489 /* if you override this you must call the base implementation, to free mAnimationFunc */
490 virtual void OnEndAnimation();
491
493 void StartAnimation(int duration);
494
497 void SetAnimation(IAnimationFunction func) { mAnimationFunc = func;}
498
502 void SetAnimation(IAnimationFunction func, int duration) { mAnimationFunc = func; StartAnimation(duration); }
503
505 IAnimationFunction GetAnimationFunction() { return mAnimationFunc; }
506
508 IActionFunction GetActionFunction() { return mActionFunc; }
509
511 double GetAnimationProgress() const;
512
514 Milliseconds GetAnimationDuration() const { return mAnimationDuration; }
515
517 template <class T>
518 T* As() { return dynamic_cast<T*>(this); }
519
520#if defined VST3_API || defined VST3C_API
521 Steinberg::tresult PLUGIN_API executeMenuItem (Steinberg::int32 tag) override { OnContextSelection(tag); return Steinberg::kResultOk; }
522#endif
523
524#pragma mark - IControl Member variables
525protected:
526
531 template<typename T, typename... Args>
532 void ForValIdx(int valIdx, T func, Args... args)
533 {
534 if (valIdx > kNoValIdx)
535 func(valIdx, args...);
536 else
537 {
538 const int nVals = NVals();
539 for (int v = 0; v < nVals; v++)
540 func(v, args...);
541 }
542 }
543
544 IRECT mRECT;
545 IRECT mTargetRECT;
546
548 WDL_String mGroup;
549
550 IText mText;
551 IBlend mBlend;
552 int mTextEntryLength = DEFAULT_TEXT_ENTRY_LEN;
553 bool mDirty = true;
554 bool mHide = false;
555 bool mDisabled = false;
556 bool mDisablePrompt = true;
557 bool mDblAsSingleClick = false;
558 bool mMouseOverWhenDisabled = false;
559 bool mMouseEventsWhenDisabled = false;
560 bool mIgnoreMouse = false;
561 bool mWantsMidi = false;
562 bool mWantsMultiTouch = false;
563 bool mPromptShowsParamLabel = false;
565 bool mMouseIsOver = false;
566 WDL_String mTooltip;
567
568 IColor mPTHighlightColor = COLOR_RED;
569 bool mPTisHighlighted = false;
570
571 void SetNVals(int nVals)
572 {
573 assert(nVals > 0);
574 mVals.resize(nVals);
575 }
576
577#if defined VST3_API || defined VST3C_API
578 OBJ_METHODS(IControl, FObject)
579 DEFINE_INTERFACES
580 DEF_INTERFACE (IContextMenuTarget)
581 END_DEFINE_INTERFACES (FObject)
582 REFCOUNT_METHODS(FObject)
583#endif
584
585private:
586 IContainerBase* mParent = nullptr;
587 IGEditorDelegate* mDelegate = nullptr;
588 IGraphics* mGraphics = nullptr;
589 IActionFunction mActionFunc = nullptr;
590 IActionFunction mAnimationEndActionFunc = nullptr;
591 IAnimationFunction mAnimationFunc = nullptr;
592 TimePoint mAnimationStartTime;
593 Milliseconds mAnimationDuration;
594 std::vector<ParamTuple> mVals { {kNoParameter, 0.} };
595 std::unordered_map<EGestureType, IGestureFunc> mGestureFuncs;
596 EGestureType mLastGesture = EGestureType::Unknown;
597};
598
599#pragma mark - Base Controls
600
611{
612public:
613 using AttachFunc = std::function<void(IContainerBase* pContainer, const IRECT& bounds)>;
614 using ResizeFunc = std::function<void(IContainerBase* pContainer, const IRECT& bounds)>;
615
616 IContainerBase(const IRECT& bounds, int paramIdx = kNoParameter, IActionFunction actionFunc = nullptr)
617 : IControl(bounds, paramIdx, actionFunc)
618 {}
619
620 IContainerBase(const IRECT& bounds, const std::initializer_list<int>& params, IActionFunction actionFunc = nullptr)
621 : IControl(bounds, params, actionFunc)
622 {}
623
624 IContainerBase(const IRECT& bounds, IActionFunction actionFunc)
625 : IControl(bounds, actionFunc)
626 {}
627
628 IContainerBase(const IRECT& bounds, AttachFunc attachFunc, ResizeFunc resizeFunc)
629 : IControl(bounds)
630 , mAttachFunc(attachFunc)
631 , mResizeFunc(resizeFunc)
632 {
633 mIgnoreMouse = true;
634 }
635
636 void SetAttachFunc(AttachFunc attachFunc)
637 {
638 mAttachFunc = attachFunc;
639 }
640
641 void SetResizeFunc(ResizeFunc resizeFunc)
642 {
643 mResizeFunc = resizeFunc;
644 }
645
646 virtual void Draw(IGraphics& g) override
647 {
648 /* NO-OP */
649 }
650
651 virtual ~IContainerBase()
652 {
653 mChildren.Empty(false);
654 }
655
656 virtual void OnAttached() override
657 {
658 if (mAttachFunc)
659 mAttachFunc(this, mRECT);
660
661 OnResize();
662 }
663
664 virtual void OnResize() override
665 {
666 if (mResizeFunc && mChildren.GetSize())
667 mResizeFunc(this, mRECT);
668 }
669
670 void SetDisabled(bool disable) override
671 {
672 ForAllChildrenFunc([disable](int childIdx, IControl* pChild) {
673 pChild->SetDisabled(disable);
674 });
675
676 IControl::SetDisabled(disable);
677 }
678
679 void Hide(bool hide) override
680 {
681 ForAllChildrenFunc([hide](int childIdx, IControl* pChild) {
682 pChild->Hide(hide);
683 });
684
685 IControl::Hide(hide);
686 }
687
688 IControl* AddChildControl(IControl* pControl, int ctrlTag = kNoTag, const char* group = "")
689 {
690 pControl->SetParent(this);
691 return mChildren.Add(GetUI()->AttachControl(pControl, ctrlTag, group));
692 }
693
694 void RemoveChildControl(IControl* pControl)
695 {
696 pControl->SetParent(nullptr);
697 mChildren.DeletePtr(pControl, false);
698 GetUI()->RemoveControl(pControl);
699 }
700
701 IControl* GetChild(int idx)
702 {
703 return mChildren.Get(idx);
704 }
705
706 int NChildren() const { return mChildren.GetSize(); }
707
708 void ForAllChildrenFunc(std::function<void(int childIdx, IControl* pControl)> func)
709 {
710 for (int i=0; i<mChildren.GetSize(); i++)
711 {
712 func(i, mChildren.Get(i));
713 }
714 }
715
716protected:
717 AttachFunc mAttachFunc = nullptr;
718 ResizeFunc mResizeFunc = nullptr;
719 WDL_PtrList<IControl> mChildren;
720};
721
724{
725public:
728 IBitmapBase(const IBitmap& bitmap)
729 : mBitmap(bitmap)
730 {
731 }
732
733 virtual ~IBitmapBase() {}
734
737 void AttachIControl(IControl* pControl) { mControl = pControl; }
738
742 {
743 int i = 1;
744
745 if (mBitmap.N() > 1)
746 {
747 i = 1 + int(0.5 + mControl->GetValue() * static_cast<double>(mBitmap.N() - 1));
748 i = Clip(i, 1, mBitmap.N());
749 }
750 IBlend blend = mControl->GetBlend();
751 g.DrawBitmap(mBitmap, mControl->GetRECT().GetCentredInside(IRECT(0, 0, mBitmap)), i, &blend);
752 }
753
754protected:
755 IBitmap mBitmap;
756 IControl* mControl = nullptr;
757};
758
762{
763public:
768 IVectorBase(const IVStyle& style, bool labelInWidget = false, bool valueInWidget = false)
769 : mLabelInWidget(labelInWidget)
770 , mValueInWidget(valueInWidget)
771 {
772 SetStyle(style);
773 }
774
775 virtual ~IVectorBase() {}
776
780 void AttachIControl(IControl* pControl, const char* label)
781 {
782 mControl = pControl;
783 mLabelStr.Set(label);
784 }
785
787 virtual void OnStyleChanged() { /* NO-OP */ }
788
792 void SetColor(EVColor colorIdx, const IColor& color)
793 {
794 mStyle.colorSpec.mColors[static_cast<int>(colorIdx)] = color;
795 mControl->SetDirty(false);
796 }
797
800 void SetColors(const IVColorSpec& spec)
801 {
802 mStyle.colorSpec = spec;
803 }
804
806 const IColor& GetColor(EVColor color) const
807 {
808 return mStyle.colorSpec.GetColor(color);
809 }
810
811 void SetLabelStr(const char* label) { mLabelStr.Set(label); mControl->SetDirty(false); OnStyleChanged(); }
812 const char* GetLabelStr() const { return mLabelStr.Get(); }
813 void SetValueStr(const char* value) { mValueStr.Set(value); mControl->SetDirty(false); OnStyleChanged(); }
814 void SetWidgetFrac(float frac) { mStyle.widgetFrac = Clip(frac, 0.f, 1.f); mControl->OnResize(); mControl->SetDirty(false); OnStyleChanged(); }
815 void SetAngle(float angle) { mStyle.angle = Clip(angle, 0.f, 360.f); mControl->SetDirty(false); OnStyleChanged(); }
816 void SetShowLabel(bool show) { mStyle.showLabel = show; mControl->OnResize(); mControl->SetDirty(false); OnStyleChanged(); }
817 void SetShowValue(bool show) { mStyle.showValue = show; mControl->OnResize(); mControl->SetDirty(false); OnStyleChanged(); }
818 void SetRoundness(float roundness) { mStyle.roundness = Clip(roundness, 0.f, 1.f); mControl->SetDirty(false); OnStyleChanged(); }
819 void SetDrawFrame(bool draw) { mStyle.drawFrame = draw; mControl->SetDirty(false); OnStyleChanged(); }
820 void SetDrawShadows(bool draw) { mStyle.drawShadows = draw; mControl->SetDirty(false); OnStyleChanged(); }
821 void SetEmboss(bool draw) { mStyle.emboss = draw; mControl->SetDirty(false); OnStyleChanged(); }
822 void SetShadowOffset(float offset) { mStyle.shadowOffset = offset; mControl->SetDirty(false); OnStyleChanged(); }
823 void SetFrameThickness(float thickness) { mStyle.frameThickness = thickness; mControl->SetDirty(false); OnStyleChanged(); }
824 void SetSplashRadius(float radius) { mSplashRadius = radius * mMaxSplashRadius; OnStyleChanged(); }
825 void SetSplashPoint(float x, float y) { mSplashPoint.x = x; mSplashPoint.y = y; OnStyleChanged(); }
826 void SetShape(EVShape shape) { mShape = shape; mControl->SetDirty(false); OnStyleChanged(); }
827
830 virtual void SetStyle(const IVStyle& style)
831 {
832 mStyle = style;
833 SetColors(style.colorSpec);
835 }
836
839 IVStyle GetStyle() const { return mStyle; }
840
845 {
846 if (mStyle.drawFrame)
847 handleBounds.Pad(- 0.5f * mStyle.frameThickness);
848
849 if (mStyle.drawShadows)
850 handleBounds.Offset(mStyle.shadowOffset, 0, -mStyle.shadowOffset, -mStyle.shadowOffset);
851
852 return handleBounds;
853 }
854
858 float GetRoundedCornerRadius(const IRECT& bounds) const
859 {
860 if (bounds.W() < bounds.H())
861 return mStyle.roundness * (bounds.W() / 2.f);
862 else
863 return mStyle.roundness * (bounds.H() / 2.f);
864 }
865
866 IRECT GetWidgetBounds() const { return mWidgetBounds; }
867 IRECT GetLabelBounds() const { return mLabelBounds; }
868 IRECT GetValueBounds() const { return mValueBounds; }
869
873 void DrawSplash(IGraphics& g, const IRECT& clipRegion = IRECT())
874 {
875 g.PathClipRegion(clipRegion);
876 g.FillCircle(GetColor(kHL), mSplashPoint.x, mSplashPoint.y, mSplashRadius);
878 }
879
881 virtual void DrawBackground(IGraphics& g, const IRECT& rect)
882 {
883 IBlend blend = mControl->GetBlend();
884 g.FillRect(GetColor(kBG), rect, &blend);
885 }
886
888 virtual void DrawWidget(IGraphics& g)
889 {
890 // NO-OP
891 }
892
894 virtual void DrawLabel(IGraphics& g)
895 {
896 if (mLabelBounds.H() && mStyle.showLabel)
897 {
898 IBlend blend = mControl->GetBlend();
899 g.DrawText(mStyle.labelText, mLabelStr.Get(), mLabelBounds, &blend);
900 }
901 }
902
904 virtual void DrawValue(IGraphics& g, bool mouseOver)
905 {
906 if(mouseOver)
907 g.FillRect(COLOR_TRANSLUCENT, mValueBounds);
908
909 if (mStyle.showValue)
910 {
911 IBlend blend = mControl->GetBlend();
912 g.DrawText(mStyle.valueText, mValueStr.Get(), mValueBounds, &blend);
913 }
914 }
915
923 virtual void DrawPressableShape(IGraphics& g, EVShape shape, const IRECT& bounds, bool pressed, bool mouseOver, bool disabled)
924 {
925 switch (shape)
926 {
927 case EVShape::Ellipse:
928 DrawPressableEllipse(g, bounds, pressed, mouseOver, disabled);
929 break;
930 case EVShape::Rectangle:
931 DrawPressableRectangle(g, bounds, pressed, mouseOver, disabled);
932 break;
933 case EVShape::Triangle:
934 DrawPressableTriangle(g, bounds, pressed, mouseOver, mStyle.angle, disabled);
935 break;
936 case EVShape::EndsRounded:
937 DrawPressableRectangle(g, bounds, pressed, mouseOver, disabled, true, true, false, false);
938 break;
939 case EVShape::AllRounded:
940 DrawPressableRectangle(g, bounds, pressed, mouseOver, disabled, true, true, true, true);
941 break;
942 default:
943 break;
944 }
945 }
946
953 void DrawPressableEllipse(IGraphics& g, const IRECT& bounds, bool pressed, bool mouseOver, bool disabled)
954 {
955 IRECT handleBounds = bounds;
956 IRECT centreBounds = bounds.GetPadded(-mStyle.shadowOffset);
957 IRECT shadowBounds = bounds.GetTranslated(mStyle.shadowOffset, mStyle.shadowOffset);
958 const IBlend blend = mControl->GetBlend();
959 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
960
961 if(!pressed && !disabled && mStyle.drawShadows)
962 g.FillEllipse(GetColor(kSH), shadowBounds);
963
964 if (pressed)
965 {
966 if (mStyle.emboss)
967 {
968 shadowBounds.ReduceFromRight(mStyle.shadowOffset);
969 shadowBounds.ReduceFromBottom(mStyle.shadowOffset);
970 // Fill background with pressed color and shade it
971 g.FillEllipse(GetColor(kPR), bounds, &blend);
972 g.FillEllipse(GetColor(kSH), bounds, &blend);
973
974 // Inverse shading for recessed look - shadowBounds = inner shadow
975 g.FillEllipse(GetColor(kFG).WithContrast(contrast), shadowBounds/*, &blend*/);
976
977 // Fill in center with pressed color
978 g.FillEllipse(GetColor(kPR).WithContrast(contrast), centreBounds/*, &blend*/);
979 }
980 else
981 g.FillEllipse(GetColor(kPR).WithContrast(contrast), handleBounds/*, &blend*/);
982 }
983 else
984 {
985 // Embossed style unpressed
986 if (mStyle.emboss)
987 {
988 // Positive light TODO: use thes kPR color for now, maybe change the name?
989 g.FillEllipse(GetColor(kPR).WithContrast(contrast), bounds/*, &blend*/);
990
991 // Negative light TODO: clip this?
992 g.FillEllipse(GetColor(kSH).WithContrast(contrast), shadowBounds/*, &blend*/);
993
994 // Fill in foreground
995 g.FillEllipse(GetColor(kFG).WithContrast(contrast), centreBounds/*, &blend*/);
996
997 // Shade when hovered
998 if (mouseOver)
999 g.FillEllipse(GetColor(kHL), centreBounds, &blend);
1000 }
1001 else
1002 {
1003 g.FillEllipse(GetColor(kFG).WithContrast(contrast), handleBounds/*, &blend*/);
1004
1005 // Shade when hovered
1006 if (mouseOver)
1007 g.FillEllipse(GetColor(kHL), handleBounds, &blend);
1008 }
1009 }
1010
1011 if (pressed && mControl->GetAnimationFunction())
1012 DrawSplash(g, handleBounds);
1013
1014 if (mStyle.drawFrame)
1015 g.DrawEllipse(GetColor(kFR), handleBounds, &blend, mStyle.frameThickness);
1016 }
1017
1025 IRECT DrawPressableRectangle(IGraphics&g, const IRECT& bounds, bool pressed, bool mouseOver, bool disabled,
1026 bool rtl = true, bool rtr = true, bool rbl = true, bool rbr = true)
1027 {
1028 IRECT handleBounds = GetAdjustedHandleBounds(bounds);
1029 IRECT centreBounds = handleBounds.GetPadded(-mStyle.shadowOffset);
1030 IRECT shadowBounds = handleBounds.GetTranslated(mStyle.shadowOffset, mStyle.shadowOffset);
1031 const IBlend blend = mControl->GetBlend();
1032 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1033 float cR = GetRoundedCornerRadius(handleBounds);
1034
1035 const float tlr = rtl ? cR : 0.f;
1036 const float trr = rtr ? cR : 0.f;
1037 const float blr = rbl ? cR : 0.f;
1038 const float brr = rbr ? cR : 0.f;
1039
1040 if (pressed)
1041 {
1042 shadowBounds.ReduceFromRight(mStyle.shadowOffset);
1043 shadowBounds.ReduceFromBottom(mStyle.shadowOffset);
1044
1045 if (mStyle.emboss)
1046 {
1047 // Fill background with pressed color and shade it
1048 g.FillRoundRect(GetColor(kPR), handleBounds, tlr, trr, blr, brr, &blend);
1049 g.FillRoundRect(GetColor(kSH), handleBounds, tlr, trr, blr, brr, &blend);
1050
1051 // Inverse shading for recessed look - shadowBounds = inner shadow
1052 g.FillRoundRect(GetColor(kFG).WithContrast(contrast), shadowBounds, tlr, trr, blr, brr/*, &blend*/);
1053
1054 // Fill in center with pressed color
1055 g.FillRoundRect(GetColor(kPR), centreBounds, tlr, trr, blr, brr, &blend);
1056 }
1057 else
1058 {
1059 g.FillRoundRect(GetColor(kPR).WithContrast(contrast), handleBounds, tlr, trr, blr, brr/*, &blend*/);
1060 }
1061 }
1062 else
1063 {
1064 // outer shadow
1065 if (mStyle.drawShadows)
1066 g.FillRoundRect(GetColor(kSH), shadowBounds, tlr, trr, blr, brr, &blend);
1067
1068 // Embossed style unpressed
1069 if (mStyle.emboss)
1070 {
1071 // Positive light TODO: use thes kPR color for now, maybe change the name?
1072 g.FillRoundRect(GetColor(kPR).WithContrast(contrast), handleBounds, tlr, trr, blr, brr/*, &blend*/);
1073
1074 // Negative light TODO: clip this?
1075 g.FillRoundRect(GetColor(kSH).WithContrast(contrast), shadowBounds, tlr, trr, blr, brr/*, &blend*/);
1076
1077 // Fill in foreground
1078 g.FillRoundRect(GetColor(kFG).WithContrast(contrast), centreBounds, tlr, trr, blr, brr/*, &blend*/);
1079
1080 // Shade when hovered
1081 if (mouseOver)
1082 g.FillRoundRect(GetColor(kHL), centreBounds, tlr, trr, blr, brr, &blend);
1083 }
1084 else
1085 {
1086 g.FillRoundRect(GetColor(kFG).WithContrast(contrast), handleBounds, tlr, trr, blr, brr/*, &blend*/);
1087
1088 // Shade when hovered
1089 if (mouseOver)
1090 g.FillRoundRect(GetColor(kHL), handleBounds, tlr, trr, blr, brr, &blend);
1091 }
1092 }
1093
1094 if (pressed && mControl->GetAnimationFunction())
1095 DrawSplash(g, handleBounds);
1096
1097 if (mStyle.drawFrame)
1098 g.DrawRoundRect(GetColor(kFR), handleBounds, tlr, trr, blr, brr, &blend, mStyle.frameThickness);
1099
1100 return handleBounds;
1101 }
1102
1108 IRECT DrawPressableTriangle(IGraphics&g, const IRECT& bounds, bool pressed, bool mouseOver, float angle, bool disabled)
1109 {
1110 float x1, x2, x3, y1, y2, y3;
1111
1112 float theta = DegToRad(angle);
1113
1114 IRECT handleBounds = GetAdjustedHandleBounds(bounds);
1115
1116 // Center bounds around origin for rotation
1117 float xT = handleBounds.L + handleBounds.W() * 0.5f;
1118 float yT = handleBounds.T + handleBounds.H() * 0.5f;
1119 IRECT centered = handleBounds.GetTranslated(-xT, -yT);
1120
1121 // Do rotation and translate points back into view space
1122 float c = cosf(theta);
1123 float s = sinf(theta);
1124 x1 = centered.L * c - centered.B * s + xT;
1125 y1 = centered.L * s + centered.B * c + yT;
1126 x2 = centered.MW() * c - centered.T * s + xT;
1127 y2 = centered.MW() * s + centered.T * c + yT;
1128 x3 = centered.R * c - centered.B * s + xT;
1129 y3 = centered.R * s + centered.B * c + yT;
1130
1131 const IBlend blend = mControl->GetBlend();
1132 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1133
1134 if (pressed)
1135 g.FillTriangle(GetColor(kPR).WithContrast(contrast), x1, y1, x2, y2, x3, y3/*, &blend*/);
1136 else
1137 {
1138 //outer shadow
1139 if (mStyle.drawShadows)
1140 g.FillTriangle(GetColor(kSH), x1 + mStyle.shadowOffset, y1 + mStyle.shadowOffset,
1141 x2 + mStyle.shadowOffset, y2 + mStyle.shadowOffset,
1142 x3 + mStyle.shadowOffset, y3 + mStyle.shadowOffset, &blend);
1143
1144 g.FillTriangle(GetColor(kFG).WithContrast(contrast), x1, y1, x2, y2, x3, y3/*, &blend*/);
1145 }
1146
1147 if (mouseOver)
1148 g.FillTriangle(GetColor(kHL), x1, y1, x2, y2, x3, y3, &blend);
1149
1150 if(pressed && mControl->GetAnimationFunction())
1151 DrawSplash(g);
1152
1153 if (mStyle.drawFrame)
1154 g.DrawTriangle(GetColor(kFR), x1, y1, x2, y2, x3, y3, &blend, mStyle.frameThickness);
1155
1156 return handleBounds;
1157 }
1158
1163 IRECT MakeRects(const IRECT& parent, bool hasHandle = false)
1164 {
1165 IRECT clickableArea = parent;
1166
1167 if(!mLabelInWidget)
1168 {
1169 if(mStyle.showLabel && CStringHasContents(mLabelStr.Get()))
1170 {
1171 IRECT textRect;
1172 mControl->GetUI()->MeasureText(mStyle.labelText, mLabelStr.Get(), textRect);
1173
1174 switch (mStyle.labelOrientation)
1175 {
1176 case EOrientation::North:
1177 mLabelBounds = parent.GetFromTop(textRect.H()).GetCentredInside(textRect.W(), textRect.H());
1178 break;
1179 case EOrientation::East:
1180 mLabelBounds = parent.GetFromRight(textRect.W()).GetCentredInside(textRect.W(), textRect.H());
1181 break;
1182 case EOrientation::South:
1183 mLabelBounds = parent.GetFromBottom(textRect.H()).GetCentredInside(textRect.W(), textRect.H());
1184 break;
1185 case EOrientation::West:
1186 mLabelBounds = parent.GetFromLeft(textRect.W()).GetCentredInside(textRect.W(), textRect.H());
1187 break;
1188 }
1189 }
1190 else
1191 mLabelBounds = IRECT();
1192
1193 if (!mLabelBounds.Empty())
1194 {
1195 switch (mStyle.labelOrientation)
1196 {
1197 case EOrientation::North:
1198 clickableArea = parent.GetReducedFromTop(mLabelBounds.H());
1199 break;
1200 case EOrientation::East:
1201 clickableArea = parent.GetReducedFromRight(mLabelBounds.W());
1202 break;
1203 case EOrientation::South:
1204 clickableArea = parent.GetReducedFromBottom(mLabelBounds.H());
1205 break;
1206 case EOrientation::West:
1207 clickableArea = parent.GetReducedFromLeft(mLabelBounds.W());
1208 break;
1209 }
1210 }
1211 }
1212
1213 if (mStyle.showValue && !mValueInWidget)
1214 {
1215 IRECT textRect;
1216
1217 if(CStringHasContents(mValueStr.Get()))
1218 mControl->GetUI()->MeasureText(mStyle.valueText, mValueStr.Get(), textRect);
1219
1220 const float valueDisplayWidth = textRect.W() * mValueDisplayFrac;
1221
1222 switch (mStyle.valueText.mVAlign)
1223 {
1224 case EVAlign::Middle:
1225 mValueBounds = clickableArea.GetMidVPadded(textRect.H()/2.f).GetMidHPadded(valueDisplayWidth);
1226 mWidgetBounds = clickableArea.GetScaledAboutCentre(mStyle.widgetFrac);
1227 break;
1228 case EVAlign::Bottom:
1229 {
1230 mValueBounds = clickableArea.GetFromBottom(textRect.H()).GetMidHPadded(valueDisplayWidth);
1231 mWidgetBounds = clickableArea.GetReducedFromBottom(textRect.H()).GetScaledAboutCentre(mStyle.widgetFrac);
1232 break;
1233 }
1234 case EVAlign::Top:
1235 mValueBounds = clickableArea.GetFromTop(textRect.H()).GetMidHPadded(valueDisplayWidth);
1236 mWidgetBounds = clickableArea.GetReducedFromTop(textRect.H()).GetScaledAboutCentre(mStyle.widgetFrac);
1237 break;
1238 default:
1239 break;
1240 }
1241 }
1242 else
1243 {
1244 mWidgetBounds = clickableArea.GetScaledAboutCentre(mStyle.widgetFrac);
1245 }
1246
1247 if(hasHandle)
1248 mWidgetBounds = GetAdjustedHandleBounds(clickableArea).GetScaledAboutCentre(mStyle.widgetFrac);
1249
1250 if(mLabelInWidget)
1251 mLabelBounds = mWidgetBounds;
1252
1253 if(mValueInWidget)
1254 mValueBounds = mWidgetBounds;
1255
1256 return clickableArea;
1257 }
1258
1259protected:
1260 IControl* mControl = nullptr;
1261 IVStyle mStyle; // IVStyle that defines certain common properties of an IVControl
1262 bool mLabelInWidget = false; // Should the Label text be displayed inside the widget
1263 bool mValueInWidget = false; // Should the Value text be displayed inside the widget
1264 float mSplashRadius = 0.f; // Modified during the default SplashClickAnimationFunc to specify the radius of the splash
1265 IVec2 mSplashPoint = {0.f, 0.f}; // Set at the start of the SplashClickActionFunc to set the position of the splash
1266 float mMaxSplashRadius = 50.f;
1267 float mTrackSize = 2.f;
1268 float mValueDisplayFrac = 0.66f; // the fraction of the control width for the text entry
1269 IRECT mWidgetBounds; // The knob/slider/button
1270 IRECT mLabelBounds; // A piece of text above the control
1271 IRECT mValueBounds; // Text below the contol, usually displaying the value of a parameter
1272 WDL_String mLabelStr;
1273 WDL_String mValueStr;
1274 EVShape mShape = EVShape::Rectangle;
1275};
1276
1279{
1280public:
1282 {
1283 int index = 0;
1284 float x = 0.f;
1285 float y = 0.f;
1286 float sx = 0.f;
1287 float sy = 0.f;
1288 float radius = 1.f;
1289 TimePoint startTime;
1290
1291 TrackedTouch(int index, float x, float y, float radius, TimePoint time)
1292 : index(index), x(x), y(y), sx(x), sy(y), radius(radius), startTime(time)
1293 {}
1294
1295 TrackedTouch()
1296 {}
1297 };
1298
1299 virtual ~IMultiTouchControlBase() {}
1300
1301 virtual void AddTouch(ITouchID touchID, float x, float y, float radius)
1302 {
1303 int touchIndex = 0;
1304 for (int i = 0; i < MAX_TOUCHES; i++)
1305 {
1306 if (mTouchStatus[i] == false)
1307 {
1308 touchIndex = i;
1309 mTouchStatus[i] = true;
1310 break;
1311 }
1312 }
1313
1314 if(NTrackedTouches() < MAX_TOUCHES)
1315 mTrackedTouches.insert(std::make_pair(touchID, TrackedTouch(touchIndex, x, y, radius, std::chrono::high_resolution_clock::now())));
1316 }
1317
1318 virtual void ReleaseTouch(ITouchID touchID)
1319 {
1320 mTouchStatus[GetTouchWithIdentifier(touchID)->index] = false;
1321 mTrackedTouches.erase(touchID);
1322 }
1323
1324 virtual void UpdateTouch(ITouchID touchID, float x, float y, float radius)
1325 {
1326 mTrackedTouches[touchID].x = x;
1327 mTrackedTouches[touchID].y = y;
1328 mTrackedTouches[touchID].radius = radius;
1329 }
1330
1331 void ClearAllTouches()
1332 {
1333 mTrackedTouches.clear();
1334 memset(mTouchStatus, 0, MAX_TOUCHES * sizeof(bool));
1335 }
1336
1337 int NTrackedTouches() const
1338 {
1339 return static_cast<int>(mTrackedTouches.size());
1340 }
1341
1342 TrackedTouch* GetTouch(int index)
1343 {
1344 auto itr = std::find_if(mTrackedTouches.begin(), mTrackedTouches.end(),
1345 [index](auto element) {
1346 return(element.second.index == index);
1347 });
1348
1349 if(itr != mTrackedTouches.end())
1350 return &itr->second;
1351 else
1352 return nullptr;
1353 }
1354
1355 TrackedTouch* GetTouchWithIdentifier(ITouchID touchID)
1356 {
1357 auto itr = mTrackedTouches.find(touchID);
1358
1359 if(itr != mTrackedTouches.end())
1360 return &itr->second;
1361 else
1362 return nullptr;
1363 }
1364
1365protected:
1366 static constexpr int MAX_TOUCHES = 10;
1367 std::unordered_map<ITouchID, TrackedTouch> mTrackedTouches;
1368 bool mTouchStatus[MAX_TOUCHES] = { 0 };
1369};
1370
1373{
1374public:
1375 IKnobControlBase(const IRECT& bounds, int paramIdx = kNoParameter, EDirection direction = EDirection::Vertical, double gearing = DEFAULT_GEARING)
1376 : IControl(bounds, paramIdx)
1377 , mDirection(direction)
1378 , mGearing(gearing)
1379 {}
1380
1381 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
1382 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
1383 void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override;
1384 void OnMouseWheel(float x, float y, const IMouseMod& mod, float d) override;
1385
1386 void SetGearing(double gearing) { mGearing = gearing; }
1387 bool IsFineControl(const IMouseMod& mod, bool wheel) const;
1388
1389protected:
1392 virtual IRECT GetKnobDragBounds() { return mTargetRECT; }
1393
1394 bool mHideCursorOnDrag = true;
1395 EDirection mDirection;
1396 double mGearing;
1397 bool mMouseDown = false;
1398 double mMouseDragValue = 0.0;
1399};
1400
1403{
1404public:
1405 ISliderControlBase(const IRECT& bounds, int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING, float handleSize = 0.f);
1406 ISliderControlBase(const IRECT& bounds, IActionFunction aF = nullptr, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING, float handleSize = 0.f);
1407
1408 void OnResize() override;
1409 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
1410 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
1411 void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override;
1412 void OnMouseWheel(float x, float y, const IMouseMod& mod, float d) override;
1413
1414 void SetGearing(double gearing) { mGearing = gearing; }
1415 bool IsFineControl(const IMouseMod& mod, bool wheel) const;
1416
1417protected:
1418 bool mHideCursorOnDrag = true;
1419 EDirection mDirection;
1420 IRECT mTrackBounds;
1421 float mHandleSize;
1422 double mGearing;
1423 bool mMouseDown = false;
1424 double mMouseDragValue;
1425};
1426
1430 , public IVectorBase
1431{
1432public:
1433 IVTrackControlBase(const IRECT& bounds, const char* label, const IVStyle& style, int maxNTracks = 1, int nSteps = 0, EDirection dir = EDirection::Horizontal, std::initializer_list<const char*> trackNames = {})
1434 : IControl(bounds)
1435 , IVectorBase(style)
1436 , mDirection(dir)
1437 , mNSteps(nSteps)
1438 {
1439 SetNVals(maxNTracks);
1440 mTrackBounds.Resize(maxNTracks);
1441
1442 for (int i=0; i<maxNTracks; i++)
1443 {
1444 SetParamIdx(kNoParameter, i);
1445 }
1446
1447 if(trackNames.size())
1448 {
1449 assert(trackNames.size() == maxNTracks); // check that the trackNames list size matches the number of tracks
1450
1451 for (auto& trackName : trackNames)
1452 {
1453 mTrackNames.Add(new WDL_String(trackName));
1454 }
1455 }
1456
1457 AttachIControl(this, label);
1458 }
1459
1460 IVTrackControlBase(const IRECT& bounds, const char* label, const IVStyle& style, int lowParamidx, int maxNTracks = 1, int nSteps = 0, EDirection dir = EDirection::Horizontal, std::initializer_list<const char*> trackNames = {})
1461 : IControl(bounds)
1462 , IVectorBase(style)
1463 , mDirection(dir)
1464 , mNSteps(nSteps)
1465 {
1466 SetNVals(maxNTracks);
1467 mTrackBounds.Resize(maxNTracks);
1468
1469 for (int i = 0; i < maxNTracks; i++)
1470 {
1471 SetParamIdx(lowParamidx+i, i);
1472 }
1473
1474 if(trackNames.size())
1475 {
1476 assert(trackNames.size() == maxNTracks);
1477
1478 for (auto& trackName : trackNames)
1479 {
1480 mTrackNames.Add(new WDL_String(trackName));
1481 }
1482 }
1483
1484 AttachIControl(this, label);
1485 }
1486
1487 IVTrackControlBase(const IRECT& bounds, const char* label, const IVStyle& style, const std::initializer_list<int>& params, int nSteps = 0, EDirection dir = EDirection::Horizontal, std::initializer_list<const char*> trackNames = {})
1488 : IControl(bounds)
1489 , IVectorBase(style)
1490 , mDirection(dir)
1491 , mNSteps(nSteps)
1492 {
1493 int maxNTracks = static_cast<int>(params.size());
1494 SetNVals(maxNTracks);
1495 mTrackBounds.Resize(maxNTracks);
1496
1497 int valIdx = 0;
1498 for (auto param : params)
1499 {
1500 SetParamIdx(param, valIdx++);
1501 }
1502
1503 if(trackNames.size())
1504 {
1505 assert(trackNames.size() == params.size());
1506
1507 for (auto& trackName : trackNames)
1508 {
1509 mTrackNames.Add(new WDL_String(trackName));
1510 }
1511 }
1512
1513 AttachIControl(this, label);
1514 }
1515
1516 virtual ~IVTrackControlBase()
1517 {
1518 mTrackNames.Empty(true);
1519 }
1520
1521 void OnMouseOver(float x, float y, const IMouseMod& mod) override
1522 {
1523 mMouseOverTrack = GetValIdxForPos(x, y);
1524 SetDirty(false);
1525 }
1526
1527 void OnMouseOut() override
1528 {
1529 mMouseOverTrack = -1;
1530 SetDirty(false);
1531 }
1532
1533 virtual void OnResize() override
1534 {
1535 SetTargetRECT(MakeRects(mRECT));
1536 MakeTrackRects(mWidgetBounds);
1537 MakeStepRects(mWidgetBounds, mNSteps);
1538 SetDirty(false);
1539 }
1540
1541 int GetValIdxForPos(float x, float y) const override
1542 {
1543 int nVals = NVals();
1544
1545 for (auto v = 0; v < nVals; v++)
1546 {
1547 if (mTrackBounds.Get()[v].Contains(x, y))
1548 {
1549 return v;
1550 }
1551 }
1552
1553 return kNoValIdx;
1554 }
1555
1556 void DrawWidget(IGraphics& g) override
1557 {
1558 const int nVals = NVals();
1559
1560 for (int ch = 0; ch < nVals; ch++)
1561 {
1562 DrawTrack(g, mTrackBounds.Get()[ch], ch);
1563 }
1564 }
1565
1568 void SetParamsByGroup(const char* paramGroup)
1569 {
1570 int nParams = GetDelegate()->NParams();
1571 std::vector<int> paramIdsForGroup;
1572
1573 for (auto p = 0; p < nParams; p++)
1574 {
1575 IParam* pParam = GetDelegate()->GetParam(p);
1576
1577 if(strcmp(pParam->GetGroup(), paramGroup) == 0)
1578 {
1579 paramIdsForGroup.push_back(p);
1580 }
1581 }
1582
1583 SetParams(paramIdsForGroup);
1584 }
1585
1588 void SetParams(const std::vector<int>& paramIds)
1589 {
1590 int nParams = static_cast<int>(paramIds.size());
1591
1592 SetNVals(nParams);
1593 mTrackBounds.Resize(nParams);
1594
1595 int valIdx = 0;
1596 for (auto param : paramIds)
1597 {
1598 SetParamIdx(param, valIdx++);
1599 }
1600
1601 const IParam* pFirstParam = GetParam(0);
1602 const int range = static_cast<int>(pFirstParam->GetRange() / pFirstParam->GetStep());
1603 mZeroValueStepHasBounds = !(range == 1);
1604 SetNSteps(pFirstParam->GetStepped() ? range : 0); // calls OnResize()
1605 }
1606
1607 void SetNTracks(int nTracks)
1608 {
1609 SetNVals(nTracks);
1610 mTrackBounds.Resize(nTracks);
1611 OnResize();
1612 }
1613
1614 void SetBaseValue(double value)
1615 {
1616 mBaseValue = value; OnResize();
1617 }
1618
1619 void SetTrackPadding(float value)
1620 {
1621 mTrackPadding = value; OnResize();
1622 }
1623
1624 void SetPeakSize(float value)
1625 {
1626 mPeakSize = value; OnResize();
1627 }
1628
1629 void SetNSteps(int nSteps)
1630 {
1631 mNSteps = nSteps; OnResize();
1632 }
1633
1634 void SetHighlightedTrack(int highlightIdx)
1635 {
1636 mHighlightedTrack = highlightIdx;
1637 SetDirty(false);
1638 }
1639
1640 void SetZeroValueStepHasBounds(bool val)
1641 {
1642 mZeroValueStepHasBounds = val;
1643 OnResize();
1644 }
1645
1646 bool HasTrackNames() const
1647 {
1648 return mTrackNames.GetSize() > 0;
1649 }
1650
1651 const char* GetTrackName(int chIdx) const
1652 {
1653 WDL_String* pStr = mTrackNames.Get(chIdx);
1654 return pStr ? pStr->Get() : "";
1655 }
1656
1657 void SetTrackName(int chIdx, const char* newName)
1658 {
1659 assert(chIdx >= 0 && chIdx < mTrackNames.GetSize());
1660
1661 if(chIdx >= 0 && chIdx < mTrackNames.GetSize())
1662 {
1663 mTrackNames.Get(chIdx)->Set(newName);
1664 }
1665 }
1666
1667protected:
1668 virtual void DrawBackground(IGraphics& g, const IRECT& r) override
1669 {
1670 g.FillRect(GetColor(kBG), r, &mBlend);
1671
1672 if(mBaseValue > 0.)
1673 {
1674 if(mDirection == EDirection::Horizontal)
1675 g.DrawVerticalLine(GetColor(kSH), r, static_cast<float>(mBaseValue));
1676 else
1677 g.DrawHorizontalLine(GetColor(kSH), r, static_cast<float>(mBaseValue));
1678 }
1679 }
1680
1681 virtual void DrawTrack(IGraphics& g, const IRECT& r, int chIdx)
1682 {
1683 DrawTrackBackground(g, r, chIdx);
1684
1685 if(HasTrackNames())
1686 DrawTrackName(g, r, chIdx);
1687
1688 const float trackPos = static_cast<float>(GetValue(chIdx));
1689
1690 const bool stepped = GetStepped();
1691
1692 IRECT fillRect;
1693 const float bv = static_cast<float>(mBaseValue);
1694
1695 if(bv > 0.f)
1696 {
1697 if(mDirection == EDirection::Vertical)
1698 {
1699 fillRect = IRECT(r.L,
1700 trackPos < bv ? r.B - r.H() * bv : r.B - r.H() * trackPos,
1701 r.R,
1702 trackPos < bv ? r.B - r.H() * trackPos : r.B - r.H() * bv);
1703 }
1704 else
1705 {
1706 fillRect = IRECT(trackPos < bv ? r.L + r.W() * trackPos : r.L + r.W() * bv,
1707 r.T,
1708 trackPos < bv ? r.L + r.W() * bv : r.L + r.W() * trackPos,
1709 r.B);
1710 }
1711 }
1712 else
1713 {
1714 fillRect = r.FracRect(mDirection, trackPos);
1715
1716 if(stepped && mZeroValueStepHasBounds && trackPos == 0.f)
1717 {
1718 if(mDirection == EDirection::Vertical)
1719 fillRect.T = mStepBounds.Get()[0].T;
1720 }
1721 }
1722
1723 if(stepped)
1724 {
1725 int step = GetStepIdxForPos(fillRect.R, fillRect.T);
1726
1727 if (step > -1)
1728 {
1729 if(mDirection == EDirection::Horizontal)
1730 {
1731 fillRect.L = mStepBounds.Get()[step].L;
1732 fillRect.R = mStepBounds.Get()[step].R;
1733 }
1734 else
1735 {
1736 fillRect.T = mStepBounds.Get()[step].T;
1737 fillRect.B = mStepBounds.Get()[step].B;
1738 }
1739 }
1740
1741 if(mZeroValueStepHasBounds || GetValue(chIdx) > 0.)
1742 DrawTrackHandle(g, fillRect, chIdx, trackPos > mBaseValue);
1743 }
1744 else
1745 {
1746 DrawTrackHandle(g, fillRect, chIdx, trackPos > mBaseValue);
1747
1748 IRECT peakRect;
1749
1750 if(mDirection == EDirection::Vertical)
1751 {
1752 peakRect = IRECT(fillRect.L,
1753 trackPos < mBaseValue ? fillRect.B : fillRect.T,
1754 fillRect.R,
1755 trackPos < mBaseValue ? fillRect.B - mPeakSize: fillRect.T + mPeakSize);
1756 }
1757 else
1758 {
1759 peakRect = IRECT(trackPos < mBaseValue ? fillRect.L + mPeakSize : fillRect.R - mPeakSize,
1760 fillRect.T,
1761 trackPos < mBaseValue ? fillRect.L : fillRect.R,
1762 fillRect.B);
1763 }
1764
1765 DrawPeak(g, peakRect, chIdx, trackPos > mBaseValue);
1766 }
1767
1768 if(mStyle.drawFrame && mDrawTrackFrame)
1769 g.DrawRect(GetColor(kFR), r, &mBlend, mStyle.frameThickness);
1770 }
1771
1772 virtual void DrawTrackBackground(IGraphics& g, const IRECT& r, int chIdx)
1773 {
1774 g.FillRect(chIdx == mHighlightedTrack ? this->GetColor(kHL) : COLOR_TRANSPARENT, r);
1775 }
1776
1777 virtual void DrawTrackName(IGraphics& g, const IRECT& r, int chIdx)
1778 {
1779 g.DrawText(mText, GetTrackName(chIdx), r);
1780 }
1781
1787 virtual void DrawTrackHandle(IGraphics& g, const IRECT& r, int chIdx, bool aboveBaseValue)
1788 {
1789 g.FillRect(chIdx == mHighlightedTrack ? GetColor(kX1) : GetColor(kFG), r, &mBlend);
1790
1791 if(chIdx == mMouseOverTrack)
1792 g.FillRect(GetColor(kHL), r, &mBlend);
1793 }
1794
1795 virtual void DrawPeak(IGraphics& g, const IRECT& r, int chIdx, bool aboveBaseValue)
1796 {
1797 g.FillRect(GetColor(kFR), r, &mBlend);
1798 }
1799
1800 int GetStepIdxForPos(float x, float y) const
1801 {
1802 int nSteps = mStepBounds.GetSize();
1803
1804 for (auto v = 0; v < nSteps; v++)
1805 {
1806 if (mStepBounds.Get()[v].ContainsEdge(x, y))
1807 {
1808 return v;
1809 }
1810 }
1811
1812 return -1;
1813 }
1814
1815 virtual void MakeTrackRects(const IRECT& bounds)
1816 {
1817 int nVals = NVals();
1818 int dir = static_cast<int>(mDirection); // 0 = horizontal, 1 = vertical
1819 for (int ch = 0; ch < nVals; ch++)
1820 {
1821 mTrackBounds.Get()[ch] = bounds.SubRect(EDirection(!dir), nVals, ch).
1822 GetPadded(0, -mTrackPadding * (float) dir, -mTrackPadding * (float) !dir, -mTrackPadding);
1823 }
1824 }
1825
1826 virtual void MakeStepRects(const IRECT& bounds, int nSteps)
1827 {
1828 if(nSteps)
1829 {
1830 int dir = static_cast<int>(mDirection);
1831
1832 nSteps += (int) mZeroValueStepHasBounds;
1833
1834 mStepBounds.Resize(nSteps);
1835
1836 for (int step = 0; step < nSteps; step++)
1837 {
1838 mStepBounds.Get()[step] = bounds.SubRect(EDirection(dir), nSteps, nSteps - 1 - step);
1839 }
1840 }
1841 else
1842 mStepBounds.Resize(0);
1843 }
1844
1845 bool GetStepped() const
1846 {
1847 return mStepBounds.GetSize() > 0;
1848 }
1849
1850protected:
1851 EDirection mDirection = EDirection::Vertical;
1852 WDL_TypedBuf<IRECT> mTrackBounds;
1853 WDL_TypedBuf<IRECT> mStepBounds;
1854 WDL_PtrList<WDL_String> mTrackNames;
1855 int mNSteps = 0;
1856 float mTrackPadding = 0.;
1857 float mPeakSize = 1.;
1858 int mHighlightedTrack = -1; // Highlight a single track, e.g. for step sequencer
1859 int mMouseOverTrack = -1;
1860 double mBaseValue = 0.; // 0-1 value to represent the mid-point, i.e. for displaying bipolar data
1861 bool mDrawTrackFrame = true;
1862 bool mZeroValueStepHasBounds = true; // If this is true, there is a separate step for zero, when mNSteps > 0
1863};
1864
1868{
1869public:
1870 IButtonControlBase(const IRECT& bounds, IActionFunction aF);
1871
1872 virtual ~IButtonControlBase() {}
1873 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
1874 void OnEndAnimation() override;
1875};
1876
1879{
1880public:
1881 ISwitchControlBase(const IRECT& bounds, int paramIdx = kNoParameter, IActionFunction aF = nullptr, int numStates = 2);
1882
1883 virtual ~ISwitchControlBase() {}
1884 void OnInit() override;
1885 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
1886 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
1887
1888 int GetSelectedIdx() const { return int(0.5 + GetValue() * (double) (mNumStates - 1)); }
1889
1890 void SetStateDisabled(int stateIdx, bool disabled);
1891 void SetAllStatesDisabled(bool disabled);
1892 bool GetStateDisabled(int stateIdx) const;
1893protected:
1894 int mNumStates;
1895 WDL_TypedBuf<bool> mDisabledState;
1896 bool mMouseDown = false;
1897};
1898
1905{
1906public:
1913 IDirBrowseControlBase(const IRECT& bounds, const char* extension, bool showFileExtensions = true, bool scanRecursively = true, bool showEmptySubmenus = false)
1914 : IContainerBase(bounds)
1915 , mExtension(extension)
1916 , mShowFileExtensions(showFileExtensions)
1917 , mScanRecursively(scanRecursively)
1918 , mShowEmptySubmenus(showEmptySubmenus)
1919 {
1920 }
1921
1922 virtual ~IDirBrowseControlBase();
1923
1924 int NItems() const;
1925
1929 void AddPath(const char* path, const char* displayText);
1930
1932 void ClearPathList();
1933
1935 void SetupMenu();
1936
1938 void SetSelectedFile(const char* filePath);
1939
1941 void GetSelectedFile(WDL_String& path) const;
1942
1944 void CheckSelectedItem();
1945
1946private:
1947 void ScanDirectory(const char* path, IPopupMenu& menuToAddTo);
1948 void CollectSortedItems(IPopupMenu* pMenu);
1949
1950protected:
1951 const bool mScanRecursively;
1952 const bool mShowFileExtensions;
1953 const bool mShowEmptySubmenus;
1954 int mSelectedItemIndex = -1; // index into mItems
1955 IPopupMenu mMainMenu;
1956 WDL_PtrList<WDL_String> mPaths;
1957 WDL_PtrList<WDL_String> mPathLabels;
1958 WDL_PtrList<WDL_String> mFiles;
1959 WDL_PtrList<IPopupMenu::Item> mItems; // ptr to item for each file
1960 WDL_String mExtension;
1961};
1962
1965#pragma mark - BASIC CONTROLS
1966
1974{
1975public:
1976 IPanelControl(const IRECT& bounds, const IColor& color, bool drawFrame = false,
1977 AttachFunc attachFunc = nullptr, ResizeFunc resizeFunc = nullptr)
1978 : IContainerBase(bounds, attachFunc, resizeFunc)
1979 , mPattern(color)
1980 , mDrawFrame(drawFrame)
1981 {
1982 mIgnoreMouse = true;
1983 }
1984
1985 IPanelControl(const IRECT& bounds, const IPattern& pattern, bool drawFrame = false,
1986 AttachFunc attachFunc = nullptr, ResizeFunc resizeFunc = nullptr)
1987 : IContainerBase(bounds, attachFunc, resizeFunc)
1988 , mPattern(pattern)
1989 , mDrawFrame(drawFrame)
1990 {
1991 mIgnoreMouse = true;
1992 }
1993
1994 void Draw(IGraphics& g) override
1995 {
1996 g.PathRect(mRECT);
1997 g.PathFill(mPattern, IFillOptions(), &mBlend);
1998
1999 if (mDrawFrame)
2000 g.DrawRect(COLOR_LIGHT_GRAY, mRECT, &mBlend);
2001 }
2002
2003 void SetPattern(const IPattern& pattern)
2004 {
2005 mPattern = pattern;
2006 SetDirty(false);
2007 }
2008
2009 IPattern GetPattern() const { return mPattern; }
2010
2011private:
2012 IPattern mPattern;
2013 bool mDrawFrame;
2014};
2015
2018{
2019public:
2020 ILambdaControl(const IRECT& bounds, ILambdaDrawFunction drawFunc, int animationDuration = DEFAULT_ANIMATION_DURATION,
2021 bool loopAnimation = false, bool startImmediately = false, int paramIdx = kNoParameter, bool ignoreMouse = false)
2022 : IControl(bounds, paramIdx, DefaultClickActionFunc)
2023 , mDrawFunc(drawFunc)
2024 , mLoopAnimation(loopAnimation)
2025 , mAnimationDuration(animationDuration)
2026 {
2027 if (startImmediately)
2028 SetAnimation(DefaultAnimationFunc, mAnimationDuration);
2029
2030 mIgnoreMouse = ignoreMouse;
2031 mDblAsSingleClick = true;
2032 }
2033
2034 void Draw(IGraphics& g) override
2035 {
2036 if (mDrawFunc)
2037 mDrawFunc(this, g, mRECT);
2038 }
2039
2040 virtual void OnEndAnimation() override // if you override this you must call the base implementation, to free mAnimationFunc
2041 {
2042 if (mLoopAnimation && mAnimationDuration)
2043 StartAnimation(mAnimationDuration);
2044 else
2045 IControl::OnEndAnimation();
2046
2047 SetDirty(false);
2048 }
2049
2050 void OnMouseDown(float x, float y, const IMouseMod& mod) override
2051 {
2052 mMouseInfo.x = x; mMouseInfo.y = y; mMouseInfo.ms = mod;
2053 SetAnimation(DefaultAnimationFunc, mAnimationDuration);
2054 }
2055
2056 void OnMouseUp(float x, float y, const IMouseMod& mod) override
2057 {
2058 mMouseInfo.x = x;
2059 mMouseInfo.y = y;
2060 mMouseInfo.ms = IMouseMod();
2061 SetDirty(false);
2062 }
2063
2064 void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override
2065 {
2066 mMouseInfo.x = x;
2067 mMouseInfo.y = y;
2068 mMouseInfo.dX = dX;
2069 mMouseInfo.dY = dY;
2070 mMouseInfo.ms = mod;
2071 SetDirty(false);
2072 }
2073
2074public: // public for easy access :-)
2075 ILayerPtr mLayer;
2076 IMouseInfo mMouseInfo;
2077private:
2078 ILambdaDrawFunction mDrawFunc = nullptr;
2079 bool mLoopAnimation;
2080 int mAnimationDuration;
2081};
2082
2085 , public IBitmapBase
2086{
2087public:
2091 IBitmapControl(float x, float y, const IBitmap& bitmap, int paramIdx = kNoParameter, EBlend blend = EBlend::Default)
2092 : IControl(IRECT(x, y, bitmap), paramIdx)
2093 , IBitmapBase(bitmap)
2094 {
2095 AttachIControl(this);
2096 mBlend = blend;
2097 }
2098
2099 IBitmapControl(const IRECT& bounds, const IBitmap& bitmap, int paramIdx = kNoParameter, EBlend blend = EBlend::Default)
2100 : IControl(bounds, paramIdx)
2101 , IBitmapBase(bitmap)
2102 {
2103 AttachIControl(this);
2104 mBlend = blend;
2105 }
2106
2107 virtual ~IBitmapControl() {}
2108
2109 void Draw(IGraphics& g) override { DrawBitmap(g); }
2110
2112 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
2113};
2114
2116class ISVGControl : public IControl
2117{
2118public:
2119 ISVGControl(const IRECT& bounds, const ISVG& svg, bool useLayer = false)
2120 : IControl(bounds)
2121 , mUseLayer(useLayer)
2122 , mSVG(svg)
2123 {}
2124
2125 virtual ~ISVGControl() {}
2126
2127 void Draw(IGraphics& g) override
2128 {
2129 if(mUseLayer)
2130 {
2131 if (!g.CheckLayer(mLayer))
2132 {
2133 g.StartLayer(this, mRECT);
2134 g.DrawSVG(mSVG, mRECT);
2135 mLayer = g.EndLayer();
2136 }
2137
2138 g.DrawLayer(mLayer, &mBlend);
2139 }
2140 else
2141 g.DrawSVG(mSVG, mRECT, &mBlend);
2142 }
2143
2144 void SetSVG(const ISVG& svg)
2145 {
2146 mSVG = svg;
2147 }
2148
2149private:
2150 bool mUseLayer;
2151 ILayerPtr mLayer;
2152 ISVG mSVG;
2153};
2154
2157{
2158public:
2159 ITextControl(const IRECT& bounds, const char* str = "", const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR, bool setBoundsBasedOnStr = false);
2160
2161 void Draw(IGraphics& g) override;
2162 void OnInit() override;
2163
2166 virtual void SetStr(const char* str);
2167
2170 virtual void SetStrFmt(int maxlen, const char* fmt, ...);
2171
2173 virtual void ClearStr() { SetStr(""); }
2174
2176 const char* GetStr() const { return mStr.Get(); }
2177
2179 void SetBoundsBasedOnStr();
2180
2181protected:
2182 WDL_String mStr;
2183 IColor mBGColor;
2184 bool mSetBoundsBasedOnStr = false;
2185};
2186
2189{
2190public:
2191 IEditableTextControl(const IRECT& bounds, const char* str, const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR)
2192 : ITextControl(bounds, str, text, BGColor)
2193 {
2194 mIgnoreMouse = false;
2195 }
2196
2197 void OnMouseDown(float x, float y, const IMouseMod& mod) override
2198 {
2199 GetUI()->CreateTextEntry(*this, mText, mRECT, GetStr());
2200 }
2201
2202 void OnTextEntryCompletion(const char* str, int valIdx) override
2203 {
2204 SetStr(str);
2205 SetDirty(true);
2206 }
2207};
2208
2211{
2212public:
2213 IMultiLineTextControl(const IRECT& bounds, const char* str, const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR)
2214 : ITextControl(bounds, str, text, BGColor)
2215 {
2216 }
2217
2218 void Draw(IGraphics& g) override
2219 {
2220 g.FillRect(mBGColor, mRECT, &mBlend);
2221 g.DrawMultiLineText(mText, mStr.Get(), mRECT, &mBlend);
2222 }
2223};
2224
2225
2228{
2229public:
2230 IURLControl(const IRECT& bounds, const char* str, const char* url, const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR, const IColor& MOColor = COLOR_WHITE, const IColor& CLColor = COLOR_BLUE);
2231
2232 void Draw(IGraphics& g) override;
2233
2234 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
2235 void OnMouseOver(float x, float y, const IMouseMod& mod) override { GetUI()->SetMouseCursor(ECursor::HAND); IControl::OnMouseOver(x, y, mod); };
2237 void SetText(const IText&) override;
2238
2240 void SetMOColor(const IColor& color) { mMOColor = color; SetDirty(false); }
2241
2243 void SetCLColor(const IColor& color) { mCLColor = color; SetDirty(false); }
2244
2245protected:
2246 WDL_String mURLStr;
2247 IColor mOriginalColor, mMOColor, mCLColor;
2248 bool mClicked = false;
2249};
2250
2253{
2254public:
2255 ITextToggleControl(const IRECT& bounds, int paramIdx = kNoParameter, const char* offText = "OFF", const char* onText = "ON", const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR);
2256
2257 ITextToggleControl(const IRECT& bounds, IActionFunction aF = nullptr, const char* offText = "OFF", const char* onText = "ON", const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR);
2258
2259 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
2260 void SetDirty(bool push, int valIdx = 0) override;
2261protected:
2262 WDL_String mOffText;
2263 WDL_String mOnText;
2264};
2265
2268{
2269public:
2276 ICaptionControl(const IRECT& bounds, int paramIdx, const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR, bool showParamLabel = true);
2277 void Draw(IGraphics& g) override;
2278 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
2279 void OnResize() override;
2280protected:
2281 bool mShowParamLabel;
2282 IColor mTriangleColor = COLOR_BLACK;
2283 IColor mTriangleMouseOverColor = COLOR_WHITE;
2284 IRECT mTriangleRect;
2285};
2286
2289{
2290public:
2291 PlaceHolder(const IRECT& bounds, const char* str = "Place Holder");
2292
2293 void Draw(IGraphics& g) override;
2294 void OnMouseDblClick(float x, float y, const IMouseMod& mod) override { GetUI()->CreateTextEntry(*this, mText, mRECT, mStr.Get()); }
2295 void OnTextEntryCompletion(const char* str, int valIdx) override { SetStr(str); }
2296 void OnResize() override;
2297
2298protected:
2299 IRECT mCentreLabelBounds;
2300 WDL_String mTLHCStr;
2301 WDL_String mWidthStr;
2302 WDL_String mHeightStr;
2303 IText mTLGCText = DEFAULT_TEXT.WithAlign(EAlign::Near);
2304 IText mWidthText = DEFAULT_TEXT;
2305 IText mHeightText = DEFAULT_TEXT.WithAngle(270.f);
2306 static constexpr float mInset = 10.f;
2307};
2308
2309END_IGRAPHICS_NAMESPACE
2310END_IPLUG_NAMESPACE
2311
Include to get consistently named preprocessor macros for different platforms and logging functionali...
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
IBitmapBase(const IBitmap &bitmap)
IBitmapBase Constructor.
Definition: IControl.h:728
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
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:2109
IBitmapControl(float x, float y, const IBitmap &bitmap, int paramIdx=kNoParameter, EBlend blend=EBlend::Default)
Creates a bitmap control.
Definition: IControl.h:2091
void OnRescale() override
If you override this make sure you call the parent method in order to rescale mBitmap.
Definition: IControl.h:2112
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
int N() const
A base class for buttons/momentary switches - cannot be linked to parameters.
Definition: IControl.h:1868
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:720
A control to display the textual representation of a parameter.
Definition: IControl.h:2268
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:615
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.cpp:648
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:623
IContainerBase allows a control to nest sub controls and it clips the drawing of those subcontrols In...
Definition: IControl.h:611
void Hide(bool hide) override
Shows or hides the IControl.
Definition: IControl.h:679
virtual void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.h:664
virtual void OnAttached() override
Called after the control has been attached, and its delegate and graphics member variable set.
Definition: IControl.h:656
void SetDisabled(bool disable) override
Sets disabled mode for the control, the default implementation modifies the mBlend member.
Definition: IControl.h:670
virtual void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:646
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
const IGraphics * GetUI() const
Definition: IControl.h:475
virtual bool GetWantsGestures() const
Definition: IControl.h:446
bool GetMouseIsOver() const
This can be used in IControl::Draw() to check if the mouse is over the control, without implementing ...
Definition: IControl.h:479
WDL_String mGroup
Controls can be grouped for hiding and showing panels.
Definition: IControl.h:548
IBlend GetBlend() const
Get the Blend for this control.
Definition: IControl.h:304
void SetMouseOverWhenDisabled(bool allow)
Specify whether the control should respond to mouse overs when disabled.
Definition: IControl.h:371
virtual void OnResize()
Called when IControl is constructed or resized using SetRect().
Definition: IControl.h:153
const char * GetGroup() const
Get the group that the control belongs to, if any.
Definition: IControl.h:289
bool GetWantsMidi() const
Definition: IControl.h:432
Milliseconds GetAnimationDuration() const
Get the duration of animations applied to the control.
Definition: IControl.h:514
virtual void SetIgnoreMouse(bool ignore)
Specify whether the control should respond to mouse events.
Definition: IControl.h:388
int GetTextEntryLength() const
Get the max number of characters that are allowed in text entry.
Definition: IControl.h:308
virtual void OnDropMultiple(const std::vector< const char * > &paths)
Implement to handle multiple items drag 'n dropped onto this control.
Definition: IControl.h:147
virtual bool OnKeyUp(float x, float y, const IKeyPress &key)
Implement this method to respond to a key up event on this control.
Definition: IControl.h:126
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 GetWantsMultiTouch() const
Definition: IControl.h:438
void SetWantsMultiTouch(bool enable=true)
Specify whether this control supports multiple touches.
Definition: IControl.h:435
const char * GetTooltip() const
Definition: IControl.h:224
virtual void OnGUIIdle()
This is an idle timer tick call on the GUI thread, only active if USE_IDLE_CALLS is defined.
Definition: IControl.h:423
bool GetMouseEventsWhenDisabled() const
Definition: IControl.h:381
bool mMouseIsOver
if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control.
Definition: IControl.h:565
bool GetMouseOverWhenDisabled() const
Definition: IControl.h:378
virtual void OnMouseOver(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouseover event on this control.
Definition: IControl.cpp:267
void SetMouseEventsWhenDisabled(bool allow)
Specify whether the control should respond to other mouse events when disabled.
Definition: IControl.h:375
void SetWantsMidi(bool enable=true)
Specify whether this control wants to know about MIDI messages sent to the UI.
Definition: IControl.h:429
virtual ~IControl()
Destructor.
Definition: IControl.h:81
virtual void SetPosition(float x, float y)
Set the position of the control, preserving the width and height.
Definition: IControl.cpp:291
virtual void SetValueFromDelegate(double value, int valIdx=0)
Set the control's value from the delegate This method is called from the class implementing the IEdit...
Definition: IControl.cpp:159
void SetGroup(const char *groupName)
Assign the control to a control group.
Definition: IControl.h:285
virtual void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx)
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControlPromptU...
Definition: IControl.cpp:283
bool IsDisabled() const
Definition: IControl.h:367
virtual void OnMouseDown(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:252
virtual void SetValueFromUserInput(double value, int valIdx=0)
Set the control's value after user input.
Definition: IControl.cpp:174
IActionFunction GetActionFunction()
Get the control's action function, if it exists.
Definition: IControl.h:508
virtual bool IsDirty()
Called at each display refresh by the IGraphics draw loop, after IControl::Animate(),...
Definition: IControl.cpp:231
virtual bool IsHit(float x, float y) const
Hit test the control.
Definition: IControl.h:400
virtual void Hide(bool hide)
Shows or hides the IControl.
Definition: IControl.cpp:239
virtual void OnRescale()
Implement to do something when graphics is scaled globally (e.g.
Definition: IControl.h:150
void SetDelegate(IGEditorDelegate &dlg)
Used internally to set the mDelegate (and mGraphics) variables.
Definition: IControl.h:457
virtual void OnDeleteFromPopupMenu(IPopupMenu *pMenu, int itemIdx)
Implement this method to handle popup menu deletion interactions (on IOS) after IGraphics::CreatePopu...
Definition: IControl.h:181
virtual void OnTouchCancelled(float x, float y, const IMouseMod &mod)
Implement this method to respond to a touch cancel event on this control.
Definition: IControl.h:141
virtual void OnDrop(const char *str)
Implement to do something when something was drag 'n dropped onto this control.
Definition: IControl.h:144
IControl * AttachGestureRecognizer(EGestureType type, IGestureFunc func)
Add a IGestureFunc that should be triggered in response to a certain type of gesture.
Definition: IControl.cpp:311
const IRECT & GetTargetRECT() const
Get the rectangular mouse tracking target area, within the graphics context for this control.
Definition: IControl.h:324
int GetParamIdx(int valIdx=0) const
Get the index of a parameter that the control is linked to Normaly controls are either linked to a si...
Definition: IControl.cpp:109
const IRECT & GetRECT() const
Get the rectangular draw area for this control, within the graphics context.
Definition: IControl.h:316
virtual bool OnKeyDown(float x, float y, const IKeyPress &key)
Implement this method to respond to a key down event on this control.
Definition: IControl.h:120
int LinkedToParam(int paramIdx) const
Check if the control is linked to a particular parameter.
Definition: IControl.cpp:132
void SetTargetRECT(const IRECT &bounds)
Set the rectangular mouse tracking target area, within the graphics context for this control.
Definition: IControl.h:328
bool GetIgnoreMouse() const
Definition: IControl.h:384
IGEditorDelegate * GetDelegate()
Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes...
Definition: IControl.h:454
virtual void SetText(const IText &txt)
Set the Text object typically used to determine font/layout/size etc of the main text in a control.
Definition: IControl.h:297
virtual void OnMouseDblClick(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse double click event on this control.
Definition: IControl.cpp:258
virtual void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData)
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate()
Definition: IControl.h:162
double GetAnimationProgress() const
Get the progress in a control's animation, in the range 0-1.
Definition: IControl.cpp:431
void PromptUserInput(int valIdx=0)
Call this method in response to a mouse event to create an edit box so the user can enter a value,...
Definition: IControl.cpp:334
int GetTag() const
Get the control's tag.
Definition: IControl.h:426
virtual void OnMouseUp(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse up event on this control.
Definition: IControl.h:93
void SetPromptShowsParamLabel(bool enable)
Set if the control should show parameter labels/units e.g.
Definition: IControl.h:394
virtual void SnapToMouse(float x, float y, EDirection direction, const IRECT &bounds, int valIdx=-1, double minClip=0., double maxClip=1.)
Set control value based on x, y position within a rectangle.
Definition: IControl.cpp:397
virtual void DrawPTHighlight(IGraphics &g)
Implement this to customise how a colored highlight is drawn on the control in ProTools (AAX format o...
Definition: IControl.cpp:389
virtual void CreateContextMenu(IPopupMenu &contextMenu)
Called by default when the user right clicks a control.
Definition: IControl.h:171
virtual void OnAttached()
Called after the control has been attached, and its delegate and graphics member variable set.
Definition: IControl.h:159
IControl * SetAnimationEndActionFunction(IActionFunction actionFunc)
Set an Action Function to be called at the end of an animation.
Definition: IControl.h:216
virtual void SetValueToDefault(int valIdx=kNoValIdx)
Set one or all of the control's values to the default value of the associated parameter.
Definition: IControl.cpp:183
virtual void SetParamIdx(int paramIdx, int valIdx=0)
Set the index of a parameter that the control is linked to If you are calling this "manually" to reus...
Definition: IControl.cpp:115
virtual bool OnGesture(const IGestureInfo &info)
Definition: IControl.cpp:320
virtual void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod &mod)
Implement this method to respond to a mouse drag event on this control.
Definition: IControl.h:101
virtual void OnMouseWheel(float x, float y, const IMouseMod &mod, float d)
Implement this method to respond to a mouse wheel event on this control.
Definition: IControl.h:114
virtual void Draw(IGraphics &g)=0
Draw the control to the graphics context.
const IParam * GetParam(int valIdx=0) const
Get a const pointer to the IParam object (owned by the editor delegate class), associated with this c...
Definition: IControl.cpp:122
void ForValIdx(int valIdx, T func, Args... args)
A helper template function to call a method for an individual value, or for all values.
Definition: IControl.h:532
T * As()
Helper function to dynamic cast an IControl to a subclass.
Definition: IControl.h:518
const IText & GetText() const
Get the Text object for the control.
Definition: IControl.h:293
virtual void OnMidi(const IMidiMsg &msg)
Implement to receive MIDI messages sent to the control if mWantsMidi == true, see IEditorDelegate:Sen...
Definition: IControl.h:165
bool GetMouseDblAsSingleClick() const
Get double click as single click By default, mouse double click has its own handler.
Definition: IControl.h:353
virtual void SetSize(float w, float h)
Set the size of the control, preserving the current position.
Definition: IControl.cpp:303
void SetPTParameterHighlight(bool isHighlighted, int color)
Used internally by the AAX wrapper view interface to set the control parmeter highlight.
Definition: IControl.cpp:365
virtual void OnTextEntryCompletion(const char *str, int valIdx)
Implement this method to handle text input after IGraphics::CreateTextEntry/IControlPromptUserInput.
Definition: IControl.h:186
void SetRECT(const IRECT &bounds)
Set the rectangular draw area for this control, within the graphics context.
Definition: IControl.h:320
void StartAnimation(int duration)
Definition: IControl.cpp:425
virtual void SetDisabled(bool disable)
Sets disabled mode for the control, the default implementation modifies the mBlend member.
Definition: IControl.cpp:245
virtual void OnInit()
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControl.h:156
IControl * SetTooltip(const char *str)
Set a tooltip for the control.
Definition: IControl.h:221
void SetAnimation(IAnimationFunction func, int duration)
Set the animation function and starts it.
Definition: IControl.h:502
virtual void SetValue(double value, int valIdx=0)
Set one of the control's values.
Definition: IControl.cpp:147
double GetValue(int valIdx=0) const
Get the control's value.
Definition: IControl.cpp:153
void SetTargetAndDrawRECTs(const IRECT &bounds)
Set BOTH the draw rect and the target area, within the graphics context for this control.
Definition: IControl.h:332
virtual void OnContextSelection(int itemSelected)
Implement this to respond to a menu selection from CreateContextMenu();.
Definition: IControl.h:189
void SetBlend(const IBlend &blend)
Set the Blend for this control.
Definition: IControl.h:301
virtual int GetValIdxForPos(float x, float y) const
Check to see which of the control's values relates to this x and y coordinate.
Definition: IControl.h:250
int NVals() const
Definition: IControl.h:244
IContainerBase * GetParent() const
Definition: IControl.h:467
IAnimationFunction GetAnimationFunction()
Get the control's animation function, if it exists.
Definition: IControl.h:505
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
Definition: IControl.cpp:198
EGestureType GetLastGesture() const
Definition: IControl.h:449
void SetTextEntryLength(int len)
Set the max number of characters that are allowed in text entry.
Definition: IControl.h:312
bool GetPromptShowsParamLabel() const
Definition: IControl.h:391
void DisablePrompt(bool disable)
Disable/enable default prompt for user input.
Definition: IControl.h:420
IControl * SetActionFunction(IActionFunction actionFunc)
Set an Action Function for this control.
Definition: IControl.h:211
void SetAnimation(IAnimationFunction func)
Set the animation function.
Definition: IControl.h:497
bool IsHidden() const
Definition: IControl.h:360
An abstract IControl base class that you can inherit from in order to make a control that pops up a m...
Definition: IControl.h:1905
void ClearPathList()
Clear the menu.
Definition: IControl.cpp:1079
void CheckSelectedItem()
Check the currently selected menu item.
Definition: IControl.cpp:1122
void SetupMenu()
Call after adding one or more paths, to populate the menu.
Definition: IControl.cpp:1052
void GetSelectedFile(WDL_String &path) const
Get the full path to the file if something has been selected in the menu.
Definition: IControl.cpp:1109
void SetSelectedFile(const char *filePath)
Set the selected file based on a file path.
Definition: IControl.cpp:1087
IDirBrowseControlBase(const IRECT &bounds, const char *extension, bool showFileExtensions=true, bool scanRecursively=true, bool showEmptySubmenus=false)
Creates an IDirBrowseControlBase.
Definition: IControl.h:1913
void AddPath(const char *path, const char *displayText)
Used to add a path to scan for files.
Definition: IControl.cpp:1029
A basic control to display some editable text.
Definition: IControl.h:2189
void OnTextEntryCompletion(const char *str, int valIdx) override
Implement this method to handle text input after IGraphics::CreateTextEntry/IControlPromptUserInput.
Definition: IControl.h:2202
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.h:2197
IParam * GetParam(int paramIdx)
Get a pointer to one of the delegate's IParam objects.
An editor delegate base class that uses IGraphics for the UI.
IGraphics * GetUI()
Get a pointer to the IGraphics context.
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
virtual void DrawRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw a rectangle to the graphics context.
Definition: IGraphics.cpp:2515
virtual void FillEllipse(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill an ellipse within a rectangular region of the graphics context.
Definition: IGraphics.cpp:2631
virtual void DrawEllipse(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw an ellipse within a rectangular region of the graphics context.
Definition: IGraphics.cpp:2566
void RemoveControl(int idx)
Remove a control at a particular index, (frees memory).
Definition: IGraphics.cpp:167
virtual void PathFill(const IPattern &pattern, const IFillOptions &options=IFillOptions(), const IBlend *pBlend=0)=0
Fill the current current path.
void DrawText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend=0)
Draw some text to the graphics context in a specific rectangle.
Definition: IGraphics.cpp:683
void CreateTextEntry(IControl &control, const IText &text, const IRECT &bounds, const char *str="", int valIdx=0)
Create a text entry box.
Definition: IGraphics.cpp:1939
void PathRect(const IRECT &bounds)
Add a rectangle to the current path.
Definition: IGraphics.cpp:2653
virtual ECursor SetMouseCursor(ECursor cursorType=ECursor::ARROW)
Sets the mouse cursor to one of ECursor (implementations should return the result of the base impleme...
Definition: IGraphics.h:828
virtual void DrawRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0, float thickness=1.f)
Draw a rounded rectangle to the graphics context.
Definition: IGraphics.cpp:2522
bool CheckLayer(const ILayerPtr &layer)
Test to see if a layer needs drawing, for instance if the control's bounds were changed.
Definition: IGraphics.cpp:2050
void DrawLayer(const ILayerPtr &layer, const IBlend *pBlend=nullptr)
Draw a layer to the main IGraphics context.
Definition: IGraphics.cpp:2063
virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
Definition: IGraphics.cpp:2587
void PathClipRegion(const IRECT r=IRECT())
Clip the current path to a particular region.
Definition: IGraphics.cpp:2783
virtual void FillRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0)
Fill a rounded rectangle with a color.
Definition: IGraphics.cpp:2594
virtual void FillTriangle(const IColor &color, float x1, float y1, float x2, float y2, float x3, float y3, const IBlend *pBlend=0)
Fill a triangle with a color.
Definition: IGraphics.cpp:2580
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:1536
void DrawVerticalLine(const IColor &color, const IRECT &bounds, float x, const IBlend *pBlend=0, float thickness=1.f)
Draw a vertical line, within a rectangular region of the graphics context.
Definition: IGraphics.cpp:800
void DrawHorizontalLine(const IColor &color, const IRECT &bounds, float y, const IBlend *pBlend=0, float thickness=1.f)
Draw a horizontal line, within a rectangular region of the graphics context.
Definition: IGraphics.cpp:807
virtual void DrawMultiLineText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend=0)
Draw some multi-line text to the graphics context in a specific rectangle (NanoVG only)
Definition: IGraphics.h:363
void StartLayer(IControl *pOwner, const IRECT &r, bool cacheable=false)
Create an IGraphics layer.
Definition: IGraphics.cpp:1995
int GetControlTag(const IControl *pControl) const
Get the tag given to a control.
Definition: IGraphics.h:1397
virtual void DrawSVG(const ISVG &svg, const IRECT &bounds, const IBlend *pBlend=0, const IColor *pStrokeColor=nullptr, const IColor *pFillColor=nullptr)
Draw an SVG image to the graphics context.
Definition: IGraphics.cpp:2802
virtual void DrawTriangle(const IColor &color, float x1, float y1, float x2, float y2, float x3, float y3, const IBlend *pBlend=0, float thickness=1.f)
Draw a triangle to the graphics context.
Definition: IGraphics.cpp:2508
virtual void FillCircle(const IColor &color, float cx, float cy, float r, const IBlend *pBlend=0)
Fill a circle with a color.
Definition: IGraphics.cpp:2624
ILayerPtr EndLayer()
End an IGraphics layer.
Definition: IGraphics.cpp:2018
virtual void DrawBitmap(const IBitmap &bitmap, const IRECT &bounds, int srcX, int srcY, const IBlend *pBlend=0)=0
Draw a bitmap (raster) image to the graphics context.
virtual float MeasureText(const IText &text, const char *str, IRECT &bounds) const
Measure the rectangular region that some text will occupy.
Definition: IGraphics.cpp:691
A base class for knob/dial controls, to handle mouse action and Sender.
Definition: IControl.h:1373
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:810
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: IControl.cpp:830
void OnMouseWheel(float x, float y, const IMouseMod &mod, float d) override
Implement this method to respond to a mouse wheel event on this control.
Definition: IControl.cpp:853
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControl.cpp:821
virtual IRECT GetKnobDragBounds()
Get the area for which mouse deltas will be used to calculate the amount dragging changes the control...
Definition: IControl.h:1392
A control that can be specialised with a lambda function, for quick experiments without making a cust...
Definition: IControl.h:2018
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:2034
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.h:2050
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: IControl.h:2064
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControl.h:2056
A basic control to display some text that needs to span multiple lines.
Definition: IControl.h:2211
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:2218
A base class for controls that can do do multitouch.
Definition: IControl.h:1279
A basic control to fill a rectangle with a color or gradient.
Definition: IControl.h:1974
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:1994
IPlug's parameter class.
double GetStep() const
Returns the parameter's step size.
bool GetStepped() const
double GetRange() const
Returns the parameter's range.
const char * GetGroup() const
Returns the parameter's group.
A class for setting the contents of a pop up menu.
A basic control to draw an SVG image to the screen.
Definition: IControl.h:2117
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:2127
A base class for slider/fader controls, to handle mouse action and Sender.
Definition: IControl.h:1403
void OnMouseWheel(float x, float y, const IMouseMod &mod, float d) override
Implement this method to respond to a mouse wheel event on this control.
Definition: IControl.cpp:975
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: IControl.cpp:935
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:906
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.cpp:899
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControl.cpp:926
A base class for switch controls.
Definition: IControl.h:1879
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:773
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControl.cpp:765
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControl.cpp:791
A basic control to display some text.
Definition: IControl.h:2157
virtual void SetStrFmt(int maxlen, const char *fmt,...)
Set the text to display, using a printf-like format string.
Definition: IControl.cpp:469
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:479
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControl.cpp:450
const char * GetStr() const
Definition: IControl.h:2176
virtual void ClearStr()
Clear the text .
Definition: IControl.h:2173
void SetBoundsBasedOnStr()
Measures the bounds of the text that the control displays and compacts/expands the control's bounds t...
Definition: IControl.cpp:487
virtual void SetStr(const char *str)
Set the text to display.
Definition: IControl.cpp:456
A control to toggle between two text strings on click.
Definition: IControl.h:2253
void SetDirty(bool push, int valIdx=0) override
Mark the control as dirty, i.e.
Definition: IControl.cpp:594
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:584
A control to show a clickable URL, that changes color after clicking.
Definition: IControl.h:2228
void SetText(const IText &) override
Set the Text object typically used to determine font/layout/size etc of the main text in a control.
Definition: IControl.cpp:557
void SetCLColor(const IColor &color)
Sets the color of the text when the URL has been clicked.
Definition: IControl.h:2243
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControl.h:2236
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:550
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
Definition: IControl.h:2235
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:504
void SetMOColor(const IColor &color)
Sets the color of the text on Mouse Over.
Definition: IControl.h:2240
A base class for mult-strip/track controls, such as multi-sliders, meters Track refers to the channel...
Definition: IControl.h:1431
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
Definition: IControl.h:1521
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControl.h:1527
void SetParamsByGroup(const char *paramGroup)
Update the parameters based on a parameter group name.
Definition: IControl.h:1568
virtual void DrawTrackHandle(IGraphics &g, const IRECT &r, int chIdx, bool aboveBaseValue)
Draw the main body of the track.
Definition: IControl.h:1787
void SetParams(const std::vector< int > &paramIds)
Update the parameters based on a parameter group name.
Definition: IControl.h:1588
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControl.h:1556
int GetValIdxForPos(float x, float y) const override
Check to see which of the control's values relates to this x and y coordinate.
Definition: IControl.h:1541
virtual void DrawBackground(IGraphics &g, const IRECT &r) override
Draw the IVControl background (usually transparent)
Definition: IControl.h:1668
virtual void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.h:1533
A base interface to be combined with IControl for vectorial controls "IVControls",...
Definition: IControl.h:762
virtual void DrawPressableShape(IGraphics &g, EVShape shape, const IRECT &bounds, bool pressed, bool mouseOver, bool disabled)
Call one of the DrawPressableShape methods.
Definition: IControl.h:923
void SetColor(EVColor colorIdx, const IColor &color)
Set one of the IVColors that style the IVControl.
Definition: IControl.h:792
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 SetStyle(const IVStyle &style)
Set the Style of this IVControl.
Definition: IControl.h:830
virtual void DrawWidget(IGraphics &g)
Draw the IVControl main widget (override)
Definition: IControl.h:888
IVectorBase(const IVStyle &style, bool labelInWidget=false, bool valueInWidget=false)
IVectorBase Constructor.
Definition: IControl.h:768
IRECT GetAdjustedHandleBounds(IRECT handleBounds) const
Get the adjusted bounds for the widget handle, based on the style settings.
Definition: IControl.h:844
void DrawPressableEllipse(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, bool disabled)
Draw an ellipse-shaped vector button.
Definition: IControl.h:953
IRECT DrawPressableTriangle(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, float angle, bool disabled)
Draw a triangle-shaped vector button.
Definition: IControl.h:1108
float GetRoundedCornerRadius(const IRECT &bounds) const
Get the radius of rounded corners for a rectangle, based on the style roundness factor.
Definition: IControl.h:858
virtual void DrawValue(IGraphics &g, bool mouseOver)
Draw the IVControl value text.
Definition: IControl.h:904
void DrawSplash(IGraphics &g, const IRECT &clipRegion=IRECT())
Draw a splash effect when a widget handle is clicked (via SplashClickAnimationFunc)
Definition: IControl.h:873
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
virtual void OnStyleChanged()
Implement if extra changes are required in response to style changing.
Definition: IControl.h:787
const IColor & GetColor(EVColor color) const
Get value of a specific EVColor in the IVControl.
Definition: IControl.h:806
void SetColors(const IVColorSpec &spec)
Set the colors of this IVControl.
Definition: IControl.h:800
IVStyle GetStyle() const
Get the style of this IVControl.
Definition: IControl.h:839
A control to use as a placeholder during development.
Definition: IControl.h:2289
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:675
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.cpp:707
void OnTextEntryCompletion(const char *str, int valIdx) override
Implement this method to handle text input after IGraphics::CreateTextEntry/IControlPromptUserInput.
Definition: IControl.h:2295
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: IControl.h:2294
BEGIN_IPLUG_NAMESPACE BEGIN_IGRAPHICS_NAMESPACE void DefaultAnimationFunc(IControl *pCaller)
An animation function that just calls the caller control's OnEndAnimation() method at the end of the ...
Definition: IControl.cpp:21
void DefaultClickActionFunc(IControl *pCaller)
A click action function that triggers the default animation function for DEFAULT_ANIMATION_DURATION.
Definition: IControl.cpp:45
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
Used to describe a particular gesture.
Used to group mouse coordinates with mouse modifier information.
BEGIN_IPLUG_NAMESPACE T Clip(T x, T lo, T hi)
Clips the value x between lo and hi.
Used to manage composite/blend operations, independent of draw class/platform.
Used to manage color data, independent of draw class/platform.
Used to manage fill behaviour.
Used for key press info, such as ASCII representation, virtual key (mapped to win32 codes) and modifi...
Definition: IPlugStructs.h:616
Encapsulates a MIDI message and provides helper functions.
Definition: IPlugMidi.h:31
Used to manage mouse modifiers i.e.
Used to store pattern information for gradients.
Used to manage a rectangular area, independent of draw class/platform.
IRECT ReduceFromRight(float amount)
Reduce in width from the right edge by 'amount' and return the removed region.
IRECT GetReducedFromTop(float amount) const
Get a subrect of this IRECT reduced in height from the top edge by 'amount'.
IRECT GetReducedFromLeft(float amount) const
Get a subrect of this IRECT reduced in width from the left edge by 'amount'.
IRECT GetReducedFromRight(float amount) const
Get a subrect of this IRECT reduced in width from the right edge by 'amount'.
void Pad(float padding)
Pad this IRECT N.B.
IRECT GetFromRight(float amount) const
Get a subrect of this IRECT bounded in X by 'amount' and the right edge.
IRECT GetFromBottom(float amount) const
Get a subrect of this IRECT bounded in Y by 'amount' and the bottom edge.
IRECT GetCentredInside(const IRECT &sr) const
Get a rectangle the size of sr but with the same center point as this rectangle.
IRECT GetTranslated(float x, float y) const
Get a translated copy of this rectangle.
IRECT GetScaledAboutCentre(float scale) const
Get a copy of this IRECT where the width and height are multiplied by scale without changing the cent...
IRECT GetReducedFromBottom(float amount) const
Get a subrect of this IRECT reduced in height from the bottom edge by 'amount'.
void Offset(float l, float t, float r, float b)
Offset each field of the rectangle.
IRECT SubRect(EDirection layoutDir, int numSlices, int sliceIdx) const
Get a new rectangle which is a "slice" of this rectangle.
bool Empty() const
IRECT FracRect(EDirection layoutDir, float frac, bool fromTopOrRight=false) const
Get a new rectangle which is a fraction of this rectangle.
float W() const
IRECT ReduceFromBottom(float amount)
Reduce in height from the bottom edge by 'amount' and return the removed region.
IRECT GetFromLeft(float amount) const
Get a subrect of this IRECT bounded in X by the left edge and 'amount'.
IRECT GetFromTop(float amount) const
Get a subrect of this IRECT bounded in Y by the top edge and 'amount'.
float H() const
IRECT GetMidHPadded(float padding) const
Get a copy of this IRECT where its width = 2 * padding but the center point on the X-axis has not cha...
float MW() const
bool Contains(const IRECT &rhs) const
Returns true if this IRECT completely contains rhs.
IRECT GetPadded(float padding) const
Get a copy of this IRECT with each value padded by padding N.B.
IRECT GetMidVPadded(float padding) const
Get a copy of this IRECT where its height = 2 * padding but the center point on the Y-axis has not ch...
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,...
Contains a set of 9 colors used to theme IVControls.
const IColor & GetColor(EVColor color) const
A struct encapsulating a set of properties used to configure IVControls.
Encapsulate an xy point in one struct.