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