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 OnTextEntryCompletion(const char* str, int valIdx) {}
182
184 virtual void OnContextSelection(int itemSelected) {}
185
188 virtual void Draw(IGraphics& g) = 0;
189
192 virtual void DrawPTHighlight(IGraphics& g);
193
196 void PromptUserInput(int valIdx = 0);
197
201 void PromptUserInput(const IRECT& bounds, int valIdx = 0);
202
206 inline IControl* SetActionFunction(IActionFunction actionFunc) { mActionFunc = actionFunc; return this; }
207
211 inline IControl* SetAnimationEndActionFunction(IActionFunction actionFunc) { mAnimationEndActionFunc = actionFunc; return this; }
212
216 inline IControl* SetTooltip(const char* str) { mTooltip.Set(str); return this; }
217
219 inline const char* GetTooltip() const { return mTooltip.Get(); }
220
225 int GetParamIdx(int valIdx = 0) const;
226
231 virtual void SetParamIdx(int paramIdx, int valIdx = 0);
232
236 int LinkedToParam(int paramIdx) const;
237
239 int NVals() const { return (int) mVals.size(); }
240
245 virtual int GetValIdxForPos(float x, float y) const { return mVals.size() == 1 ? 0 : kNoValIdx; }
246
249 const IParam* GetParam(int valIdx = 0) const;
250
255 virtual void SetValueFromDelegate(double value, int valIdx = 0);
256
261 virtual void SetValueFromUserInput(double value, int valIdx = 0);
262
266 virtual void SetValueToDefault(int valIdx = kNoValIdx);
267
271 virtual void SetValue(double value, int valIdx = 0);
272
276 double GetValue(int valIdx = 0) const;
277
280 void SetGroup(const char* groupName) { mGroup.Set(groupName); }
281
284 const char* GetGroup() const { return mGroup.Get(); }
285
288 const IText& GetText() const { return mText; }
289
292 virtual void SetText(const IText& txt) { mText = txt; }
293
296 void SetBlend(const IBlend& blend) { mBlend = blend; }
297
299 IBlend GetBlend() const { return mBlend; }
300
303 int GetTextEntryLength() const { return mTextEntryLength; }
304
307 void SetTextEntryLength(int len) { mTextEntryLength = len; }
308
311 const IRECT& GetRECT() const { return mRECT; }
312
315 void SetRECT(const IRECT& bounds) { mRECT = bounds; mMouseIsOver = false; OnResize(); }
316
319 const IRECT& GetTargetRECT() const { return mTargetRECT; } // The mouse target area (default = draw area).
320
323 void SetTargetRECT(const IRECT& bounds) { mTargetRECT = bounds; mMouseIsOver = false; }
324
327 void SetTargetAndDrawRECTs(const IRECT& bounds) { mRECT = mTargetRECT = bounds; mMouseIsOver = false; OnResize(); }
328
332 virtual void SetPosition(float x, float y);
333
337 virtual void SetSize(float w, float h);
338
342 void SetPTParameterHighlight(bool isHighlighted, int color);
343
348 bool GetMouseDblAsSingleClick() const { return mDblAsSingleClick; }
349
352 virtual void Hide(bool hide);
353
355 bool IsHidden() const { return mHide; }
356
359 virtual void SetDisabled(bool disable);
360
362 bool IsDisabled() const { return mDisabled; }
363
366 void SetMouseOverWhenDisabled(bool allow) { mMouseOverWhenDisabled = allow; }
367
370 void SetMouseEventsWhenDisabled(bool allow) { mMouseEventsWhenDisabled = allow; }
371
373 bool GetMouseOverWhenDisabled() const { return mMouseOverWhenDisabled; }
374
376 bool GetMouseEventsWhenDisabled() const { return mMouseEventsWhenDisabled; }
377
379 bool GetIgnoreMouse() const { return mIgnoreMouse; }
380
383 virtual void SetIgnoreMouse(bool ignore) { mIgnoreMouse = ignore; }
384
386 bool GetPromptShowsParamLabel() const { return mPromptShowsParamLabel; }
387
389 void SetPromptShowsParamLabel(bool enable) { mPromptShowsParamLabel = enable; }
390
395 virtual bool IsHit(float x, float y) const { return mTargetRECT.Contains(x, y); }
396
401 virtual void SetDirty(bool triggerAction = true, int valIdx = kNoValIdx);
402
403 /* Set the control clean, i.e. Called by IGraphics draw loop after control has been drawn */
404 virtual void SetClean() { mDirty = false; }
405
406 /* Called at each display refresh by the IGraphics draw loop, triggers the control's AnimationFunc if it is set */
407 void Animate();
408
411 virtual bool IsDirty();
412
415 void DisablePrompt(bool disable) { mDisablePrompt = disable; }
416
418 virtual void OnGUIIdle() {}
419
421 int GetTag() const { return GetUI()->GetControlTag(this); }
422
424 void SetWantsMidi(bool enable = true) { mWantsMidi = enable; }
425
427 bool GetWantsMidi() const { return mWantsMidi; }
428
430 void SetWantsMultiTouch(bool enable = true) { mWantsMultiTouch = enable; }
431
433 bool GetWantsMultiTouch() const { return mWantsMultiTouch; }
434
438 IControl* AttachGestureRecognizer(EGestureType type, IGestureFunc func);
439
441 virtual bool GetWantsGestures() const { return mGestureFuncs.size() > 0 && !mAnimationFunc; }
442
444 EGestureType GetLastGesture() const { return mLastGesture; }
445
449 IGEditorDelegate* GetDelegate() { return mDelegate; }
450
453 {
454 mDelegate = &dlg;
455 mGraphics = dlg.GetUI();
456 OnInit();
457 OnResize();
458 OnRescale();
459 }
460
462 IContainerBase* GetParent() const { return mParent; }
463
464 void SetParent(IContainerBase* pParent) { mParent = pParent; }
465
467 IGraphics* GetUI() { return mGraphics; }
468
470 const IGraphics* GetUI() const { return mGraphics; }
471
474 bool GetMouseIsOver() const { return mMouseIsOver; }
475
482 virtual void SnapToMouse(float x, float y, EDirection direction, const IRECT& bounds, int valIdx = -1, double minClip = 0., double maxClip = 1.);
483
484 /* if you override this you must call the base implementation, to free mAnimationFunc */
485 virtual void OnEndAnimation();
486
488 void StartAnimation(int duration);
489
492 void SetAnimation(IAnimationFunction func) { mAnimationFunc = func;}
493
497 void SetAnimation(IAnimationFunction func, int duration) { mAnimationFunc = func; StartAnimation(duration); }
498
500 IAnimationFunction GetAnimationFunction() { return mAnimationFunc; }
501
503 IActionFunction GetActionFunction() { return mActionFunc; }
504
506 double GetAnimationProgress() const;
507
509 Milliseconds GetAnimationDuration() const { return mAnimationDuration; }
510
512 template <class T>
513 T* As() { return dynamic_cast<T*>(this); }
514
515#if defined VST3_API || defined VST3C_API
516 Steinberg::tresult PLUGIN_API executeMenuItem (Steinberg::int32 tag) override { OnContextSelection(tag); return Steinberg::kResultOk; }
517#endif
518
519#pragma mark - IControl Member variables
520protected:
521
526 template<typename T, typename... Args>
527 void ForValIdx(int valIdx, T func, Args... args)
528 {
529 if (valIdx > kNoValIdx)
530 func(valIdx, args...);
531 else
532 {
533 const int nVals = NVals();
534 for (int v = 0; v < nVals; v++)
535 func(v, args...);
536 }
537 }
538
539 IRECT mRECT;
540 IRECT mTargetRECT;
541
543 WDL_String mGroup;
544
545 IText mText;
546 IBlend mBlend;
547 int mTextEntryLength = DEFAULT_TEXT_ENTRY_LEN;
548 bool mDirty = true;
549 bool mHide = false;
550 bool mDisabled = false;
551 bool mDisablePrompt = true;
552 bool mDblAsSingleClick = false;
553 bool mMouseOverWhenDisabled = false;
554 bool mMouseEventsWhenDisabled = false;
555 bool mIgnoreMouse = false;
556 bool mWantsMidi = false;
557 bool mWantsMultiTouch = false;
558 bool mPromptShowsParamLabel = false;
560 bool mMouseIsOver = false;
561 WDL_String mTooltip;
562
563 IColor mPTHighlightColor = COLOR_RED;
564 bool mPTisHighlighted = false;
565
566 void SetNVals(int nVals)
567 {
568 assert(nVals > 0);
569 mVals.resize(nVals);
570 }
571
572#if defined VST3_API || defined VST3C_API
573 OBJ_METHODS(IControl, FObject)
574 DEFINE_INTERFACES
575 DEF_INTERFACE (IContextMenuTarget)
576 END_DEFINE_INTERFACES (FObject)
577 REFCOUNT_METHODS(FObject)
578#endif
579
580private:
581 IContainerBase* mParent = nullptr;
582 IGEditorDelegate* mDelegate = nullptr;
583 IGraphics* mGraphics = nullptr;
584 IActionFunction mActionFunc = nullptr;
585 IActionFunction mAnimationEndActionFunc = nullptr;
586 IAnimationFunction mAnimationFunc = nullptr;
587 TimePoint mAnimationStartTime;
588 Milliseconds mAnimationDuration;
589 std::vector<ParamTuple> mVals { {kNoParameter, 0.} };
590 std::unordered_map<EGestureType, IGestureFunc> mGestureFuncs;
591 EGestureType mLastGesture = EGestureType::Unknown;
592};
593
594#pragma mark - Base Controls
595
606{
607public:
608 using AttachFunc = std::function<void(IContainerBase* pContainer, const IRECT& bounds)>;
609 using ResizeFunc = std::function<void(IContainerBase* pContainer, const IRECT& bounds)>;
610
611 IContainerBase(const IRECT& bounds, int paramIdx = kNoParameter, IActionFunction actionFunc = nullptr)
612 : IControl(bounds, paramIdx, actionFunc)
613 {}
614
615 IContainerBase(const IRECT& bounds, const std::initializer_list<int>& params, IActionFunction actionFunc = nullptr)
616 : IControl(bounds, params, actionFunc)
617 {}
618
619 IContainerBase(const IRECT& bounds, IActionFunction actionFunc)
620 : IControl(bounds, actionFunc)
621 {}
622
623 IContainerBase(const IRECT& bounds, AttachFunc attachFunc, ResizeFunc resizeFunc)
624 : IControl(bounds)
625 , mAttachFunc(attachFunc)
626 , mResizeFunc(resizeFunc)
627 {
628 mIgnoreMouse = true;
629 }
630
631 void SetAttachFunc(AttachFunc attachFunc)
632 {
633 mAttachFunc = attachFunc;
634 }
635
636 void SetResizeFunc(ResizeFunc resizeFunc)
637 {
638 mResizeFunc = resizeFunc;
639 }
640
641 virtual void Draw(IGraphics& g) override
642 {
643 /* NO-OP */
644 }
645
646 virtual ~IContainerBase()
647 {
648 mChildren.Empty(false);
649 }
650
651 virtual void OnAttached() override
652 {
653 if (mAttachFunc)
654 mAttachFunc(this, mRECT);
655
656 OnResize();
657 }
658
659 virtual void OnResize() override
660 {
661 if (mResizeFunc && mChildren.GetSize())
662 mResizeFunc(this, mRECT);
663 }
664
665 void SetDisabled(bool disable) override
666 {
667 ForAllChildrenFunc([disable](int childIdx, IControl* pChild) {
668 pChild->SetDisabled(disable);
669 });
670
671 IControl::SetDisabled(disable);
672 }
673
674 void Hide(bool hide) override
675 {
676 ForAllChildrenFunc([hide](int childIdx, IControl* pChild) {
677 pChild->Hide(hide);
678 });
679
680 IControl::Hide(hide);
681 }
682
683 IControl* AddChildControl(IControl* pControl, int ctrlTag = kNoTag, const char* group = "")
684 {
685 pControl->SetParent(this);
686 return mChildren.Add(GetUI()->AttachControl(pControl, ctrlTag, group));
687 }
688
689 void RemoveChildControl(IControl* pControl)
690 {
691 pControl->SetParent(nullptr);
692 mChildren.DeletePtr(pControl, false);
693 GetUI()->RemoveControl(pControl);
694 }
695
696 IControl* GetChild(int idx)
697 {
698 return mChildren.Get(idx);
699 }
700
701 int NChildren() const { return mChildren.GetSize(); }
702
703 void ForAllChildrenFunc(std::function<void(int childIdx, IControl* pControl)> func)
704 {
705 for (int i=0; i<mChildren.GetSize(); i++)
706 {
707 func(i, mChildren.Get(i));
708 }
709 }
710
711protected:
712 AttachFunc mAttachFunc = nullptr;
713 ResizeFunc mResizeFunc = nullptr;
714 WDL_PtrList<IControl> mChildren;
715};
716
719{
720public:
723 IBitmapBase(const IBitmap& bitmap)
724 : mBitmap(bitmap)
725 {
726 }
727
728 virtual ~IBitmapBase() {}
729
732 void AttachIControl(IControl* pControl) { mControl = pControl; }
733
737 {
738 int i = 1;
739
740 if (mBitmap.N() > 1)
741 {
742 i = 1 + int(0.5 + mControl->GetValue() * static_cast<double>(mBitmap.N() - 1));
743 i = Clip(i, 1, mBitmap.N());
744 }
745 IBlend blend = mControl->GetBlend();
746 g.DrawBitmap(mBitmap, mControl->GetRECT().GetCentredInside(IRECT(0, 0, mBitmap)), i, &blend);
747 }
748
749protected:
750 IBitmap mBitmap;
751 IControl* mControl = nullptr;
752};
753
757{
758public:
763 IVectorBase(const IVStyle& style, bool labelInWidget = false, bool valueInWidget = false)
764 : mLabelInWidget(labelInWidget)
765 , mValueInWidget(valueInWidget)
766 {
767 SetStyle(style);
768 }
769
770 virtual ~IVectorBase() {}
771
775 void AttachIControl(IControl* pControl, const char* label)
776 {
777 mControl = pControl;
778 mLabelStr.Set(label);
779 }
780
782 virtual void OnStyleChanged() { /* NO-OP */ }
783
787 void SetColor(EVColor colorIdx, const IColor& color)
788 {
789 mStyle.colorSpec.mColors[static_cast<int>(colorIdx)] = color;
790 mControl->SetDirty(false);
791 }
792
795 void SetColors(const IVColorSpec& spec)
796 {
797 mStyle.colorSpec = spec;
798 }
799
801 const IColor& GetColor(EVColor color) const
802 {
803 return mStyle.colorSpec.GetColor(color);
804 }
805
806 void SetLabelStr(const char* label) { mLabelStr.Set(label); mControl->SetDirty(false); OnStyleChanged(); }
807 const char* GetLabelStr() const { return mLabelStr.Get(); }
808 void SetValueStr(const char* value) { mValueStr.Set(value); mControl->SetDirty(false); OnStyleChanged(); }
809 void SetWidgetFrac(float frac) { mStyle.widgetFrac = Clip(frac, 0.f, 1.f); mControl->OnResize(); mControl->SetDirty(false); OnStyleChanged(); }
810 void SetAngle(float angle) { mStyle.angle = Clip(angle, 0.f, 360.f); mControl->SetDirty(false); OnStyleChanged(); }
811 void SetShowLabel(bool show) { mStyle.showLabel = show; mControl->OnResize(); mControl->SetDirty(false); OnStyleChanged(); }
812 void SetShowValue(bool show) { mStyle.showValue = show; mControl->OnResize(); mControl->SetDirty(false); OnStyleChanged(); }
813 void SetRoundness(float roundness) { mStyle.roundness = Clip(roundness, 0.f, 1.f); mControl->SetDirty(false); OnStyleChanged(); }
814 void SetDrawFrame(bool draw) { mStyle.drawFrame = draw; mControl->SetDirty(false); OnStyleChanged(); }
815 void SetDrawShadows(bool draw) { mStyle.drawShadows = draw; mControl->SetDirty(false); OnStyleChanged(); }
816 void SetEmboss(bool draw) { mStyle.emboss = draw; mControl->SetDirty(false); OnStyleChanged(); }
817 void SetShadowOffset(float offset) { mStyle.shadowOffset = offset; mControl->SetDirty(false); OnStyleChanged(); }
818 void SetFrameThickness(float thickness) { mStyle.frameThickness = thickness; mControl->SetDirty(false); OnStyleChanged(); }
819 void SetSplashRadius(float radius) { mSplashRadius = radius * mMaxSplashRadius; OnStyleChanged(); }
820 void SetSplashPoint(float x, float y) { mSplashPoint.x = x; mSplashPoint.y = y; OnStyleChanged(); }
821 void SetShape(EVShape shape) { mShape = shape; mControl->SetDirty(false); OnStyleChanged(); }
822
825 virtual void SetStyle(const IVStyle& style)
826 {
827 mStyle = style;
828 SetColors(style.colorSpec);
830 }
831
834 IVStyle GetStyle() const { return mStyle; }
835
840 {
841 if (mStyle.drawFrame)
842 handleBounds.Pad(- 0.5f * mStyle.frameThickness);
843
844 if (mStyle.drawShadows)
845 handleBounds.Offset(mStyle.shadowOffset, 0, -mStyle.shadowOffset, -mStyle.shadowOffset);
846
847 return handleBounds;
848 }
849
853 float GetRoundedCornerRadius(const IRECT& bounds) const
854 {
855 if (bounds.W() < bounds.H())
856 return mStyle.roundness * (bounds.W() / 2.f);
857 else
858 return mStyle.roundness * (bounds.H() / 2.f);
859 }
860
861 IRECT GetWidgetBounds() const { return mWidgetBounds; }
862 IRECT GetLabelBounds() const { return mLabelBounds; }
863 IRECT GetValueBounds() const { return mValueBounds; }
864
868 void DrawSplash(IGraphics& g, const IRECT& clipRegion = IRECT())
869 {
870 g.PathClipRegion(clipRegion);
871 g.FillCircle(GetColor(kHL), mSplashPoint.x, mSplashPoint.y, mSplashRadius);
873 }
874
876 virtual void DrawBackground(IGraphics& g, const IRECT& rect)
877 {
878 IBlend blend = mControl->GetBlend();
879 g.FillRect(GetColor(kBG), rect, &blend);
880 }
881
883 virtual void DrawWidget(IGraphics& g)
884 {
885 // NO-OP
886 }
887
889 virtual void DrawLabel(IGraphics& g)
890 {
891 if (mLabelBounds.H() && mStyle.showLabel)
892 {
893 IBlend blend = mControl->GetBlend();
894 g.DrawText(mStyle.labelText, mLabelStr.Get(), mLabelBounds, &blend);
895 }
896 }
897
899 virtual void DrawValue(IGraphics& g, bool mouseOver)
900 {
901 if(mouseOver)
902 g.FillRect(COLOR_TRANSLUCENT, mValueBounds);
903
904 if (mStyle.showValue)
905 {
906 IBlend blend = mControl->GetBlend();
907 g.DrawText(mStyle.valueText, mValueStr.Get(), mValueBounds, &blend);
908 }
909 }
910
918 virtual void DrawPressableShape(IGraphics& g, EVShape shape, const IRECT& bounds, bool pressed, bool mouseOver, bool disabled)
919 {
920 switch (shape)
921 {
922 case EVShape::Ellipse:
923 DrawPressableEllipse(g, bounds, pressed, mouseOver, disabled);
924 break;
925 case EVShape::Rectangle:
926 DrawPressableRectangle(g, bounds, pressed, mouseOver, disabled);
927 break;
928 case EVShape::Triangle:
929 DrawPressableTriangle(g, bounds, pressed, mouseOver, mStyle.angle, disabled);
930 break;
931 case EVShape::EndsRounded:
932 DrawPressableRectangle(g, bounds, pressed, mouseOver, disabled, true, true, false, false);
933 break;
934 case EVShape::AllRounded:
935 DrawPressableRectangle(g, bounds, pressed, mouseOver, disabled, true, true, true, true);
936 break;
937 default:
938 break;
939 }
940 }
941
948 void DrawPressableEllipse(IGraphics& g, const IRECT& bounds, bool pressed, bool mouseOver, bool disabled)
949 {
950 IRECT handleBounds = bounds;
951 IRECT centreBounds = bounds.GetPadded(-mStyle.shadowOffset);
952 IRECT shadowBounds = bounds.GetTranslated(mStyle.shadowOffset, mStyle.shadowOffset);
953 const IBlend blend = mControl->GetBlend();
954 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
955
956 if(!pressed && !disabled && mStyle.drawShadows)
957 g.FillEllipse(GetColor(kSH), shadowBounds);
958
959 if (pressed)
960 {
961 if (mStyle.emboss)
962 {
963 shadowBounds.ReduceFromRight(mStyle.shadowOffset);
964 shadowBounds.ReduceFromBottom(mStyle.shadowOffset);
965 // Fill background with pressed color and shade it
966 g.FillEllipse(GetColor(kPR), bounds, &blend);
967 g.FillEllipse(GetColor(kSH), bounds, &blend);
968
969 // Inverse shading for recessed look - shadowBounds = inner shadow
970 g.FillEllipse(GetColor(kFG).WithContrast(contrast), shadowBounds/*, &blend*/);
971
972 // Fill in center with pressed color
973 g.FillEllipse(GetColor(kPR).WithContrast(contrast), centreBounds/*, &blend*/);
974 }
975 else
976 g.FillEllipse(GetColor(kPR).WithContrast(contrast), handleBounds/*, &blend*/);
977 }
978 else
979 {
980 // Embossed style unpressed
981 if (mStyle.emboss)
982 {
983 // Positive light TODO: use thes kPR color for now, maybe change the name?
984 g.FillEllipse(GetColor(kPR).WithContrast(contrast), bounds/*, &blend*/);
985
986 // Negative light TODO: clip this?
987 g.FillEllipse(GetColor(kSH).WithContrast(contrast), shadowBounds/*, &blend*/);
988
989 // Fill in foreground
990 g.FillEllipse(GetColor(kFG).WithContrast(contrast), centreBounds/*, &blend*/);
991
992 // Shade when hovered
993 if (mouseOver)
994 g.FillEllipse(GetColor(kHL), centreBounds, &blend);
995 }
996 else
997 {
998 g.FillEllipse(GetColor(kFG).WithContrast(contrast), handleBounds/*, &blend*/);
999
1000 // Shade when hovered
1001 if (mouseOver)
1002 g.FillEllipse(GetColor(kHL), handleBounds, &blend);
1003 }
1004 }
1005
1006 if (pressed && mControl->GetAnimationFunction())
1007 DrawSplash(g, handleBounds);
1008
1009 if (mStyle.drawFrame)
1010 g.DrawEllipse(GetColor(kFR), handleBounds, &blend, mStyle.frameThickness);
1011 }
1012
1020 IRECT DrawPressableRectangle(IGraphics&g, const IRECT& bounds, bool pressed, bool mouseOver, bool disabled,
1021 bool rtl = true, bool rtr = true, bool rbl = true, bool rbr = true)
1022 {
1023 IRECT handleBounds = GetAdjustedHandleBounds(bounds);
1024 IRECT centreBounds = handleBounds.GetPadded(-mStyle.shadowOffset);
1025 IRECT shadowBounds = handleBounds.GetTranslated(mStyle.shadowOffset, mStyle.shadowOffset);
1026 const IBlend blend = mControl->GetBlend();
1027 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1028 float cR = GetRoundedCornerRadius(handleBounds);
1029
1030 const float tlr = rtl ? cR : 0.f;
1031 const float trr = rtr ? cR : 0.f;
1032 const float blr = rbl ? cR : 0.f;
1033 const float brr = rbr ? cR : 0.f;
1034
1035 if (pressed)
1036 {
1037 shadowBounds.ReduceFromRight(mStyle.shadowOffset);
1038 shadowBounds.ReduceFromBottom(mStyle.shadowOffset);
1039
1040 if (mStyle.emboss)
1041 {
1042 // Fill background with pressed color and shade it
1043 g.FillRoundRect(GetColor(kPR), handleBounds, tlr, trr, blr, brr, &blend);
1044 g.FillRoundRect(GetColor(kSH), handleBounds, tlr, trr, blr, brr, &blend);
1045
1046 // Inverse shading for recessed look - shadowBounds = inner shadow
1047 g.FillRoundRect(GetColor(kFG).WithContrast(contrast), shadowBounds, tlr, trr, blr, brr/*, &blend*/);
1048
1049 // Fill in center with pressed color
1050 g.FillRoundRect(GetColor(kPR), centreBounds, tlr, trr, blr, brr, &blend);
1051 }
1052 else
1053 {
1054 g.FillRoundRect(GetColor(kPR).WithContrast(contrast), handleBounds, tlr, trr, blr, brr/*, &blend*/);
1055 }
1056 }
1057 else
1058 {
1059 // outer shadow
1060 if (mStyle.drawShadows)
1061 g.FillRoundRect(GetColor(kSH), shadowBounds, tlr, trr, blr, brr, &blend);
1062
1063 // Embossed style unpressed
1064 if (mStyle.emboss)
1065 {
1066 // Positive light TODO: use thes kPR color for now, maybe change the name?
1067 g.FillRoundRect(GetColor(kPR).WithContrast(contrast), handleBounds, tlr, trr, blr, brr/*, &blend*/);
1068
1069 // Negative light TODO: clip this?
1070 g.FillRoundRect(GetColor(kSH).WithContrast(contrast), shadowBounds, tlr, trr, blr, brr/*, &blend*/);
1071
1072 // Fill in foreground
1073 g.FillRoundRect(GetColor(kFG).WithContrast(contrast), centreBounds, tlr, trr, blr, brr/*, &blend*/);
1074
1075 // Shade when hovered
1076 if (mouseOver)
1077 g.FillRoundRect(GetColor(kHL), centreBounds, tlr, trr, blr, brr, &blend);
1078 }
1079 else
1080 {
1081 g.FillRoundRect(GetColor(kFG).WithContrast(contrast), handleBounds, tlr, trr, blr, brr/*, &blend*/);
1082
1083 // Shade when hovered
1084 if (mouseOver)
1085 g.FillRoundRect(GetColor(kHL), handleBounds, tlr, trr, blr, brr, &blend);
1086 }
1087 }
1088
1089 if (pressed && mControl->GetAnimationFunction())
1090 DrawSplash(g, handleBounds);
1091
1092 if (mStyle.drawFrame)
1093 g.DrawRoundRect(GetColor(kFR), handleBounds, tlr, trr, blr, brr, &blend, mStyle.frameThickness);
1094
1095 return handleBounds;
1096 }
1097
1103 IRECT DrawPressableTriangle(IGraphics&g, const IRECT& bounds, bool pressed, bool mouseOver, float angle, bool disabled)
1104 {
1105 float x1, x2, x3, y1, y2, y3;
1106
1107 float theta = DegToRad(angle);
1108
1109 IRECT handleBounds = GetAdjustedHandleBounds(bounds);
1110
1111 // Center bounds around origin for rotation
1112 float xT = handleBounds.L + handleBounds.W() * 0.5f;
1113 float yT = handleBounds.T + handleBounds.H() * 0.5f;
1114 IRECT centered = handleBounds.GetTranslated(-xT, -yT);
1115
1116 // Do rotation and translate points back into view space
1117 float c = cosf(theta);
1118 float s = sinf(theta);
1119 x1 = centered.L * c - centered.B * s + xT;
1120 y1 = centered.L * s + centered.B * c + yT;
1121 x2 = centered.MW() * c - centered.T * s + xT;
1122 y2 = centered.MW() * s + centered.T * c + yT;
1123 x3 = centered.R * c - centered.B * s + xT;
1124 y3 = centered.R * s + centered.B * c + yT;
1125
1126 const IBlend blend = mControl->GetBlend();
1127 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1128
1129 if (pressed)
1130 g.FillTriangle(GetColor(kPR).WithContrast(contrast), x1, y1, x2, y2, x3, y3/*, &blend*/);
1131 else
1132 {
1133 //outer shadow
1134 if (mStyle.drawShadows)
1135 g.FillTriangle(GetColor(kSH), x1 + mStyle.shadowOffset, y1 + mStyle.shadowOffset,
1136 x2 + mStyle.shadowOffset, y2 + mStyle.shadowOffset,
1137 x3 + mStyle.shadowOffset, y3 + mStyle.shadowOffset, &blend);
1138
1139 g.FillTriangle(GetColor(kFG).WithContrast(contrast), x1, y1, x2, y2, x3, y3/*, &blend*/);
1140 }
1141
1142 if (mouseOver)
1143 g.FillTriangle(GetColor(kHL), x1, y1, x2, y2, x3, y3, &blend);
1144
1145 if(pressed && mControl->GetAnimationFunction())
1146 DrawSplash(g);
1147
1148 if (mStyle.drawFrame)
1149 g.DrawTriangle(GetColor(kFR), x1, y1, x2, y2, x3, y3, &blend, mStyle.frameThickness);
1150
1151 return handleBounds;
1152 }
1153
1158 IRECT MakeRects(const IRECT& parent, bool hasHandle = false)
1159 {
1160 IRECT clickableArea = parent;
1161
1162 if(!mLabelInWidget)
1163 {
1164 if(mStyle.showLabel && CStringHasContents(mLabelStr.Get()))
1165 {
1166 IRECT textRect;
1167 mControl->GetUI()->MeasureText(mStyle.labelText, mLabelStr.Get(), textRect);
1168
1169 switch (mStyle.labelOrientation)
1170 {
1171 case EOrientation::North:
1172 mLabelBounds = parent.GetFromTop(textRect.H()).GetCentredInside(textRect.W(), textRect.H());
1173 break;
1174 case EOrientation::East:
1175 mLabelBounds = parent.GetFromRight(textRect.W()).GetCentredInside(textRect.W(), textRect.H());
1176 break;
1177 case EOrientation::South:
1178 mLabelBounds = parent.GetFromBottom(textRect.H()).GetCentredInside(textRect.W(), textRect.H());
1179 break;
1180 case EOrientation::West:
1181 mLabelBounds = parent.GetFromLeft(textRect.W()).GetCentredInside(textRect.W(), textRect.H());
1182 break;
1183 }
1184 }
1185 else
1186 mLabelBounds = IRECT();
1187
1188 if (!mLabelBounds.Empty())
1189 {
1190 switch (mStyle.labelOrientation)
1191 {
1192 case EOrientation::North:
1193 clickableArea = parent.GetReducedFromTop(mLabelBounds.H());
1194 break;
1195 case EOrientation::East:
1196 clickableArea = parent.GetReducedFromRight(mLabelBounds.W());
1197 break;
1198 case EOrientation::South:
1199 clickableArea = parent.GetReducedFromBottom(mLabelBounds.H());
1200 break;
1201 case EOrientation::West:
1202 clickableArea = parent.GetReducedFromLeft(mLabelBounds.W());
1203 break;
1204 }
1205 }
1206 }
1207
1208 if (mStyle.showValue && !mValueInWidget)
1209 {
1210 IRECT textRect;
1211
1212 if(CStringHasContents(mValueStr.Get()))
1213 mControl->GetUI()->MeasureText(mStyle.valueText, mValueStr.Get(), textRect);
1214
1215 const float valueDisplayWidth = textRect.W() * mValueDisplayFrac;
1216
1217 switch (mStyle.valueText.mVAlign)
1218 {
1219 case EVAlign::Middle:
1220 mValueBounds = clickableArea.GetMidVPadded(textRect.H()/2.f).GetMidHPadded(valueDisplayWidth);
1221 mWidgetBounds = clickableArea.GetScaledAboutCentre(mStyle.widgetFrac);
1222 break;
1223 case EVAlign::Bottom:
1224 {
1225 mValueBounds = clickableArea.GetFromBottom(textRect.H()).GetMidHPadded(valueDisplayWidth);
1226 mWidgetBounds = clickableArea.GetReducedFromBottom(textRect.H()).GetScaledAboutCentre(mStyle.widgetFrac);
1227 break;
1228 }
1229 case EVAlign::Top:
1230 mValueBounds = clickableArea.GetFromTop(textRect.H()).GetMidHPadded(valueDisplayWidth);
1231 mWidgetBounds = clickableArea.GetReducedFromTop(textRect.H()).GetScaledAboutCentre(mStyle.widgetFrac);
1232 break;
1233 default:
1234 break;
1235 }
1236 }
1237 else
1238 {
1239 mWidgetBounds = clickableArea.GetScaledAboutCentre(mStyle.widgetFrac);
1240 }
1241
1242 if(hasHandle)
1243 mWidgetBounds = GetAdjustedHandleBounds(clickableArea).GetScaledAboutCentre(mStyle.widgetFrac);
1244
1245 if(mLabelInWidget)
1246 mLabelBounds = mWidgetBounds;
1247
1248 if(mValueInWidget)
1249 mValueBounds = mWidgetBounds;
1250
1251 return clickableArea;
1252 }
1253
1254protected:
1255 IControl* mControl = nullptr;
1256 IVStyle mStyle; // IVStyle that defines certain common properties of an IVControl
1257 bool mLabelInWidget = false; // Should the Label text be displayed inside the widget
1258 bool mValueInWidget = false; // Should the Value text be displayed inside the widget
1259 float mSplashRadius = 0.f; // Modified during the default SplashClickAnimationFunc to specify the radius of the splash
1260 IVec2 mSplashPoint = {0.f, 0.f}; // Set at the start of the SplashClickActionFunc to set the position of the splash
1261 float mMaxSplashRadius = 50.f;
1262 float mTrackSize = 2.f;
1263 float mValueDisplayFrac = 0.66f; // the fraction of the control width for the text entry
1264 IRECT mWidgetBounds; // The knob/slider/button
1265 IRECT mLabelBounds; // A piece of text above the control
1266 IRECT mValueBounds; // Text below the contol, usually displaying the value of a parameter
1267 WDL_String mLabelStr;
1268 WDL_String mValueStr;
1269 EVShape mShape = EVShape::Rectangle;
1270};
1271
1274{
1275public:
1277 {
1278 int index = 0;
1279 float x = 0.f;
1280 float y = 0.f;
1281 float sx = 0.f;
1282 float sy = 0.f;
1283 float radius = 1.f;
1284 TimePoint startTime;
1285
1286 TrackedTouch(int index, float x, float y, float radius, TimePoint time)
1287 : index(index), x(x), y(y), sx(x), sy(y), radius(radius), startTime(time)
1288 {}
1289
1290 TrackedTouch()
1291 {}
1292 };
1293
1294 virtual ~IMultiTouchControlBase() {}
1295
1296 virtual void AddTouch(ITouchID touchID, float x, float y, float radius)
1297 {
1298 int touchIndex = 0;
1299 for (int i = 0; i < MAX_TOUCHES; i++)
1300 {
1301 if (mTouchStatus[i] == false)
1302 {
1303 touchIndex = i;
1304 mTouchStatus[i] = true;
1305 break;
1306 }
1307 }
1308
1309 if(NTrackedTouches() < MAX_TOUCHES)
1310 mTrackedTouches.insert(std::make_pair(touchID, TrackedTouch(touchIndex, x, y, radius, std::chrono::high_resolution_clock::now())));
1311 }
1312
1313 virtual void ReleaseTouch(ITouchID touchID)
1314 {
1315 mTouchStatus[GetTouchWithIdentifier(touchID)->index] = false;
1316 mTrackedTouches.erase(touchID);
1317 }
1318
1319 virtual void UpdateTouch(ITouchID touchID, float x, float y, float radius)
1320 {
1321 mTrackedTouches[touchID].x = x;
1322 mTrackedTouches[touchID].y = y;
1323 mTrackedTouches[touchID].radius = radius;
1324 }
1325
1326 void ClearAllTouches()
1327 {
1328 mTrackedTouches.clear();
1329 memset(mTouchStatus, 0, MAX_TOUCHES * sizeof(bool));
1330 }
1331
1332 int NTrackedTouches() const
1333 {
1334 return static_cast<int>(mTrackedTouches.size());
1335 }
1336
1337 TrackedTouch* GetTouch(int index)
1338 {
1339 auto itr = std::find_if(mTrackedTouches.begin(), mTrackedTouches.end(),
1340 [index](auto element) {
1341 return(element.second.index == index);
1342 });
1343
1344 if(itr != mTrackedTouches.end())
1345 return &itr->second;
1346 else
1347 return nullptr;
1348 }
1349
1350 TrackedTouch* GetTouchWithIdentifier(ITouchID touchID)
1351 {
1352 auto itr = mTrackedTouches.find(touchID);
1353
1354 if(itr != mTrackedTouches.end())
1355 return &itr->second;
1356 else
1357 return nullptr;
1358 }
1359
1360protected:
1361 static constexpr int MAX_TOUCHES = 10;
1362 std::unordered_map<ITouchID, TrackedTouch> mTrackedTouches;
1363 bool mTouchStatus[MAX_TOUCHES] = { 0 };
1364};
1365
1368{
1369public:
1370 IKnobControlBase(const IRECT& bounds, int paramIdx = kNoParameter, EDirection direction = EDirection::Vertical, double gearing = DEFAULT_GEARING)
1371 : IControl(bounds, paramIdx)
1372 , mDirection(direction)
1373 , mGearing(gearing)
1374 {}
1375
1376 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
1377 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
1378 void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override;
1379 void OnMouseWheel(float x, float y, const IMouseMod& mod, float d) override;
1380
1381 void SetGearing(double gearing) { mGearing = gearing; }
1382 bool IsFineControl(const IMouseMod& mod, bool wheel) const;
1383
1384protected:
1387 virtual IRECT GetKnobDragBounds() { return mTargetRECT; }
1388
1389 bool mHideCursorOnDrag = true;
1390 EDirection mDirection;
1391 double mGearing;
1392 bool mMouseDown = false;
1393 double mMouseDragValue = 0.0;
1394};
1395
1398{
1399public:
1400 ISliderControlBase(const IRECT& bounds, int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING, float handleSize = 0.f);
1401 ISliderControlBase(const IRECT& bounds, IActionFunction aF = nullptr, EDirection dir = EDirection::Vertical, double gearing = DEFAULT_GEARING, float handleSize = 0.f);
1402
1403 void OnResize() override;
1404 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
1405 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
1406 void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override;
1407 void OnMouseWheel(float x, float y, const IMouseMod& mod, float d) override;
1408
1409 void SetGearing(double gearing) { mGearing = gearing; }
1410 bool IsFineControl(const IMouseMod& mod, bool wheel) const;
1411
1412protected:
1413 bool mHideCursorOnDrag = true;
1414 EDirection mDirection;
1415 IRECT mTrackBounds;
1416 float mHandleSize;
1417 double mGearing;
1418 bool mMouseDown = false;
1419 double mMouseDragValue;
1420};
1421
1425 , public IVectorBase
1426{
1427public:
1428 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 = {})
1429 : IControl(bounds)
1430 , IVectorBase(style)
1431 , mDirection(dir)
1432 , mNSteps(nSteps)
1433 {
1434 SetNVals(maxNTracks);
1435 mTrackBounds.Resize(maxNTracks);
1436
1437 for (int i=0; i<maxNTracks; i++)
1438 {
1439 SetParamIdx(kNoParameter, i);
1440 }
1441
1442 if(trackNames.size())
1443 {
1444 assert(trackNames.size() == maxNTracks); // check that the trackNames list size matches the number of tracks
1445
1446 for (auto& trackName : trackNames)
1447 {
1448 mTrackNames.Add(new WDL_String(trackName));
1449 }
1450 }
1451
1452 AttachIControl(this, label);
1453 }
1454
1455 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 = {})
1456 : IControl(bounds)
1457 , IVectorBase(style)
1458 , mDirection(dir)
1459 , mNSteps(nSteps)
1460 {
1461 SetNVals(maxNTracks);
1462 mTrackBounds.Resize(maxNTracks);
1463
1464 for (int i = 0; i < maxNTracks; i++)
1465 {
1466 SetParamIdx(lowParamidx+i, i);
1467 }
1468
1469 if(trackNames.size())
1470 {
1471 assert(trackNames.size() == maxNTracks);
1472
1473 for (auto& trackName : trackNames)
1474 {
1475 mTrackNames.Add(new WDL_String(trackName));
1476 }
1477 }
1478
1479 AttachIControl(this, label);
1480 }
1481
1482 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 = {})
1483 : IControl(bounds)
1484 , IVectorBase(style)
1485 , mDirection(dir)
1486 , mNSteps(nSteps)
1487 {
1488 int maxNTracks = static_cast<int>(params.size());
1489 SetNVals(maxNTracks);
1490 mTrackBounds.Resize(maxNTracks);
1491
1492 int valIdx = 0;
1493 for (auto param : params)
1494 {
1495 SetParamIdx(param, valIdx++);
1496 }
1497
1498 if(trackNames.size())
1499 {
1500 assert(trackNames.size() == params.size());
1501
1502 for (auto& trackName : trackNames)
1503 {
1504 mTrackNames.Add(new WDL_String(trackName));
1505 }
1506 }
1507
1508 AttachIControl(this, label);
1509 }
1510
1511 virtual ~IVTrackControlBase()
1512 {
1513 mTrackNames.Empty(true);
1514 }
1515
1516 void OnMouseOver(float x, float y, const IMouseMod& mod) override
1517 {
1518 mMouseOverTrack = GetValIdxForPos(x, y);
1519 SetDirty(false);
1520 }
1521
1522 void OnMouseOut() override
1523 {
1524 mMouseOverTrack = -1;
1525 SetDirty(false);
1526 }
1527
1528 virtual void OnResize() override
1529 {
1530 SetTargetRECT(MakeRects(mRECT));
1531 MakeTrackRects(mWidgetBounds);
1532 MakeStepRects(mWidgetBounds, mNSteps);
1533 SetDirty(false);
1534 }
1535
1536 int GetValIdxForPos(float x, float y) const override
1537 {
1538 int nVals = NVals();
1539
1540 for (auto v = 0; v < nVals; v++)
1541 {
1542 if (mTrackBounds.Get()[v].Contains(x, y))
1543 {
1544 return v;
1545 }
1546 }
1547
1548 return kNoValIdx;
1549 }
1550
1551 void DrawWidget(IGraphics& g) override
1552 {
1553 const int nVals = NVals();
1554
1555 for (int ch = 0; ch < nVals; ch++)
1556 {
1557 DrawTrack(g, mTrackBounds.Get()[ch], ch);
1558 }
1559 }
1560
1563 void SetParamsByGroup(const char* paramGroup)
1564 {
1565 int nParams = GetDelegate()->NParams();
1566 std::vector<int> paramIdsForGroup;
1567
1568 for (auto p = 0; p < nParams; p++)
1569 {
1570 IParam* pParam = GetDelegate()->GetParam(p);
1571
1572 if(strcmp(pParam->GetGroup(), paramGroup) == 0)
1573 {
1574 paramIdsForGroup.push_back(p);
1575 }
1576 }
1577
1578 SetParams(paramIdsForGroup);
1579 }
1580
1583 void SetParams(const std::vector<int>& paramIds)
1584 {
1585 int nParams = static_cast<int>(paramIds.size());
1586
1587 SetNVals(nParams);
1588 mTrackBounds.Resize(nParams);
1589
1590 int valIdx = 0;
1591 for (auto param : paramIds)
1592 {
1593 SetParamIdx(param, valIdx++);
1594 }
1595
1596 const IParam* pFirstParam = GetParam(0);
1597 const int range = static_cast<int>(pFirstParam->GetRange() / pFirstParam->GetStep());
1598 mZeroValueStepHasBounds = !(range == 1);
1599 SetNSteps(pFirstParam->GetStepped() ? range : 0); // calls OnResize()
1600 }
1601
1602 void SetNTracks(int nTracks)
1603 {
1604 SetNVals(nTracks);
1605 mTrackBounds.Resize(nTracks);
1606 OnResize();
1607 }
1608
1609 void SetBaseValue(double value)
1610 {
1611 mBaseValue = value; OnResize();
1612 }
1613
1614 void SetTrackPadding(float value)
1615 {
1616 mTrackPadding = value; OnResize();
1617 }
1618
1619 void SetPeakSize(float value)
1620 {
1621 mPeakSize = value; OnResize();
1622 }
1623
1624 void SetNSteps(int nSteps)
1625 {
1626 mNSteps = nSteps; OnResize();
1627 }
1628
1629 void SetHighlightedTrack(int highlightIdx)
1630 {
1631 mHighlightedTrack = highlightIdx;
1632 SetDirty(false);
1633 }
1634
1635 void SetZeroValueStepHasBounds(bool val)
1636 {
1637 mZeroValueStepHasBounds = val;
1638 OnResize();
1639 }
1640
1641 bool HasTrackNames() const
1642 {
1643 return mTrackNames.GetSize() > 0;
1644 }
1645
1646 const char* GetTrackName(int chIdx) const
1647 {
1648 WDL_String* pStr = mTrackNames.Get(chIdx);
1649 return pStr ? pStr->Get() : "";
1650 }
1651
1652 void SetTrackName(int chIdx, const char* newName)
1653 {
1654 assert(chIdx >= 0 && chIdx < mTrackNames.GetSize());
1655
1656 if(chIdx >= 0 && chIdx < mTrackNames.GetSize())
1657 {
1658 mTrackNames.Get(chIdx)->Set(newName);
1659 }
1660 }
1661
1662protected:
1663 virtual void DrawBackground(IGraphics& g, const IRECT& r) override
1664 {
1665 g.FillRect(GetColor(kBG), r, &mBlend);
1666
1667 if(mBaseValue > 0.)
1668 {
1669 if(mDirection == EDirection::Horizontal)
1670 g.DrawVerticalLine(GetColor(kSH), r, static_cast<float>(mBaseValue));
1671 else
1672 g.DrawHorizontalLine(GetColor(kSH), r, static_cast<float>(mBaseValue));
1673 }
1674 }
1675
1676 virtual void DrawTrack(IGraphics& g, const IRECT& r, int chIdx)
1677 {
1678 DrawTrackBackground(g, r, chIdx);
1679
1680 if(HasTrackNames())
1681 DrawTrackName(g, r, chIdx);
1682
1683 const float trackPos = static_cast<float>(GetValue(chIdx));
1684
1685 const bool stepped = GetStepped();
1686
1687 IRECT fillRect;
1688 const float bv = static_cast<float>(mBaseValue);
1689
1690 if(bv > 0.f)
1691 {
1692 if(mDirection == EDirection::Vertical)
1693 {
1694 fillRect = IRECT(r.L,
1695 trackPos < bv ? r.B - r.H() * bv : r.B - r.H() * trackPos,
1696 r.R,
1697 trackPos < bv ? r.B - r.H() * trackPos : r.B - r.H() * bv);
1698 }
1699 else
1700 {
1701 fillRect = IRECT(trackPos < bv ? r.L + r.W() * trackPos : r.L + r.W() * bv,
1702 r.T,
1703 trackPos < bv ? r.L + r.W() * bv : r.L + r.W() * trackPos,
1704 r.B);
1705 }
1706 }
1707 else
1708 {
1709 fillRect = r.FracRect(mDirection, trackPos);
1710
1711 if(stepped && mZeroValueStepHasBounds && trackPos == 0.f)
1712 {
1713 if(mDirection == EDirection::Vertical)
1714 fillRect.T = mStepBounds.Get()[0].T;
1715 }
1716 }
1717
1718 if(stepped)
1719 {
1720 int step = GetStepIdxForPos(fillRect.R, fillRect.T);
1721
1722 if (step > -1)
1723 {
1724 if(mDirection == EDirection::Horizontal)
1725 {
1726 fillRect.L = mStepBounds.Get()[step].L;
1727 fillRect.R = mStepBounds.Get()[step].R;
1728 }
1729 else
1730 {
1731 fillRect.T = mStepBounds.Get()[step].T;
1732 fillRect.B = mStepBounds.Get()[step].B;
1733 }
1734 }
1735
1736 if(mZeroValueStepHasBounds || GetValue(chIdx) > 0.)
1737 DrawTrackHandle(g, fillRect, chIdx, trackPos > mBaseValue);
1738 }
1739 else
1740 {
1741 DrawTrackHandle(g, fillRect, chIdx, trackPos > mBaseValue);
1742
1743 IRECT peakRect;
1744
1745 if(mDirection == EDirection::Vertical)
1746 {
1747 peakRect = IRECT(fillRect.L,
1748 trackPos < mBaseValue ? fillRect.B : fillRect.T,
1749 fillRect.R,
1750 trackPos < mBaseValue ? fillRect.B - mPeakSize: fillRect.T + mPeakSize);
1751 }
1752 else
1753 {
1754 peakRect = IRECT(trackPos < mBaseValue ? fillRect.L + mPeakSize : fillRect.R - mPeakSize,
1755 fillRect.T,
1756 trackPos < mBaseValue ? fillRect.L : fillRect.R,
1757 fillRect.B);
1758 }
1759
1760 DrawPeak(g, peakRect, chIdx, trackPos > mBaseValue);
1761 }
1762
1763 if(mStyle.drawFrame && mDrawTrackFrame)
1764 g.DrawRect(GetColor(kFR), r, &mBlend, mStyle.frameThickness);
1765 }
1766
1767 virtual void DrawTrackBackground(IGraphics& g, const IRECT& r, int chIdx)
1768 {
1769 g.FillRect(chIdx == mHighlightedTrack ? this->GetColor(kHL) : COLOR_TRANSPARENT, r);
1770 }
1771
1772 virtual void DrawTrackName(IGraphics& g, const IRECT& r, int chIdx)
1773 {
1774 g.DrawText(mText, GetTrackName(chIdx), r);
1775 }
1776
1782 virtual void DrawTrackHandle(IGraphics& g, const IRECT& r, int chIdx, bool aboveBaseValue)
1783 {
1784 g.FillRect(chIdx == mHighlightedTrack ? GetColor(kX1) : GetColor(kFG), r, &mBlend);
1785
1786 if(chIdx == mMouseOverTrack)
1787 g.FillRect(GetColor(kHL), r, &mBlend);
1788 }
1789
1790 virtual void DrawPeak(IGraphics& g, const IRECT& r, int chIdx, bool aboveBaseValue)
1791 {
1792 g.FillRect(GetColor(kFR), r, &mBlend);
1793 }
1794
1795 int GetStepIdxForPos(float x, float y) const
1796 {
1797 int nSteps = mStepBounds.GetSize();
1798
1799 for (auto v = 0; v < nSteps; v++)
1800 {
1801 if (mStepBounds.Get()[v].ContainsEdge(x, y))
1802 {
1803 return v;
1804 }
1805 }
1806
1807 return -1;
1808 }
1809
1810 virtual void MakeTrackRects(const IRECT& bounds)
1811 {
1812 int nVals = NVals();
1813 int dir = static_cast<int>(mDirection); // 0 = horizontal, 1 = vertical
1814 for (int ch = 0; ch < nVals; ch++)
1815 {
1816 mTrackBounds.Get()[ch] = bounds.SubRect(EDirection(!dir), nVals, ch).
1817 GetPadded(0, -mTrackPadding * (float) dir, -mTrackPadding * (float) !dir, -mTrackPadding);
1818 }
1819 }
1820
1821 virtual void MakeStepRects(const IRECT& bounds, int nSteps)
1822 {
1823 if(nSteps)
1824 {
1825 int dir = static_cast<int>(mDirection);
1826
1827 nSteps += (int) mZeroValueStepHasBounds;
1828
1829 mStepBounds.Resize(nSteps);
1830
1831 for (int step = 0; step < nSteps; step++)
1832 {
1833 mStepBounds.Get()[step] = bounds.SubRect(EDirection(dir), nSteps, nSteps - 1 - step);
1834 }
1835 }
1836 else
1837 mStepBounds.Resize(0);
1838 }
1839
1840 bool GetStepped() const
1841 {
1842 return mStepBounds.GetSize() > 0;
1843 }
1844
1845protected:
1846 EDirection mDirection = EDirection::Vertical;
1847 WDL_TypedBuf<IRECT> mTrackBounds;
1848 WDL_TypedBuf<IRECT> mStepBounds;
1849 WDL_PtrList<WDL_String> mTrackNames;
1850 int mNSteps = 0;
1851 float mTrackPadding = 0.;
1852 float mPeakSize = 1.;
1853 int mHighlightedTrack = -1; // Highlight a single track, e.g. for step sequencer
1854 int mMouseOverTrack = -1;
1855 double mBaseValue = 0.; // 0-1 value to represent the mid-point, i.e. for displaying bipolar data
1856 bool mDrawTrackFrame = true;
1857 bool mZeroValueStepHasBounds = true; // If this is true, there is a separate step for zero, when mNSteps > 0
1858};
1859
1863{
1864public:
1865 IButtonControlBase(const IRECT& bounds, IActionFunction aF);
1866
1867 virtual ~IButtonControlBase() {}
1868 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
1869 void OnEndAnimation() override;
1870};
1871
1874{
1875public:
1876 ISwitchControlBase(const IRECT& bounds, int paramIdx = kNoParameter, IActionFunction aF = nullptr, int numStates = 2);
1877
1878 virtual ~ISwitchControlBase() {}
1879 void OnInit() override;
1880 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
1881 void OnMouseUp(float x, float y, const IMouseMod& mod) override;
1882
1883 int GetSelectedIdx() const { return int(0.5 + GetValue() * (double) (mNumStates - 1)); }
1884
1885 void SetStateDisabled(int stateIdx, bool disabled);
1886 void SetAllStatesDisabled(bool disabled);
1887 bool GetStateDisabled(int stateIdx) const;
1888protected:
1889 int mNumStates;
1890 WDL_TypedBuf<bool> mDisabledState;
1891 bool mMouseDown = false;
1892};
1893
1900{
1901public:
1908 IDirBrowseControlBase(const IRECT& bounds, const char* extension, bool showFileExtensions = true, bool scanRecursively = true, bool showEmptySubmenus = false)
1909 : IContainerBase(bounds)
1910 , mExtension(extension)
1911 , mShowFileExtensions(showFileExtensions)
1912 , mScanRecursively(scanRecursively)
1913 , mShowEmptySubmenus(showEmptySubmenus)
1914 {
1915 }
1916
1917 virtual ~IDirBrowseControlBase();
1918
1919 int NItems() const;
1920
1924 void AddPath(const char* path, const char* displayText);
1925
1927 void ClearPathList();
1928
1930 void SetupMenu();
1931
1933 void SetSelectedFile(const char* filePath);
1934
1936 void GetSelectedFile(WDL_String& path) const;
1937
1939 void CheckSelectedItem();
1940
1941private:
1942 void ScanDirectory(const char* path, IPopupMenu& menuToAddTo);
1943 void CollectSortedItems(IPopupMenu* pMenu);
1944
1945protected:
1946 const bool mScanRecursively;
1947 const bool mShowFileExtensions;
1948 const bool mShowEmptySubmenus;
1949 int mSelectedItemIndex = -1; // index into mItems
1950 IPopupMenu mMainMenu;
1951 WDL_PtrList<WDL_String> mPaths;
1952 WDL_PtrList<WDL_String> mPathLabels;
1953 WDL_PtrList<WDL_String> mFiles;
1954 WDL_PtrList<IPopupMenu::Item> mItems; // ptr to item for each file
1955 WDL_String mExtension;
1956};
1957
1960#pragma mark - BASIC CONTROLS
1961
1969{
1970public:
1971 IPanelControl(const IRECT& bounds, const IColor& color, bool drawFrame = false,
1972 AttachFunc attachFunc = nullptr, ResizeFunc resizeFunc = nullptr)
1973 : IContainerBase(bounds, attachFunc, resizeFunc)
1974 , mPattern(color)
1975 , mDrawFrame(drawFrame)
1976 {
1977 mIgnoreMouse = true;
1978 }
1979
1980 IPanelControl(const IRECT& bounds, const IPattern& pattern, bool drawFrame = false,
1981 AttachFunc attachFunc = nullptr, ResizeFunc resizeFunc = nullptr)
1982 : IContainerBase(bounds, attachFunc, resizeFunc)
1983 , mPattern(pattern)
1984 , mDrawFrame(drawFrame)
1985 {
1986 mIgnoreMouse = true;
1987 }
1988
1989 void Draw(IGraphics& g) override
1990 {
1991 g.PathRect(mRECT);
1992 g.PathFill(mPattern, IFillOptions(), &mBlend);
1993
1994 if (mDrawFrame)
1995 g.DrawRect(COLOR_LIGHT_GRAY, mRECT, &mBlend);
1996 }
1997
1998 void SetPattern(const IPattern& pattern)
1999 {
2000 mPattern = pattern;
2001 SetDirty(false);
2002 }
2003
2004 IPattern GetPattern() const { return mPattern; }
2005
2006private:
2007 IPattern mPattern;
2008 bool mDrawFrame;
2009};
2010
2013{
2014public:
2015 ILambdaControl(const IRECT& bounds, ILambdaDrawFunction drawFunc, int animationDuration = DEFAULT_ANIMATION_DURATION,
2016 bool loopAnimation = false, bool startImmediately = false, int paramIdx = kNoParameter, bool ignoreMouse = false)
2017 : IControl(bounds, paramIdx, DefaultClickActionFunc)
2018 , mDrawFunc(drawFunc)
2019 , mLoopAnimation(loopAnimation)
2020 , mAnimationDuration(animationDuration)
2021 {
2022 if (startImmediately)
2023 SetAnimation(DefaultAnimationFunc, mAnimationDuration);
2024
2025 mIgnoreMouse = ignoreMouse;
2026 mDblAsSingleClick = true;
2027 }
2028
2029 void Draw(IGraphics& g) override
2030 {
2031 if (mDrawFunc)
2032 mDrawFunc(this, g, mRECT);
2033 }
2034
2035 virtual void OnEndAnimation() override // if you override this you must call the base implementation, to free mAnimationFunc
2036 {
2037 if (mLoopAnimation && mAnimationDuration)
2038 StartAnimation(mAnimationDuration);
2039 else
2040 IControl::OnEndAnimation();
2041
2042 SetDirty(false);
2043 }
2044
2045 void OnMouseDown(float x, float y, const IMouseMod& mod) override
2046 {
2047 mMouseInfo.x = x; mMouseInfo.y = y; mMouseInfo.ms = mod;
2048 SetAnimation(DefaultAnimationFunc, mAnimationDuration);
2049 }
2050
2051 void OnMouseUp(float x, float y, const IMouseMod& mod) override
2052 {
2053 mMouseInfo.x = x;
2054 mMouseInfo.y = y;
2055 mMouseInfo.ms = IMouseMod();
2056 SetDirty(false);
2057 }
2058
2059 void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod) override
2060 {
2061 mMouseInfo.x = x;
2062 mMouseInfo.y = y;
2063 mMouseInfo.dX = dX;
2064 mMouseInfo.dY = dY;
2065 mMouseInfo.ms = mod;
2066 SetDirty(false);
2067 }
2068
2069public: // public for easy access :-)
2070 ILayerPtr mLayer;
2071 IMouseInfo mMouseInfo;
2072private:
2073 ILambdaDrawFunction mDrawFunc = nullptr;
2074 bool mLoopAnimation;
2075 int mAnimationDuration;
2076};
2077
2080 , public IBitmapBase
2081{
2082public:
2086 IBitmapControl(float x, float y, const IBitmap& bitmap, int paramIdx = kNoParameter, EBlend blend = EBlend::Default)
2087 : IControl(IRECT(x, y, bitmap), paramIdx)
2088 , IBitmapBase(bitmap)
2089 {
2090 AttachIControl(this);
2091 mBlend = blend;
2092 }
2093
2094 IBitmapControl(const IRECT& bounds, const IBitmap& bitmap, int paramIdx = kNoParameter, EBlend blend = EBlend::Default)
2095 : IControl(bounds, paramIdx)
2096 , IBitmapBase(bitmap)
2097 {
2098 AttachIControl(this);
2099 mBlend = blend;
2100 }
2101
2102 virtual ~IBitmapControl() {}
2103
2104 void Draw(IGraphics& g) override { DrawBitmap(g); }
2105
2107 void OnRescale() override { mBitmap = GetUI()->GetScaledBitmap(mBitmap); }
2108};
2109
2111class ISVGControl : public IControl
2112{
2113public:
2114 ISVGControl(const IRECT& bounds, const ISVG& svg, bool useLayer = false)
2115 : IControl(bounds)
2116 , mUseLayer(useLayer)
2117 , mSVG(svg)
2118 {}
2119
2120 virtual ~ISVGControl() {}
2121
2122 void Draw(IGraphics& g) override
2123 {
2124 if(mUseLayer)
2125 {
2126 if (!g.CheckLayer(mLayer))
2127 {
2128 g.StartLayer(this, mRECT);
2129 g.DrawSVG(mSVG, mRECT);
2130 mLayer = g.EndLayer();
2131 }
2132
2133 g.DrawLayer(mLayer, &mBlend);
2134 }
2135 else
2136 g.DrawSVG(mSVG, mRECT, &mBlend);
2137 }
2138
2139 void SetSVG(const ISVG& svg)
2140 {
2141 mSVG = svg;
2142 }
2143
2144private:
2145 bool mUseLayer;
2146 ILayerPtr mLayer;
2147 ISVG mSVG;
2148};
2149
2152{
2153public:
2154 ITextControl(const IRECT& bounds, const char* str = "", const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR, bool setBoundsBasedOnStr = false);
2155
2156 void Draw(IGraphics& g) override;
2157 void OnInit() override;
2158
2161 virtual void SetStr(const char* str);
2162
2165 virtual void SetStrFmt(int maxlen, const char* fmt, ...);
2166
2168 virtual void ClearStr() { SetStr(""); }
2169
2171 const char* GetStr() const { return mStr.Get(); }
2172
2174 void SetBoundsBasedOnStr();
2175
2176protected:
2177 WDL_String mStr;
2178 IColor mBGColor;
2179 bool mSetBoundsBasedOnStr = false;
2180};
2181
2184{
2185public:
2186 IEditableTextControl(const IRECT& bounds, const char* str, const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR)
2187 : ITextControl(bounds, str, text, BGColor)
2188 {
2189 mIgnoreMouse = false;
2190 }
2191
2192 void OnMouseDown(float x, float y, const IMouseMod& mod) override
2193 {
2194 GetUI()->CreateTextEntry(*this, mText, mRECT, GetStr());
2195 }
2196
2197 void OnTextEntryCompletion(const char* str, int valIdx) override
2198 {
2199 SetStr(str);
2200 SetDirty(true);
2201 }
2202};
2203
2206{
2207public:
2208 IMultiLineTextControl(const IRECT& bounds, const char* str, const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR)
2209 : ITextControl(bounds, str, text, BGColor)
2210 {
2211 }
2212
2213 void Draw(IGraphics& g) override
2214 {
2215 g.FillRect(mBGColor, mRECT, &mBlend);
2216 g.DrawMultiLineText(mText, mStr.Get(), mRECT, &mBlend);
2217 }
2218};
2219
2220
2223{
2224public:
2225 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);
2226
2227 void Draw(IGraphics& g) override;
2228
2229 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
2230 void OnMouseOver(float x, float y, const IMouseMod& mod) override { GetUI()->SetMouseCursor(ECursor::HAND); IControl::OnMouseOver(x, y, mod); };
2232 void SetText(const IText&) override;
2233
2235 void SetMOColor(const IColor& color) { mMOColor = color; SetDirty(false); }
2236
2238 void SetCLColor(const IColor& color) { mCLColor = color; SetDirty(false); }
2239
2240protected:
2241 WDL_String mURLStr;
2242 IColor mOriginalColor, mMOColor, mCLColor;
2243 bool mClicked = false;
2244};
2245
2248{
2249public:
2250 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);
2251
2252 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);
2253
2254 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
2255 void SetDirty(bool push, int valIdx = 0) override;
2256protected:
2257 WDL_String mOffText;
2258 WDL_String mOnText;
2259};
2260
2263{
2264public:
2271 ICaptionControl(const IRECT& bounds, int paramIdx, const IText& text = DEFAULT_TEXT, const IColor& BGColor = DEFAULT_BGCOLOR, bool showParamLabel = true);
2272 void Draw(IGraphics& g) override;
2273 void OnMouseDown(float x, float y, const IMouseMod& mod) override;
2274 void OnResize() override;
2275protected:
2276 bool mShowParamLabel;
2277 IColor mTriangleColor = COLOR_BLACK;
2278 IColor mTriangleMouseOverColor = COLOR_WHITE;
2279 IRECT mTri;
2280};
2281
2284{
2285public:
2286 PlaceHolder(const IRECT& bounds, const char* str = "Place Holder");
2287
2288 void Draw(IGraphics& g) override;
2289 void OnMouseDblClick(float x, float y, const IMouseMod& mod) override { GetUI()->CreateTextEntry(*this, mText, mRECT, mStr.Get()); }
2290 void OnTextEntryCompletion(const char* str, int valIdx) override { SetStr(str); }
2291 void OnResize() override;
2292
2293protected:
2294 IRECT mCentreLabelBounds;
2295 WDL_String mTLHCStr;
2296 WDL_String mWidthStr;
2297 WDL_String mHeightStr;
2298 IText mTLGCText = DEFAULT_TEXT.WithAlign(EAlign::Near);
2299 IText mWidthText = DEFAULT_TEXT;
2300 IText mHeightText = DEFAULT_TEXT.WithAngle(270.f);
2301 static constexpr float mInset = 10.f;
2302};
2303
2304END_IGRAPHICS_NAMESPACE
2305END_IPLUG_NAMESPACE
2306
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:719
void AttachIControl(IControl *pControl)
Call in the constructor of your IBControl to link the IBitmapBase and IControl.
Definition: IControl.h:732
IBitmapBase(const IBitmap &bitmap)
IBitmapBase Constructor.
Definition: IControl.h:723
void DrawBitmap(IGraphics &g)
Draw a frame of a multi-frame bitmap based on the IControl value.
Definition: IControl.h:736
A basic control to draw a bitmap, or one frame of a stacked bitmap depending on the current value.
Definition: IControl.h:2081
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:2104
IBitmapControl(float x, float y, const IBitmap &bitmap, int paramIdx=kNoParameter, EBlend blend=EBlend::Default)
Creates a bitmap control.
Definition: IControl.h:2086
void OnRescale() override
If you override this make sure you call the parent method in order to rescale mBitmap.
Definition: IControl.h:2107
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:1863
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:709
A control to display the textual representation of a parameter.
Definition: IControl.h:2263
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:646
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:606
void Hide(bool hide) override
Shows or hides the IControl.
Definition: IControl.h:674
virtual void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.h:659
virtual void OnAttached() override
Called after the control has been attached, and its delegate and graphics member variable set.
Definition: IControl.h:651
void SetDisabled(bool disable) override
Sets disabled mode for the control, the default implementation modifies the mBlend member.
Definition: IControl.h:665
virtual void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:641
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
const IGraphics * GetUI() const
Definition: IControl.h:470
virtual bool GetWantsGestures() const
Definition: IControl.h:441
bool GetMouseIsOver() const
This can be used in IControl::Draw() to check if the mouse is over the control, without implementing ...
Definition: IControl.h:474
WDL_String mGroup
Controls can be grouped for hiding and showing panels.
Definition: IControl.h:543
IBlend GetBlend() const
Get the Blend for this control.
Definition: IControl.h:299
void SetMouseOverWhenDisabled(bool allow)
Specify whether the control should respond to mouse overs when disabled.
Definition: IControl.h:366
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:284
bool GetWantsMidi() const
Definition: IControl.h:427
Milliseconds GetAnimationDuration() const
Get the duration of animations applied to the control.
Definition: IControl.h:509
virtual void SetIgnoreMouse(bool ignore)
Specify whether the control should respond to mouse events.
Definition: IControl.h:383
int GetTextEntryLength() const
Get the max number of characters that are allowed in text entry.
Definition: IControl.h:303
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:467
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:433
void SetWantsMultiTouch(bool enable=true)
Specify whether this control supports multiple touches.
Definition: IControl.h:430
const char * GetTooltip() const
Definition: IControl.h:219
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:418
bool GetMouseEventsWhenDisabled() const
Definition: IControl.h:376
bool mMouseIsOver
if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control.
Definition: IControl.h:560
bool GetMouseOverWhenDisabled() const
Definition: IControl.h:373
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:370
void SetWantsMidi(bool enable=true)
Specify whether this control wants to know about MIDI messages sent to the UI.
Definition: IControl.h:424
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:280
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:362
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:503
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:395
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:452
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:319
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:311
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:323
bool GetIgnoreMouse() const
Definition: IControl.h:379
IGEditorDelegate * GetDelegate()
Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes...
Definition: IControl.h:449
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:292
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:421
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:389
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:211
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:527
T * As()
Helper function to dynamic cast an IControl to a subclass.
Definition: IControl.h:513
const IText & GetText() const
Get the Text object for the control.
Definition: IControl.h:288
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:348
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:181
void SetRECT(const IRECT &bounds)
Set the rectangular draw area for this control, within the graphics context.
Definition: IControl.h:315
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:216
void SetAnimation(IAnimationFunction func, int duration)
Set the animation function and starts it.
Definition: IControl.h:497
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:327
virtual void OnContextSelection(int itemSelected)
Implement this to respond to a menu selection from CreateContextMenu();.
Definition: IControl.h:184
void SetBlend(const IBlend &blend)
Set the Blend for this control.
Definition: IControl.h:296
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:245
int NVals() const
Definition: IControl.h:239
IContainerBase * GetParent() const
Definition: IControl.h:462
IAnimationFunction GetAnimationFunction()
Get the control's animation function, if it exists.
Definition: IControl.h:500
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:444
void SetTextEntryLength(int len)
Set the max number of characters that are allowed in text entry.
Definition: IControl.h:307
bool GetPromptShowsParamLabel() const
Definition: IControl.h:386
void DisablePrompt(bool disable)
Disable/enable default prompt for user input.
Definition: IControl.h:415
IControl * SetActionFunction(IActionFunction actionFunc)
Set an Action Function for this control.
Definition: IControl.h:206
void SetAnimation(IAnimationFunction func)
Set the animation function.
Definition: IControl.h:492
bool IsHidden() const
Definition: IControl.h:355
An abstract IControl base class that you can inherit from in order to make a control that pops up a m...
Definition: IControl.h:1900
void ClearPathList()
Clear the menu.
Definition: IControl.cpp:1068
void CheckSelectedItem()
Check the currently selected menu item.
Definition: IControl.cpp:1111
void SetupMenu()
Call after adding one or more paths, to populate the menu.
Definition: IControl.cpp:1041
void GetSelectedFile(WDL_String &path) const
Get the full path to the file if something has been selected in the menu.
Definition: IControl.cpp:1098
void SetSelectedFile(const char *filePath)
Set the selected file based on a file path.
Definition: IControl.cpp:1076
IDirBrowseControlBase(const IRECT &bounds, const char *extension, bool showFileExtensions=true, bool scanRecursively=true, bool showEmptySubmenus=false)
Creates an IDirBrowseControlBase.
Definition: IControl.h:1908
void AddPath(const char *path, const char *displayText)
Used to add a path to scan for files.
Definition: IControl.cpp:1018
A basic control to display some editable text.
Definition: IControl.h:2184
void OnTextEntryCompletion(const char *str, int valIdx) override
Implement this method to handle text input after IGraphics::CreateTextEntry/IControlPromptUserInput.
Definition: IControl.h:2197
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:2192
IParam * GetParam(int paramIdx)
Get a pointer to one of the delegate's IParam objects.
An editor delegate base class for a SOMETHING that uses IGraphics for it's 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:2497
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:2613
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:2548
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:670
void CreateTextEntry(IControl &control, const IText &text, const IRECT &bounds, const char *str="", int valIdx=0)
Create a text entry box.
Definition: IGraphics.cpp:1923
void PathRect(const IRECT &bounds)
Add a rectangle to the current path.
Definition: IGraphics.cpp:2635
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:2504
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:2032
void DrawLayer(const ILayerPtr &layer, const IBlend *pBlend=nullptr)
Draw a layer to the main IGraphics context.
Definition: IGraphics.cpp:2045
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:2569
void PathClipRegion(const IRECT r=IRECT())
Clip the current path to a particular region.
Definition: IGraphics.cpp:2765
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:2576
virtual void DrawMultiLineText(const IText &text, const char *str, 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
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:2562
IBitmap GetScaledBitmap(IBitmap &inBitmap)
Get a version of the input bitmap from the cache that corresponds to the current screen scale For exa...
Definition: IGraphics.cpp:1520
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:787
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:794
void StartLayer(IControl *pOwner, const IRECT &r, bool cacheable=false)
Create an IGraphics layer.
Definition: IGraphics.cpp:1977
int GetControlTag(const IControl *pControl) const
Get the tag given to a control.
Definition: IGraphics.h:1378
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:2784
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:2490
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:2606
ILayerPtr EndLayer()
End an IGraphics layer.
Definition: IGraphics.cpp:2000
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:678
A base class for knob/dial controls, to handle mouse action and Sender.
Definition: IControl.h:1368
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:799
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:819
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:842
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:810
virtual IRECT GetKnobDragBounds()
Get the area for which mouse deltas will be used to calculate the amount dragging changes the control...
Definition: IControl.h:1387
A control that can be specialised with a lambda function, for quick experiments without making a cust...
Definition: IControl.h:2013
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:2029
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:2045
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:2059
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:2051
A basic control to display some text that needs to span multiple lines.
Definition: IControl.h:2206
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:2213
A base class for controls that can do do multitouch.
Definition: IControl.h:1274
A basic control to fill a rectangle with a color or gradient.
Definition: IControl.h:1969
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:1989
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:2112
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.h:2122
A base class for slider/fader controls, to handle mouse action and Sender.
Definition: IControl.h:1398
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:964
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:924
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:895
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.cpp:888
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:915
A base class for switch controls.
Definition: IControl.h:1874
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:762
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControl.cpp:754
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:780
A basic control to display some text.
Definition: IControl.h:2152
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:2171
virtual void ClearStr()
Clear the text .
Definition: IControl.h:2168
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:2248
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:2223
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:2238
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControl.h:2231
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:2230
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:2235
A base class for mult-strip/track controls, such as multi-sliders, meters Track refers to the channel...
Definition: IControl.h:1426
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:1516
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
Definition: IControl.h:1522
void SetParamsByGroup(const char *paramGroup)
Update the parameters based on a parameter group name.
Definition: IControl.h:1563
virtual void DrawTrackHandle(IGraphics &g, const IRECT &r, int chIdx, bool aboveBaseValue)
Draw the main body of the track.
Definition: IControl.h:1782
void SetParams(const std::vector< int > &paramIds)
Update the parameters based on a parameter group name.
Definition: IControl.h:1583
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
Definition: IControl.h:1551
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:1536
virtual void DrawBackground(IGraphics &g, const IRECT &r) override
Draw the IVControl background (usually transparent)
Definition: IControl.h:1663
virtual void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.h:1528
A base interface to be combined with IControl for vectorial controls "IVControls",...
Definition: IControl.h:757
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:918
void SetColor(EVColor colorIdx, const IColor &color)
Set one of the IVColors that style the IVControl.
Definition: IControl.h:787
IRECT MakeRects(const IRECT &parent, bool hasHandle=false)
Calculate the rectangles for the various areas, depending on the style.
Definition: IControl.h:1158
virtual void DrawBackground(IGraphics &g, const IRECT &rect)
Draw the IVControl background (usually transparent)
Definition: IControl.h:876
virtual void SetStyle(const IVStyle &style)
Set the Style of this IVControl.
Definition: IControl.h:825
virtual void DrawWidget(IGraphics &g)
Draw the IVControl main widget (override)
Definition: IControl.h:883
IVectorBase(const IVStyle &style, bool labelInWidget=false, bool valueInWidget=false)
IVectorBase Constructor.
Definition: IControl.h:763
IRECT GetAdjustedHandleBounds(IRECT handleBounds) const
Get the adjusted bounds for the widget handle, based on the style settings.
Definition: IControl.h:839
void DrawPressableEllipse(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, bool disabled)
Draw an ellipse-shaped vector button.
Definition: IControl.h:948
IRECT DrawPressableTriangle(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, float angle, bool disabled)
Draw a triangle-shaped vector button.
Definition: IControl.h:1103
float GetRoundedCornerRadius(const IRECT &bounds) const
Get the radius of rounded corners for a rectangle, based on the style roundness factor.
Definition: IControl.h:853
virtual void DrawValue(IGraphics &g, bool mouseOver)
Draw the IVControl value text.
Definition: IControl.h:899
void DrawSplash(IGraphics &g, const IRECT &clipRegion=IRECT())
Draw a splash effect when a widget handle is clicked (via SplashClickAnimationFunc)
Definition: IControl.h:868
void AttachIControl(IControl *pControl, const char *label)
Call in the constructor of your IVControl to link the IVectorBase and IControl.
Definition: IControl.h:775
IRECT DrawPressableRectangle(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, bool disabled, bool rtl=true, bool rtr=true, bool rbl=true, bool rbr=true)
Draw a rectangle-shaped vector button.
Definition: IControl.h:1020
virtual void DrawLabel(IGraphics &g)
Draw the IVControl label text.
Definition: IControl.h:889
virtual void OnStyleChanged()
Implement if extra changes are required in response to style changing.
Definition: IControl.h:782
const IColor & GetColor(EVColor color) const
Get value of a specific EVColor in the IVControl.
Definition: IControl.h:801
void SetColors(const IVColorSpec &spec)
Set the colors of this IVControl.
Definition: IControl.h:795
IVStyle GetStyle() const
Get the style of this IVControl.
Definition: IControl.h:834
A control to use as a placeholder during development.
Definition: IControl.h:2284
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:664
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.cpp:696
void OnTextEntryCompletion(const char *str, int valIdx) override
Implement this method to handle text input after IGraphics::CreateTextEntry/IControlPromptUserInput.
Definition: IControl.h:2290
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:2289
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.