iPlug2 - C++ Audio Plug-in Framework
Loading...
Searching...
No Matches
IControl.cpp
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#include <cmath>
12#include <cstring>
13#include "dirscan.h"
14
15#include "IControl.h"
16#include "IPlugParameter.h"
17
18
19BEGIN_IPLUG_NAMESPACE
20BEGIN_IGRAPHICS_NAMESPACE
22{
23 if(pCaller->GetAnimationProgress() > 1.)
24 {
25 pCaller->OnEndAnimation();
26 return;
27 }
28};
29
31{
32 auto progress = pCaller->GetAnimationProgress();
33
34 if(progress > 1.) {
35 pCaller->OnEndAnimation();
36 return;
37 }
38
39 pCaller->As<IVectorBase>()->SetSplashRadius((float) progress);
40 pCaller->SetDirty(false);
41};
42
43void EmptyClickActionFunc(IControl* pCaller) { };
44
45void DefaultClickActionFunc(IControl* pCaller) { pCaller->SetAnimation(DefaultAnimationFunc, DEFAULT_ANIMATION_DURATION); };
46
48{
49 float x, y;
50 pCaller->GetUI()->GetMouseDownPoint(x, y);
51 pCaller->As<IVectorBase>()->SetSplashPoint(x, y);
52 pCaller->SetAnimation(SplashAnimationFunc, DEFAULT_ANIMATION_DURATION);
53}
54
56{
57 IGraphics* pGraphics = pCaller->GetUI();
58 const IParam* pParam = pCaller->GetParam();
59 assert(pParam && "ShowBubbleHorizontalActionFunc requires a parameter");
60 IRECT bounds = pCaller->GetRECT();
61 WDL_String display;
62 pParam->GetDisplayWithLabel(display);
63 pGraphics->ShowBubbleControl(pCaller, bounds.R, bounds.MH(), display.Get(), EDirection::Horizontal, IRECT(0, 0, 50, 30));
64}
65
67{
68 IGraphics* pGraphics = pCaller->GetUI();
69 const IParam* pParam = pCaller->GetParam();
70 assert(pParam && "ShowBubbleVerticalActionFunc requires a parameter");
71 IRECT bounds = pCaller->GetRECT();
72 WDL_String display;
73 pParam->GetDisplayWithLabel(display);
74 pGraphics->ShowBubbleControl(pCaller, bounds.MW(), bounds.T, display.Get(), EDirection::Vertical, IRECT(0, 0, 50, 30));
75}
76
77END_IGRAPHICS_NAMESPACE
78END_IPLUG_NAMESPACE
79
80using namespace iplug;
81using namespace igraphics;
82
83IControl::IControl(const IRECT& bounds, int paramIdx, IActionFunction aF)
84: mRECT(bounds)
85, mTargetRECT(bounds)
86, mActionFunc(aF)
87{
88 mVals[0].idx = paramIdx;
89}
90
91IControl::IControl(const IRECT& bounds, const std::initializer_list<int>& params, IActionFunction aF)
92: mRECT(bounds)
93, mTargetRECT(bounds)
94, mActionFunc(aF)
95{
96 mVals.clear();
97 for (auto& paramIdx : params) {
98 mVals.push_back({paramIdx, 0.});
99 }
100}
101
102IControl::IControl(const IRECT& bounds, IActionFunction aF)
103: mRECT(bounds)
104, mTargetRECT(bounds)
105, mActionFunc(aF)
106{
107}
108
109int IControl::GetParamIdx(int valIdx) const
110{
111 assert(valIdx > kNoValIdx && valIdx < NVals());
112 return mVals[valIdx].idx;
113}
114
115void IControl::SetParamIdx(int paramIdx, int valIdx)
116{
117 assert(valIdx > kNoValIdx && valIdx < NVals());
118 mVals.at(valIdx).idx = paramIdx;
119 SetDirty(false);
120}
121
122const IParam* IControl::GetParam(int valIdx) const
123{
124 int paramIdx = GetParamIdx(valIdx);
125
126 if(paramIdx > kNoParameter)
127 return mDelegate->GetParam(paramIdx);
128 else
129 return nullptr;
130}
131
132int IControl::LinkedToParam(int paramIdx) const
133{
134 const int nVals = NVals();
135
136 for (int v = 0; v < nVals; v++)
137 {
138 if(mVals[v].idx == paramIdx)
139 {
140 return v;
141 }
142 }
143
144 return kNoValIdx;
145}
146
147void IControl::SetValue(double value, int valIdx)
148{
149 assert(valIdx > kNoValIdx && valIdx < NVals());
150 mVals[valIdx].value = value;
151}
152
153double IControl::GetValue(int valIdx) const
154{
155 assert(valIdx > kNoValIdx && valIdx < NVals());
156 return mVals[valIdx].value;
157}
158
159void IControl::SetValueFromDelegate(double value, int valIdx)
160{
161 // Don't update the control from delegate if it is being captured
162 // (i.e. if host is automating the control then the mouse is more important)
163
164 if (!GetUI()->ControlIsCaptured(this))
165 {
166 if(GetValue(valIdx) != value)
167 {
168 SetValue(value, valIdx);
169 SetDirty(false);
170 }
171 }
172}
173
174void IControl::SetValueFromUserInput(double value, int valIdx)
175{
176 if (GetValue(valIdx) != value)
177 {
178 SetValue(value, valIdx);
179 SetDirty(true, valIdx);
180 }
181}
182
184{
185 valIdx = (NVals() == 1) ? 0 : valIdx;
186
187 auto paramDefault = [this](int v)
188 {
189 const IParam* pParam = GetParam(v);
190 if (pParam)
191 SetValue(pParam->GetDefault(true), v);
192 };
193
194 ForValIdx(valIdx, paramDefault);
195 SetDirty(true, valIdx);
196}
197
198void IControl::SetDirty(bool triggerAction, int valIdx)
199{
200 valIdx = (NVals() == 1) ? 0 : valIdx;
201
202 auto setValue = [this](int v) { SetValue(Clip(GetValue(v), 0.0, 1.0), v); };
203 ForValIdx(valIdx, setValue);
204
205 mDirty = true;
206
207 if (triggerAction)
208 {
209 auto paramUpdate = [this](int v)
210 {
211 if (GetParamIdx(v) > kNoParameter)
212 {
213 GetDelegate()->SendParameterValueFromUI(GetParamIdx(v), GetValue(v)); //TODO: take tuple
214 GetUI()->UpdatePeers(this, v);
215 }
216 };
217
218 ForValIdx(valIdx, paramUpdate);
219
220 if (mActionFunc)
221 mActionFunc(this);
222 }
223}
224
225void IControl::Animate()
226{
228 mAnimationFunc(this);
229}
230
232{
234 return true;
235
236 return mDirty;
237}
238
239void IControl::Hide(bool hide)
240{
241 mHide = hide;
242 SetDirty(false);
243}
244
245void IControl::SetDisabled(bool disable)
246{
247 mBlend.mWeight = (disable ? GRAYED_ALPHA : 1.0f);
248 mDisabled = disable;
249 SetDirty(false);
250}
251
252void IControl::OnMouseDown(float x, float y, const IMouseMod& mod)
253{
254 if (mod.R)
256}
257
258void IControl::OnMouseDblClick(float x, float y, const IMouseMod& mod)
259{
260 #ifdef AAX_API
262 #else
264 #endif
265}
266
267void IControl::OnMouseOver(float x, float y, const IMouseMod& mod)
268{
269 bool prev = mMouseIsOver;
270 mMouseIsOver = true;
271 if (prev == false)
272 SetDirty(false);
273}
274
276{
277 bool prev = mMouseIsOver;
278 mMouseIsOver = false;
279 if (prev == true)
280 SetDirty(false);
281}
282
283void IControl::OnPopupMenuSelection(IPopupMenu* pSelectedMenu, int valIdx)
284{
285 if (pSelectedMenu && valIdx > kNoValIdx && GetParamIdx(valIdx) > kNoParameter && !mDisablePrompt)
286 {
287 SetValueFromUserInput(GetParam()->ToNormalized( (double) pSelectedMenu->GetChosenItemIdx()), valIdx);
288 }
289}
290
291void IControl::SetPosition(float x, float y)
292{
293 if (x < 0.f) x = 0.f;
294 if (y < 0.f) y = 0.f;
295
296 float tX = x + (mTargetRECT.L - mRECT.L);
297 float tY = y + (mTargetRECT.T - mRECT.T);
298
299 SetRECT({x, y, x + mRECT.W(), y + mRECT.H()});
300 SetTargetRECT({tX, tY, tX + mTargetRECT.W(), tY + mTargetRECT.H()});
301}
302
303void IControl::SetSize(float w, float h)
304{
305 if (w < 0.f) w = 0.f;
306 if (h < 0.f) h = 0.f;
307
308 SetTargetAndDrawRECTs({mRECT.L, mRECT.T, mRECT.L + w, mRECT.T + h});
309}
310
311IControl* IControl::AttachGestureRecognizer(EGestureType type, IGestureFunc func)
312{
313 mGestureFuncs.insert(std::make_pair(type, func));
314
315 GetUI()->AttachGestureRecognizer(type); // this will crash if called in constructor
316
317 return this; //for chaining
318}
319
321{
322 auto itr = mGestureFuncs.find(info.type);
323
324 if(itr != mGestureFuncs.end())
325 {
326 mLastGesture = info.type;
327 itr->second(this, info);
328 return true;
329 }
330
331 return false;
332}
333
335{
336 if (valIdx > kNoValIdx && GetParamIdx(valIdx) > kNoParameter && !mDisablePrompt)
337 {
338 if (GetParam(valIdx)->NDisplayTexts()) // popup menu
339 {
340 GetUI()->PromptUserInput(*this, mRECT, valIdx);
341 }
342 else // text entry
343 {
344 float cX = mRECT.MW();
345 float cY = mRECT.MH();
346 float halfW = PARAM_EDIT_W/2.f;
347 float halfH = PARAM_EDIT_H/2.f;
348
349 IRECT txtRECT = IRECT(cX - halfW, cY - halfH, cX + halfW,cY + halfH);
350 GetUI()->PromptUserInput(*this, txtRECT, valIdx);
351 }
352
353 SetDirty(false);
354 }
355}
356
357void IControl::PromptUserInput(const IRECT& bounds, int valIdx)
358{
359 if (valIdx > kNoValIdx && GetParamIdx(valIdx) > kNoParameter && !mDisablePrompt)
360 {
361 GetUI()->PromptUserInput(*this, bounds, valIdx);
362 }
363}
364
365void IControl::SetPTParameterHighlight(bool isHighlighted, int color)
366{
367 switch (color)
368 {
369 case 0: //AAX_eHighlightColor_Red
370 mPTHighlightColor = COLOR_RED;
371 break;
372 case 1: //AAX_eHighlightColor_Blue
373 mPTHighlightColor = COLOR_BLUE;
374 break;
375 case 2: //AAX_eHighlightColor_Green
376 mPTHighlightColor = COLOR_GREEN;
377 break;
378 case 3: //AAX_eHighlightColor_Yellow
379 mPTHighlightColor = COLOR_YELLOW;
380 break;
381 default:
382 break;
383 }
384
385 mPTisHighlighted = isHighlighted;
386 SetDirty(false);
387}
388
390{
391 if (mPTisHighlighted)
392 {
393 g.FillCircle(mPTHighlightColor, mTargetRECT.R-5, mTargetRECT.T+5, 2);
394 }
395}
396
397void IControl::SnapToMouse(float x, float y, EDirection direction, const IRECT& bounds, int valIdx, double minClip, double maxClip)
398{
399 bounds.Constrain(x, y);
400
401 float val;
402
403 if(direction == EDirection::Vertical)
404 val = 1.f - (y-bounds.T) / bounds.H();
405 else
406 val = (x-bounds.L) / bounds.W();
407
408 auto valFunc = [&](int valIdx) {
409 SetValue(Clip(std::round(val / 0.001 ) * 0.001, minClip, maxClip), valIdx);
410 };
411
412 ForValIdx(valIdx, valFunc);
413 SetDirty(true, valIdx);
414}
415
416void IControl::OnEndAnimation()
417{
418 mAnimationFunc = nullptr;
419 SetDirty(false);
420
421 if(mAnimationEndActionFunc)
422 mAnimationEndActionFunc(this);
423}
424
425void IControl::StartAnimation(int duration)
426{
427 mAnimationStartTime = std::chrono::high_resolution_clock::now();
428 mAnimationDuration = Milliseconds(duration);
429}
430
432{
433 if(!mAnimationFunc)
434 return 0.;
435
436 auto elapsed = Milliseconds(std::chrono::high_resolution_clock::now() - mAnimationStartTime);
437 return elapsed.count() / mAnimationDuration.count();
438}
439
440ITextControl::ITextControl(const IRECT& bounds, const char* str, const IText& text, const IColor& BGColor, bool setBoundsBasedOnStr)
441: IControl(bounds)
442, mStr(str)
443, mBGColor(BGColor)
444, mSetBoundsBasedOnStr(setBoundsBasedOnStr)
445{
446 mIgnoreMouse = true;
447 mText = text;
448}
449
451{
452 if(mSetBoundsBasedOnStr)
454}
455
456void ITextControl::SetStr(const char* str)
457{
458 if (strcmp(mStr.Get(), str))
459 {
460 mStr.Set(str);
461
462 if(mSetBoundsBasedOnStr)
464
465 SetDirty(false);
466 }
467}
468
469void ITextControl::SetStrFmt(int maxlen, const char* fmt, ...)
470{
471 va_list arglist;
472 va_start(arglist, fmt);
473 mStr.SetAppendFormattedArgs(false, maxlen, fmt, arglist);
474 va_end(arglist);
475
476 SetDirty(false);
477}
478
480{
481 g.FillRect(mBGColor, mRECT, &mBlend);
482
483 if (mStr.GetLength() && g.GetControlInTextEntry() != this)
484 g.DrawText(mText, mStr.Get(), mRECT, &mBlend);
485}
486
488{
489 IRECT r;
490 GetUI()->MeasureText(mText, mStr.Get(), r);
491 SetTargetAndDrawRECTs({mRECT.MW()-(r.W()/2.f), mRECT.MH()-(r.H()/2.f), mRECT.MW()+(r.W()/2.f), mRECT.MH()+(r.H()/2.f)});
492}
493
494IURLControl::IURLControl(const IRECT& bounds, const char* str, const char* urlStr, const IText& text, const IColor& BGColor, const IColor& MOColor, const IColor& CLColor)
495: ITextControl(bounds, str, text, BGColor)
496, mURLStr(urlStr)
497, mOriginalColor(text.mFGColor)
498, mMOColor(MOColor)
499, mCLColor(CLColor)
500{
501 mIgnoreMouse = false;
502}
503
505{
506 g.FillRect(mBGColor, mRECT, &mBlend);
507
508 if(mMouseIsOver)
509 mText.mFGColor = mMOColor;
510 else
511 mText.mFGColor = mClicked ? mCLColor : mOriginalColor;
512
513 if (mStr.GetLength())
514 {
515 IRECT textDims;
516 g.MeasureText(mText, mStr.Get(), textDims);
517
518 float linePosY = 0.f;
519 float linePosL = 0.f;
520 float linePosR = 0.f;
521
522 if(mText.mVAlign == EVAlign::Middle)
523 linePosY = mRECT.MH() + textDims.B;
524 else if(mText.mVAlign == EVAlign::Bottom)
525 linePosY = mRECT.B;
526 else if(mText.mVAlign == EVAlign::Top)
527 linePosY = mRECT.T - textDims.H();
528
529 if(mText.mAlign == EAlign::Center)
530 {
531 linePosL = mRECT.MW() + textDims.L;
532 linePosR = mRECT.MW() + textDims.R;
533 }
534 else if(mText.mAlign == EAlign::Near)
535 {
536 linePosL = mRECT.L;
537 linePosR = mRECT.L + textDims.W();
538 }
539 else if(mText.mAlign == EAlign::Far)
540 {
541 linePosL = mRECT.R - textDims.W();
542 linePosR = mRECT.R;
543 }
544
545 g.DrawLine(mText.mFGColor, linePosL, linePosY, linePosR, linePosY, &mBlend);
546 g.DrawText(mText, mStr.Get(), mRECT, &mBlend);
547 }
548}
549
550void IURLControl::OnMouseDown(float x, float y, const IMouseMod& mod)
551{
552 GetUI()->OpenURL(mURLStr.Get());
554 mClicked = true;
555}
556
558{
559 mText = txt;
560 mOriginalColor = txt.mFGColor;
561}
562
563ITextToggleControl::ITextToggleControl(const IRECT& bounds, int paramIdx, const char* offText, const char* onText, const IText& text, const IColor& bgColor)
564: ITextControl(bounds, offText, text, bgColor)
565, mOffText(offText)
566, mOnText(onText)
567{
568 SetParamIdx(paramIdx);
569 //TODO: assert boolean?
570 mIgnoreMouse = false;
571 mDblAsSingleClick = true;
572}
573
574ITextToggleControl::ITextToggleControl(const IRECT& bounds, IActionFunction aF, const char* offText, const char* onText, const IText& text, const IColor& bgColor)
575: ITextControl(bounds, offText, text, bgColor)
576, mOffText(offText)
577, mOnText(onText)
578{
580 mDblAsSingleClick = true;
581 mIgnoreMouse = false;
582}
583
584void ITextToggleControl::OnMouseDown(float x, float y, const IMouseMod& mod)
585{
586 if(GetValue() < 0.5)
587 SetValue(1.);
588 else
589 SetValue(0.);
590
591 SetDirty(true);
592}
593
594void ITextToggleControl::SetDirty(bool push, int valIdx)
595{
596 if(GetValue() > 0.5)
597 SetStr(mOnText.Get());
598 else
599 SetStr(mOffText.Get());
600
601 IControl::SetDirty(push);
602}
603
604
605ICaptionControl::ICaptionControl(const IRECT& bounds, int paramIdx, const IText& text, const IColor& bgColor, bool showParamLabel)
606: ITextControl(bounds, "", text, bgColor)
607, mShowParamLabel(showParamLabel)
608{
609 SetParamIdx(paramIdx);
610 mDblAsSingleClick = true;
611 mDisablePrompt = false;
612 mIgnoreMouse = false;
613}
614
615void ICaptionControl::OnMouseDown(float x, float y, const IMouseMod& mod)
616{
617 if (mod.L || mod.R)
618 {
619 PromptUserInput(mRECT);
620 }
621}
622
624{
625 const IParam* pParam = GetParam();
626
627 if (pParam)
628 {
629 pParam->GetDisplay(mStr);
630
631 if (mShowParamLabel)
632 {
633 mStr.Append(" ");
634 mStr.Append(pParam->GetLabel());
635 }
636 }
637
639
640 if (mTriangleRect.W() > 0.f)
641 {
642 g.FillTriangle(mMouseIsOver ? mTriangleMouseOverColor : mTriangleColor,
643 mTriangleRect.L, mTriangleRect.T, mTriangleRect.R, mTriangleRect.T, mTriangleRect.MW(), mTriangleRect.B,
644 GetMouseIsOver() ? 0 : &BLEND_50);
645 }
646}
647
649{
650 const IParam* pParam = GetParam();
651
652 if (pParam && pParam->Type() == IParam::kTypeEnum)
653 {
654 const auto textHeight = mText.mSize;
655 const auto dropDownAreaWidth = textHeight;
656 const auto triangleWidth = dropDownAreaWidth * 0.5f;
657 const auto triangleHeight = dropDownAreaWidth * 0.33f;
658
659 auto dropDownAreaRect = mText.mAlign == EAlign::Far ? mRECT.GetFromLeft(dropDownAreaWidth)
660 : mRECT.GetFromRight(dropDownAreaWidth);
661
662 mTriangleRect = dropDownAreaRect.GetCentredInside(IRECT(0.f, 0.f, triangleWidth, triangleHeight));
663 }
664}
665
666PlaceHolder::PlaceHolder(const IRECT& bounds, const char* str)
667: ITextControl(bounds, str, IText(20))
668{
669 mBGColor = COLOR_WHITE;
670 mDisablePrompt = false;
671 mDblAsSingleClick = false;
672 mIgnoreMouse = false;
673}
674
676{
677 g.FillRect(mBGColor, mRECT);
678 g.DrawLine(COLOR_RED, mRECT.L, mRECT.T, mRECT.R, mRECT.B, &BLEND_50, 2.f);
679 g.DrawLine(COLOR_RED, mRECT.L, mRECT.B, mRECT.R, mRECT.T, &BLEND_50, 2.f);
680
681 IRECT r = {};
682 g.MeasureText(mHeightText, mHeightStr.Get(), r);
683 g.FillRect(mBGColor, r.GetTranslated(mRECT.L + mInset, mRECT.MH()), &BLEND_50);
684 g.DrawText(mHeightText, mHeightStr.Get(), mRECT.L + mInset, mRECT.MH());
685
686 r = {};
687 g.MeasureText(mWidthText, mWidthStr.Get(), r);
688 g.FillRect(mBGColor, r.GetTranslated(mRECT.MW(), mRECT.T + mInset), &BLEND_75);
689 g.DrawText(mWidthText, mWidthStr.Get(), mRECT.MW(), mRECT.T + mInset);
690
691 r = {};
692 g.MeasureText(mTLGCText, mTLHCStr.Get(), r);
693 g.FillRect(mBGColor, r.GetTranslated(mRECT.L + mInset, mRECT.T + mInset), &BLEND_50);
694 g.DrawText(mTLGCText, mTLHCStr.Get(), mRECT.L + mInset, mRECT.T + mInset);
695
696 if (mStr.GetLength())
697 {
698 r = mRECT;
699 g.MeasureText(mText, mStr.Get(), r);
700 g.FillRect(mBGColor, r, &BLEND_75);
701 g.DrawText(mText, mStr.Get(), r);
702
703 mCentreLabelBounds = r;
704 }
705}
706
708{
709 mTLHCStr.SetFormatted(32, "%0.1f, %0.1f", mRECT.L, mRECT.T);
710 mWidthStr.SetFormatted(32, "%0.1f", mRECT.W());
711 mHeightStr.SetFormatted(32, "%0.1f", mRECT.H());
712}
713
714IButtonControlBase::IButtonControlBase(const IRECT& bounds, IActionFunction aF)
715: IControl(bounds, kNoParameter, aF)
716{
717 mDblAsSingleClick = true;
718}
719
720void IButtonControlBase::OnMouseDown(float x, float y, const IMouseMod& mod)
721{
722 SetValue(1.);
723 SetDirty(true);
724}
725
726void IButtonControlBase::OnEndAnimation()
727{
728 SetValue(0.);
729 IControl::OnEndAnimation();
730}
731
732ISwitchControlBase::ISwitchControlBase(const IRECT& bounds, int paramIdx, IActionFunction aF, int numStates)
733: IControl(bounds, paramIdx, aF)
734, mNumStates(numStates)
735{
736 mDisabledState.Resize(numStates);
737 SetAllStatesDisabled(false);
738 mDblAsSingleClick = true;
739}
740
741void ISwitchControlBase::SetAllStatesDisabled(bool disabled)
742{
743 for(int i=0; i<mNumStates; i++)
744 {
745 SetStateDisabled(i, disabled);
746 }
747 SetDirty(false);
748}
749
750void ISwitchControlBase::SetStateDisabled(int stateIdx, bool disabled)
751{
752 if(stateIdx >= 0 && stateIdx < mNumStates && mDisabledState.GetSize())
753 mDisabledState.Get()[stateIdx] = disabled;
754
755 SetDirty(false);
756}
757
758bool ISwitchControlBase::GetStateDisabled(int stateIdx) const
759{
760 if(stateIdx >= 0 && stateIdx < mNumStates && mDisabledState.GetSize())
761 return mDisabledState.Get()[stateIdx];
762 return false;
763}
764
766{
767 if (GetParamIdx() > kNoParameter)
768 mNumStates = (int) GetParam()->GetRange() + 1;
769
770 assert(mNumStates > 1);
771}
772
773void ISwitchControlBase::OnMouseDown(float x, float y, const IMouseMod& mod)
774{
775 if (mNumStates == 2)
776 SetValue(!GetValue());
777 else
778 {
779 const double step = 1.0 / (double(mNumStates-1));
780 double val = GetValue();
781 val += step;
782 if (val > (1.0 + std::numeric_limits<double>::epsilon()))
783 val = 0.0;
784 SetValue(val);
785 }
786
787 mMouseDown = true;
788 SetDirty(true);
789}
790
791void ISwitchControlBase::OnMouseUp(float x, float y, const IMouseMod& mod)
792{
793 mMouseDown = false;
794 SetDirty(false);
795}
796
797bool IKnobControlBase::IsFineControl(const IMouseMod& mod, bool wheel) const
798{
799#ifdef PROTOOLS
800#ifdef OS_WIN
801 return mod.C;
802#else
803 return wheel ? mod.C : mod.R;
804#endif
805#else
806 return (mod.C || mod.S);
807#endif
808}
809
810void IKnobControlBase::OnMouseDown(float x, float y, const IMouseMod& mod)
811{
812 mMouseDown = true;
813 mMouseDragValue = GetValue();
814
815 if (mHideCursorOnDrag)
816 GetUI()->HideMouseCursor(true, true);
817
818 IControl::OnMouseDown(x, y, mod);
819}
820
821void IKnobControlBase::OnMouseUp(float x, float y, const IMouseMod& mod)
822{
823 if (mHideCursorOnDrag)
824 GetUI()->HideMouseCursor(false);
825
826 mMouseDown = false;
827 SetDirty(false);
828}
829
830void IKnobControlBase::OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod)
831{
832 double gearing = IsFineControl(mod, false) ? mGearing * 10.0 : mGearing;
833
834 IRECT dragBounds = GetKnobDragBounds();
835
836 if (mDirection == EDirection::Vertical)
837 mMouseDragValue += static_cast<double>(dY / static_cast<double>(dragBounds.T - dragBounds.B) / gearing);
838 else
839 mMouseDragValue += static_cast<double>(dX / static_cast<double>(dragBounds.R - dragBounds.L) / gearing);
840
841 mMouseDragValue = Clip(mMouseDragValue, 0., 1.);
842
843 double v = mMouseDragValue;
844 const IParam* pParam = GetParam();
845
846 if (pParam && pParam->GetStepped() && pParam->GetStep() > 0)
847 v = pParam->ConstrainNormalized(mMouseDragValue);
848
849 SetValue(v);
850 SetDirty();
851}
852
853void IKnobControlBase::OnMouseWheel(float x, float y, const IMouseMod& mod, float d)
854{
855 const double gearing = IsFineControl(mod, true) ? 0.001 : 0.01;
856 double newValue = 0.0;
857 const double oldValue = GetValue();
858 const IParam* pParam = GetParam();
859
860 if (pParam && pParam->GetStepped() && pParam->GetStep() > 0)
861 {
862 if (d != 0.f)
863 {
864 const double step = pParam->GetStep();
865 double v = pParam->FromNormalized(oldValue);
866 v += d > 0 ? step : -step;
867 newValue = pParam->ToNormalized(v);
868 }
869 else
870 {
871 newValue = oldValue;
872 }
873 }
874 else
875 {
876 newValue = oldValue + gearing * d;
877 }
878
879 SetValue(newValue);
880 SetDirty();
881}
882
883ISliderControlBase::ISliderControlBase(const IRECT& bounds, int paramIdx, EDirection dir, double gearing, float handleSize)
884: IControl(bounds, paramIdx)
885, mDirection(dir)
886, mHandleSize(handleSize)
887, mGearing(gearing)
888{
889}
890
891 ISliderControlBase::ISliderControlBase(const IRECT& bounds, IActionFunction aF, EDirection dir, double gearing, float handleSize)
892: IControl(bounds, aF)
893, mDirection(dir)
894, mHandleSize(handleSize)
895, mGearing(gearing)
896{
897}
898
900{
901 SetTargetRECT(mRECT);
902 mTrackBounds = mRECT;
903 SetDirty(false);
904}
905
906void ISliderControlBase::OnMouseDown(float x, float y, const IMouseMod& mod)
907{
908 mMouseDown = true;
909
910 if(GetParam())
911 {
912 if(!GetParam()->GetStepped())
913 SnapToMouse(x, y, mDirection, mTrackBounds);
914 }
915 else
916 SnapToMouse(x, y, mDirection, mTrackBounds);
917
918 mMouseDragValue = GetValue();
919
920 if (mHideCursorOnDrag)
921 GetUI()->HideMouseCursor(true, true);
922
923 IControl::OnMouseDown(x, y, mod);
924}
925
926void ISliderControlBase::OnMouseUp(float x, float y, const IMouseMod& mod)
927{
928 if (mHideCursorOnDrag)
929 GetUI()->HideMouseCursor(false);
930
931 mMouseDown = false;
932 SetDirty(false);
933}
934
935void ISliderControlBase::OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod)
936{
937 const IParam* pParam = GetParam();
938
939 if(mod.touchID || !mHideCursorOnDrag)
940 {
941 if(pParam)
942 {
943 if(!pParam->GetStepped())
944 {
945 SnapToMouse(x, y, mDirection, mTrackBounds);
946 return;
947 }
948 // non-stepped parameter, fall through
949 }
950 else
951 {
952 SnapToMouse(x, y, mDirection, mTrackBounds);
953 return;
954 }
955 }
956
957 double gearing = IsFineControl(mod, false) ? mGearing * 10.0 : mGearing;
958
959 if (mDirection == EDirection::Vertical)
960 mMouseDragValue += static_cast<double>(dY / static_cast<double>(mTrackBounds.T - mTrackBounds.B) / gearing);
961 else
962 mMouseDragValue += static_cast<double>(dX / static_cast<double>(mTrackBounds.R - mTrackBounds.L) / gearing);
963
964 mMouseDragValue = Clip(mMouseDragValue, 0., 1.);
965
966 double v = mMouseDragValue;
967
968 if (pParam && pParam->GetStepped() && pParam->GetStep() > 0)
969 v = pParam->ConstrainNormalized(mMouseDragValue);
970
971 SetValue(v);
972 SetDirty(true);
973}
974
975void ISliderControlBase::OnMouseWheel(float x, float y, const IMouseMod& mod, float d)
976{
977 const double gearing = IsFineControl(mod, true) ? 0.001 : 0.01;
978 double newValue = 0.0;
979 const double oldValue = GetValue();
980 const IParam* pParam = GetParam();
981
982 if (pParam && pParam->GetStepped() && pParam->GetStep() > 0)
983 {
984 if (d != 0.f)
985 {
986 const double step = pParam->GetStep();
987 double v = pParam->FromNormalized(oldValue);
988 v += d > 0 ? step : -step;
989 newValue = pParam->ToNormalized(v);
990 }
991 else
992 {
993 newValue = oldValue;
994 }
995 }
996 else
997 {
998 newValue = oldValue + gearing * d;
999 }
1000
1001 SetValue(newValue);
1002 SetDirty();
1003}
1004
1005bool ISliderControlBase::IsFineControl(const IMouseMod& mod, bool wheel) const
1006{
1007#ifdef PROTOOLS
1008#ifdef OS_WIN
1009 return mod.C;
1010#else
1011 return wheel ? mod.C : mod.R;
1012#endif
1013#else
1014 return (mod.C || mod.S);
1015#endif
1016}
1017
1018
1019IDirBrowseControlBase::~IDirBrowseControlBase()
1020{
1021 ClearPathList();
1022}
1023
1024int IDirBrowseControlBase::NItems() const
1025{
1026 return mItems.GetSize();
1027}
1028
1029void IDirBrowseControlBase::AddPath(const char* path, const char* label)
1030{
1031 assert(strlen(path));
1032
1033 mPaths.Add(new WDL_String(path));
1034 mPathLabels.Add(new WDL_String(label));
1035}
1036
1037void IDirBrowseControlBase::CollectSortedItems(IPopupMenu* pMenu)
1038{
1039 int nItems = pMenu->NItems();
1040
1041 for (int i = 0; i < nItems; i++)
1042 {
1043 IPopupMenu::Item* pItem = pMenu->GetItem(i);
1044
1045 if (pItem->GetSubmenu())
1046 CollectSortedItems(pItem->GetSubmenu());
1047 else
1048 mItems.Add(pItem);
1049 }
1050}
1051
1053{
1054 mFiles.Empty(true);
1055 mItems.Empty(false);
1056
1057 mMainMenu.Clear();
1058 mSelectedItemIndex = -1;
1059
1060 int idx = 0;
1061
1062 if (mPaths.GetSize() == 1)
1063 {
1064 ScanDirectory(mPaths.Get(0)->Get(), mMainMenu);
1065 }
1066 else
1067 {
1068 for (int p = 0; p<mPaths.GetSize(); p++)
1069 {
1070 IPopupMenu* pNewMenu = new IPopupMenu();
1071 mMainMenu.AddItem(mPathLabels.Get(p)->Get(), idx++, pNewMenu);
1072 ScanDirectory(mPaths.Get(p)->Get(), *pNewMenu);
1073 }
1074 }
1075
1076 CollectSortedItems(&mMainMenu);
1077}
1078
1080{
1081 mPaths.Empty(true);
1082 mPathLabels.Empty(true);
1083 mFiles.Empty(true);
1084 mItems.Empty(false);
1085}
1086
1088{
1089 for (auto fileIdx = 0; fileIdx < mFiles.GetSize(); fileIdx ++)
1090 {
1091 if (strcmp(mFiles.Get(fileIdx)->Get(), filePath) == 0)
1092 {
1093 for (auto itemIdx = 0; itemIdx < mItems.GetSize(); itemIdx++)
1094 {
1095 IPopupMenu::Item* pItem = mItems.Get(itemIdx);
1096
1097 if (pItem->GetTag() == fileIdx)
1098 {
1099 mSelectedItemIndex = itemIdx;
1100 return;
1101 }
1102 }
1103 }
1104 }
1105
1106 mSelectedItemIndex = -1;
1107}
1108
1109void IDirBrowseControlBase::GetSelectedFile(WDL_String& path) const
1110{
1111 if (mSelectedItemIndex > -1)
1112 {
1113 IPopupMenu::Item* pItem = mItems.Get(mSelectedItemIndex);
1114 path.Set(mFiles.Get(pItem->GetTag()));
1115 }
1116 else
1117 {
1118 path.Set("");
1119 }
1120}
1121
1123{
1124 if (mSelectedItemIndex > -1)
1125 {
1126 IPopupMenu::Item* pItem = mItems.Get(mSelectedItemIndex);
1127 mMainMenu.CheckItemAlone(pItem);
1128 }
1129}
1130
1131void IDirBrowseControlBase::ScanDirectory(const char* path, IPopupMenu& menuToAddTo)
1132{
1133 WDL_DirScan d;
1134
1135 if (!d.First(path))
1136 {
1137 do
1138 {
1139 const char* f = d.GetCurrentFN();
1140 if (f && f[0] != '.')
1141 {
1142 if (mScanRecursively && d.GetCurrentIsDirectory())
1143 {
1144 WDL_String subdir;
1145 d.GetCurrentFullFN(&subdir);
1146 IPopupMenu* pNewMenu = new IPopupMenu();
1147 menuToAddTo.AddItem(d.GetCurrentFN(), pNewMenu, -2);
1148 ScanDirectory(subdir.Get(), *pNewMenu);
1149 }
1150 else
1151 {
1152 // Find the last occurrence of str2 in str1.
1153 // Return a pointer to the first character of the match.
1154 // Return a pointer to the start of str1 if str2 is empty.
1155 // Return a nullptr if str2 isn't found in str1.
1156 auto strrstr = [](const char* str1, const char* str2) -> const char* {
1157 if (*str2 == '\0')
1158 return str1;
1159
1160 const char* result = nullptr;
1161
1162 while (*str1 != '\0') {
1163 if (std::strncmp(str1, str2, std::strlen(str2)) == 0)
1164 result = str1;
1165
1166 str1++;
1167 }
1168
1169 return result;
1170 };
1171
1172 const char* a = strrstr(f, mExtension.Get());
1173 if (a && a > f && strlen(a) == strlen(mExtension.Get()))
1174 {
1175 WDL_String menuEntry {f};
1176
1177 if (!mShowFileExtensions)
1178 menuEntry.Set(f, (int) (a - f) - 1);
1179
1180 IPopupMenu::Item* pItem = new IPopupMenu::Item(menuEntry.Get(), IPopupMenu::Item::kNoFlags, mFiles.GetSize());
1181 menuToAddTo.AddItem(pItem, -2 /* sort alphabetically */);
1182 WDL_String* pFullPath = new WDL_String("");
1183 d.GetCurrentFullFN(pFullPath);
1184 mFiles.Add(pFullPath);
1185 }
1186 }
1187 }
1188 } while (!d.Next());
1189 }
1190
1191 if (!mShowEmptySubmenus)
1192 menuToAddTo.RemoveEmptySubmenus();
1193}
This file contains the base IControl implementation, along with some base classes for specific types ...
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:720
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:615
ICaptionControl(const IRECT &bounds, int paramIdx, const IText &text=DEFAULT_TEXT, const IColor &BGColor=DEFAULT_BGCOLOR, bool showParamLabel=true)
Creates an ICaptionControl.
Definition: IControl.cpp:605
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.cpp:648
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:623
The lowest level base class of an IGraphics control.
Definition: IControl.h:49
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
IControl(const IRECT &bounds, int paramIdx=kNoParameter, IActionFunction actionFunc=nullptr)
Constructor.
Definition: IControl.cpp:83
IGraphics * GetUI()
Definition: IControl.h:472
virtual void OnMouseOut()
Implement this method to respond to a mouseout event on this control.
Definition: IControl.cpp:275
bool mMouseIsOver
if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control.
Definition: IControl.h:565
virtual void OnMouseOver(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouseover event on this control.
Definition: IControl.cpp:267
virtual void SetPosition(float x, float y)
Set the position of the control, preserving the width and height.
Definition: IControl.cpp:291
virtual void SetValueFromDelegate(double value, int valIdx=0)
Set the control's value from the delegate This method is called from the class implementing the IEdit...
Definition: IControl.cpp:159
virtual void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx)
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControlPromptU...
Definition: IControl.cpp:283
virtual void OnMouseDown(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:252
virtual void SetValueFromUserInput(double value, int valIdx=0)
Set the control's value after user input.
Definition: IControl.cpp:174
virtual bool IsDirty()
Called at each display refresh by the IGraphics draw loop, after IControl::Animate(),...
Definition: IControl.cpp:231
virtual void Hide(bool hide)
Shows or hides the IControl.
Definition: IControl.cpp:239
IControl * AttachGestureRecognizer(EGestureType type, IGestureFunc func)
Add a IGestureFunc that should be triggered in response to a certain type of gesture.
Definition: IControl.cpp:311
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
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
IGEditorDelegate * GetDelegate()
Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes...
Definition: IControl.h:454
virtual void OnMouseDblClick(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse double click event on this control.
Definition: IControl.cpp:258
double GetAnimationProgress() const
Get the progress in a control's animation, in the range 0-1.
Definition: IControl.cpp:431
void PromptUserInput(int valIdx=0)
Call this method in response to a mouse event to create an edit box so the user can enter a value,...
Definition: IControl.cpp:334
virtual void SnapToMouse(float x, float y, EDirection direction, const IRECT &bounds, int valIdx=-1, double minClip=0., double maxClip=1.)
Set control value based on x, y position within a rectangle.
Definition: IControl.cpp:397
virtual void DrawPTHighlight(IGraphics &g)
Implement this to customise how a colored highlight is drawn on the control in ProTools (AAX format o...
Definition: IControl.cpp:389
virtual void SetValueToDefault(int valIdx=kNoValIdx)
Set one or all of the control's values to the default value of the associated parameter.
Definition: IControl.cpp:183
virtual void SetParamIdx(int paramIdx, int valIdx=0)
Set the index of a parameter that the control is linked to If you are calling this "manually" to reus...
Definition: IControl.cpp:115
virtual bool OnGesture(const IGestureInfo &info)
Definition: IControl.cpp:320
const IParam * GetParam(int valIdx=0) const
Get a const pointer to the IParam object (owned by the editor delegate class), associated with this c...
Definition: IControl.cpp:122
void ForValIdx(int valIdx, T func, Args... args)
A helper template function to call a method for an individual value, or for all values.
Definition: IControl.h:532
T * As()
Helper function to dynamic cast an IControl to a subclass.
Definition: IControl.h:518
virtual void SetSize(float w, float h)
Set the size of the control, preserving the current position.
Definition: IControl.cpp:303
void SetPTParameterHighlight(bool isHighlighted, int color)
Used internally by the AAX wrapper view interface to set the control parmeter highlight.
Definition: IControl.cpp:365
void SetRECT(const IRECT &bounds)
Set the rectangular draw area for this control, within the graphics context.
Definition: IControl.h:320
void StartAnimation(int duration)
Definition: IControl.cpp:425
virtual void SetDisabled(bool disable)
Sets disabled mode for the control, the default implementation modifies the mBlend member.
Definition: IControl.cpp:245
virtual void SetValue(double value, int valIdx=0)
Set one of the control's values.
Definition: IControl.cpp:147
double GetValue(int valIdx=0) const
Get the control's value.
Definition: IControl.cpp:153
void SetTargetAndDrawRECTs(const IRECT &bounds)
Set BOTH the draw rect and the target area, within the graphics context for this control.
Definition: IControl.h:332
virtual 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
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
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
void ClearPathList()
Clear the menu.
Definition: IControl.cpp:1079
void CheckSelectedItem()
Check the currently selected menu item.
Definition: IControl.cpp:1122
void SetupMenu()
Call after adding one or more paths, to populate the menu.
Definition: IControl.cpp:1052
void GetSelectedFile(WDL_String &path) const
Get the full path to the file if something has been selected in the menu.
Definition: IControl.cpp:1109
void SetSelectedFile(const char *filePath)
Set the selected file based on a file path.
Definition: IControl.cpp:1087
void AddPath(const char *path, const char *displayText)
Used to add a path to scan for files.
Definition: IControl.cpp:1029
IParam * GetParam(int paramIdx)
Get a pointer to one of the delegate's IParam objects.
virtual void SendParameterValueFromUI(int paramIdx, double normalizedValue)
SPVFUI Called by the UI during a parameter change gesture, in order to notify the host of the new val...
The lowest level base class of an IGraphics context.
Definition: IGraphics.h:86
virtual bool OpenURL(const char *url, const char *msgWindowTitle=0, const char *confirmMsg=0, const char *errMsgOnFailure=0)=0
Open a URL in the platform’s default browser.
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:678
void UpdatePeers(IControl *pCaller, int callerValIdx)
This method is called after interacting with a control, so that any other controls linked to the same...
Definition: IGraphics.cpp:611
virtual void AttachGestureRecognizer(EGestureType type)
Registers a gesture recognizer with the graphics context.
Definition: IGraphics.cpp:2389
void ReleaseMouseCapture()
Used to tell the graphics context to stop tracking mouse interaction with a control.
Definition: IGraphics.cpp:1289
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:2580
virtual void DrawLine(const IColor &color, float x1, float y1, float x2, float y2, const IBlend *pBlend=0, float thickness=1.f)
Draw a line to the graphics context.
Definition: IGraphics.cpp:2427
void GetMouseDownPoint(float &x, float &y) const
Get the x, y position of the last mouse down message.
Definition: IGraphics.h:1599
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:2573
IControl * GetControlInTextEntry()
Definition: IGraphics.h:1136
void PromptUserInput(IControl &control, const IRECT &bounds, int valIdx=0)
Prompt for user input either using a text entry or pop up menu.
Definition: IGraphics.cpp:630
virtual void HideMouseCursor(bool hide=true, bool lock=true)=0
Call to hide/show the mouse cursor.
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:2617
virtual float MeasureText(const IText &text, const char *str, IRECT &bounds) const
Measure the rectangular region that some text will occupy.
Definition: IGraphics.cpp:686
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:810
void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod &mod) override
Implement this method to respond to a mouse drag event on this control.
Definition: IControl.cpp:830
void OnMouseWheel(float x, float y, const IMouseMod &mod, float d) override
Implement this method to respond to a mouse wheel event on this control.
Definition: IControl.cpp:853
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControl.cpp:821
virtual IRECT GetKnobDragBounds()
Get the area for which mouse deltas will be used to calculate the amount dragging changes the control...
Definition: IControl.h:1392
IPlug's parameter class.
double GetStep() const
Returns the parameter's step size.
double GetDefault(bool normalized=false) const
Returns the parameter's default value.
EParamType Type() const
Get the parameter's type.
double ToNormalized(double nonNormalizedValue) const
Convert a real value to normalized value for this parameter.
double ConstrainNormalized(double normalizedValue) const
Constrains a normalised input value similarly to Constrain()
void GetDisplay(WDL_String &display, bool withDisplayText=true) const
Get the current textual display for the current parameter value.
const char * GetLabel() const
Returns the parameter's label.
bool GetStepped() const
double FromNormalized(double normalizedValue) const
Convert a normalized value to real value for this parameter.
void GetDisplayWithLabel(WDL_String &display, bool withDisplayText=true) const
Fills the WDL_String the value of the parameter along with the label, e.g.
double GetRange() const
Returns the parameter's range.
A class to specify an item of a pop up menu.
A class for setting the contents of a pop up menu.
void OnMouseWheel(float x, float y, const IMouseMod &mod, float d) override
Implement this method to respond to a mouse wheel event on this control.
Definition: IControl.cpp:975
void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod &mod) override
Implement this method to respond to a mouse drag event on this control.
Definition: IControl.cpp:935
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:906
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.cpp:899
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControl.cpp:926
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:773
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControl.cpp:765
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControl.cpp:791
A basic control to display some text.
Definition: IControl.h:2157
virtual void SetStrFmt(int maxlen, const char *fmt,...)
Set the text to display, using a printf-like format string.
Definition: IControl.cpp:469
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:479
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControl.cpp:450
void SetBoundsBasedOnStr()
Measures the bounds of the text that the control displays and compacts/expands the control's bounds t...
Definition: IControl.cpp:487
virtual void SetStr(const char *str)
Set the text to display.
Definition: IControl.cpp:456
void SetDirty(bool push, int valIdx=0) override
Mark the control as dirty, i.e.
Definition: IControl.cpp:594
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:584
void SetText(const IText &) override
Set the Text object typically used to determine font/layout/size etc of the main text in a control.
Definition: IControl.cpp:557
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:550
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:504
A base interface to be combined with IControl for vectorial controls "IVControls",...
Definition: IControl.h:762
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:675
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.cpp:707
BEGIN_IPLUG_NAMESPACE BEGIN_IGRAPHICS_NAMESPACE void DefaultAnimationFunc(IControl *pCaller)
An animation function that just calls the caller control's OnEndAnimation() method at the end of the ...
Definition: IControl.cpp:21
void EmptyClickActionFunc(IControl *pCaller)
A click action function that does nothing.
Definition: IControl.cpp:43
void DefaultClickActionFunc(IControl *pCaller)
A click action function that triggers the default animation function for DEFAULT_ANIMATION_DURATION.
Definition: IControl.cpp:45
void SplashClickActionFunc(IControl *pCaller)
The splash click action function is used by IVControls to start SplashAnimationFunc.
Definition: IControl.cpp:47
void SplashAnimationFunc(IControl *pCaller)
The splash animation function is used by IVControls to animate the splash.
Definition: IControl.cpp:30
void ShowBubbleVerticalActionFunc(IControl *pCaller)
Use with a param-linked control to popup the bubble control vertically.
Definition: IControl.cpp:66
void ShowBubbleHorizontalActionFunc(IControl *pCaller)
Use with a param-linked control to popup the bubble control horizontally.
Definition: IControl.cpp:55
Used to describe a particular gesture.
BEGIN_IPLUG_NAMESPACE T Clip(T x, T lo, T hi)
Clips the value x between lo and hi.
Used to manage color data, independent of draw class/platform.
Used to manage mouse modifiers i.e.
Used to manage a rectangular area, independent of draw class/platform.
IRECT GetFromRight(float amount) const
Get a subrect of this IRECT bounded in X by 'amount' and the right 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.
float MH() const
float W() const
void Constrain(float &x, float &y) const
Ensure the point (x,y) is inside this IRECT.
IRECT GetFromLeft(float amount) const
Get a subrect of this IRECT bounded in X by the left edge and 'amount'.
float H() const
float MW() const
IText is used to manage font and text/text entry style for a piece of text on the UI,...