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(mTri.W() > 0.f)
641 {
642 g.FillTriangle(mMouseIsOver ? mTriangleMouseOverColor : mTriangleColor, mTri.L, mTri.T, mTri.R, mTri.T, mTri.MW(), mTri.B, GetMouseIsOver() ? 0 : &BLEND_50);
643 }
644}
645
647{
648 const IParam* pParam = GetParam();
649 if(pParam && pParam->Type() == IParam::kTypeEnum)
650 {
651 mTri = mRECT.FracRectHorizontal(0.2f, true).GetCentredInside(IRECT(0, 0, 8, 5)); //TODO: This seems rubbish
652 }
653}
654
655PlaceHolder::PlaceHolder(const IRECT& bounds, const char* str)
656: ITextControl(bounds, str, IText(20))
657{
658 mBGColor = COLOR_WHITE;
659 mDisablePrompt = false;
660 mDblAsSingleClick = false;
661 mIgnoreMouse = false;
662}
663
665{
666 g.FillRect(mBGColor, mRECT);
667 g.DrawLine(COLOR_RED, mRECT.L, mRECT.T, mRECT.R, mRECT.B, &BLEND_50, 2.f);
668 g.DrawLine(COLOR_RED, mRECT.L, mRECT.B, mRECT.R, mRECT.T, &BLEND_50, 2.f);
669
670 IRECT r = {};
671 g.MeasureText(mHeightText, mHeightStr.Get(), r);
672 g.FillRect(mBGColor, r.GetTranslated(mRECT.L + mInset, mRECT.MH()), &BLEND_50);
673 g.DrawText(mHeightText, mHeightStr.Get(), mRECT.L + mInset, mRECT.MH());
674
675 r = {};
676 g.MeasureText(mWidthText, mWidthStr.Get(), r);
677 g.FillRect(mBGColor, r.GetTranslated(mRECT.MW(), mRECT.T + mInset), &BLEND_75);
678 g.DrawText(mWidthText, mWidthStr.Get(), mRECT.MW(), mRECT.T + mInset);
679
680 r = {};
681 g.MeasureText(mTLGCText, mTLHCStr.Get(), r);
682 g.FillRect(mBGColor, r.GetTranslated(mRECT.L + mInset, mRECT.T + mInset), &BLEND_50);
683 g.DrawText(mTLGCText, mTLHCStr.Get(), mRECT.L + mInset, mRECT.T + mInset);
684
685 if (mStr.GetLength())
686 {
687 r = mRECT;
688 g.MeasureText(mText, mStr.Get(), r);
689 g.FillRect(mBGColor, r, &BLEND_75);
690 g.DrawText(mText, mStr.Get(), r);
691
692 mCentreLabelBounds = r;
693 }
694}
695
697{
698 mTLHCStr.SetFormatted(32, "%0.1f, %0.1f", mRECT.L, mRECT.T);
699 mWidthStr.SetFormatted(32, "%0.1f", mRECT.W());
700 mHeightStr.SetFormatted(32, "%0.1f", mRECT.H());
701}
702
703IButtonControlBase::IButtonControlBase(const IRECT& bounds, IActionFunction aF)
704: IControl(bounds, kNoParameter, aF)
705{
706 mDblAsSingleClick = true;
707}
708
709void IButtonControlBase::OnMouseDown(float x, float y, const IMouseMod& mod)
710{
711 SetValue(1.);
712 SetDirty(true);
713}
714
715void IButtonControlBase::OnEndAnimation()
716{
717 SetValue(0.);
718 IControl::OnEndAnimation();
719}
720
721ISwitchControlBase::ISwitchControlBase(const IRECT& bounds, int paramIdx, IActionFunction aF, int numStates)
722: IControl(bounds, paramIdx, aF)
723, mNumStates(numStates)
724{
725 mDisabledState.Resize(numStates);
726 SetAllStatesDisabled(false);
727 mDblAsSingleClick = true;
728}
729
730void ISwitchControlBase::SetAllStatesDisabled(bool disabled)
731{
732 for(int i=0; i<mNumStates; i++)
733 {
734 SetStateDisabled(i, disabled);
735 }
736 SetDirty(false);
737}
738
739void ISwitchControlBase::SetStateDisabled(int stateIdx, bool disabled)
740{
741 if(stateIdx >= 0 && stateIdx < mNumStates && mDisabledState.GetSize())
742 mDisabledState.Get()[stateIdx] = disabled;
743
744 SetDirty(false);
745}
746
747bool ISwitchControlBase::GetStateDisabled(int stateIdx) const
748{
749 if(stateIdx >= 0 && stateIdx < mNumStates && mDisabledState.GetSize())
750 return mDisabledState.Get()[stateIdx];
751 return false;
752}
753
755{
756 if (GetParamIdx() > kNoParameter)
757 mNumStates = (int) GetParam()->GetRange() + 1;
758
759 assert(mNumStates > 1);
760}
761
762void ISwitchControlBase::OnMouseDown(float x, float y, const IMouseMod& mod)
763{
764 if (mNumStates == 2)
765 SetValue(!GetValue());
766 else
767 {
768 const double step = 1.0 / (double(mNumStates-1));
769 double val = GetValue();
770 val += step;
771 if (val > (1.0 + std::numeric_limits<double>::epsilon()))
772 val = 0.0;
773 SetValue(val);
774 }
775
776 mMouseDown = true;
777 SetDirty(true);
778}
779
780void ISwitchControlBase::OnMouseUp(float x, float y, const IMouseMod& mod)
781{
782 mMouseDown = false;
783 SetDirty(false);
784}
785
786bool IKnobControlBase::IsFineControl(const IMouseMod& mod, bool wheel) const
787{
788#ifdef PROTOOLS
789#ifdef OS_WIN
790 return mod.C;
791#else
792 return wheel ? mod.C : mod.R;
793#endif
794#else
795 return (mod.C || mod.S);
796#endif
797}
798
799void IKnobControlBase::OnMouseDown(float x, float y, const IMouseMod& mod)
800{
801 mMouseDown = true;
802 mMouseDragValue = GetValue();
803
804 if (mHideCursorOnDrag)
805 GetUI()->HideMouseCursor(true, true);
806
807 IControl::OnMouseDown(x, y, mod);
808}
809
810void IKnobControlBase::OnMouseUp(float x, float y, const IMouseMod& mod)
811{
812 if (mHideCursorOnDrag)
813 GetUI()->HideMouseCursor(false);
814
815 mMouseDown = false;
816 SetDirty(false);
817}
818
819void IKnobControlBase::OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod)
820{
821 double gearing = IsFineControl(mod, false) ? mGearing * 10.0 : mGearing;
822
823 IRECT dragBounds = GetKnobDragBounds();
824
825 if (mDirection == EDirection::Vertical)
826 mMouseDragValue += static_cast<double>(dY / static_cast<double>(dragBounds.T - dragBounds.B) / gearing);
827 else
828 mMouseDragValue += static_cast<double>(dX / static_cast<double>(dragBounds.R - dragBounds.L) / gearing);
829
830 mMouseDragValue = Clip(mMouseDragValue, 0., 1.);
831
832 double v = mMouseDragValue;
833 const IParam* pParam = GetParam();
834
835 if (pParam && pParam->GetStepped() && pParam->GetStep() > 0)
836 v = pParam->ConstrainNormalized(mMouseDragValue);
837
838 SetValue(v);
839 SetDirty();
840}
841
842void IKnobControlBase::OnMouseWheel(float x, float y, const IMouseMod& mod, float d)
843{
844 const double gearing = IsFineControl(mod, true) ? 0.001 : 0.01;
845 double newValue = 0.0;
846 const double oldValue = GetValue();
847 const IParam* pParam = GetParam();
848
849 if (pParam && pParam->GetStepped() && pParam->GetStep() > 0)
850 {
851 if (d != 0.f)
852 {
853 const double step = pParam->GetStep();
854 double v = pParam->FromNormalized(oldValue);
855 v += d > 0 ? step : -step;
856 newValue = pParam->ToNormalized(v);
857 }
858 else
859 {
860 newValue = oldValue;
861 }
862 }
863 else
864 {
865 newValue = oldValue + gearing * d;
866 }
867
868 SetValue(newValue);
869 SetDirty();
870}
871
872ISliderControlBase::ISliderControlBase(const IRECT& bounds, int paramIdx, EDirection dir, double gearing, float handleSize)
873: IControl(bounds, paramIdx)
874, mDirection(dir)
875, mHandleSize(handleSize)
876, mGearing(gearing)
877{
878}
879
880 ISliderControlBase::ISliderControlBase(const IRECT& bounds, IActionFunction aF, EDirection dir, double gearing, float handleSize)
881: IControl(bounds, aF)
882, mDirection(dir)
883, mHandleSize(handleSize)
884, mGearing(gearing)
885{
886}
887
889{
890 SetTargetRECT(mRECT);
891 mTrackBounds = mRECT;
892 SetDirty(false);
893}
894
895void ISliderControlBase::OnMouseDown(float x, float y, const IMouseMod& mod)
896{
897 mMouseDown = true;
898
899 if(GetParam())
900 {
901 if(!GetParam()->GetStepped())
902 SnapToMouse(x, y, mDirection, mTrackBounds);
903 }
904 else
905 SnapToMouse(x, y, mDirection, mTrackBounds);
906
907 mMouseDragValue = GetValue();
908
909 if (mHideCursorOnDrag)
910 GetUI()->HideMouseCursor(true, true);
911
912 IControl::OnMouseDown(x, y, mod);
913}
914
915void ISliderControlBase::OnMouseUp(float x, float y, const IMouseMod& mod)
916{
917 if (mHideCursorOnDrag)
918 GetUI()->HideMouseCursor(false);
919
920 mMouseDown = false;
921 SetDirty(false);
922}
923
924void ISliderControlBase::OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod& mod)
925{
926 const IParam* pParam = GetParam();
927
928 if(mod.touchID || !mHideCursorOnDrag)
929 {
930 if(pParam)
931 {
932 if(!pParam->GetStepped())
933 {
934 SnapToMouse(x, y, mDirection, mTrackBounds);
935 return;
936 }
937 // non-stepped parameter, fall through
938 }
939 else
940 {
941 SnapToMouse(x, y, mDirection, mTrackBounds);
942 return;
943 }
944 }
945
946 double gearing = IsFineControl(mod, false) ? mGearing * 10.0 : mGearing;
947
948 if (mDirection == EDirection::Vertical)
949 mMouseDragValue += static_cast<double>(dY / static_cast<double>(mTrackBounds.T - mTrackBounds.B) / gearing);
950 else
951 mMouseDragValue += static_cast<double>(dX / static_cast<double>(mTrackBounds.R - mTrackBounds.L) / gearing);
952
953 mMouseDragValue = Clip(mMouseDragValue, 0., 1.);
954
955 double v = mMouseDragValue;
956
957 if (pParam && pParam->GetStepped() && pParam->GetStep() > 0)
958 v = pParam->ConstrainNormalized(mMouseDragValue);
959
960 SetValue(v);
961 SetDirty(true);
962}
963
964void ISliderControlBase::OnMouseWheel(float x, float y, const IMouseMod& mod, float d)
965{
966 const double gearing = IsFineControl(mod, true) ? 0.001 : 0.01;
967 double newValue = 0.0;
968 const double oldValue = GetValue();
969 const IParam* pParam = GetParam();
970
971 if (pParam && pParam->GetStepped() && pParam->GetStep() > 0)
972 {
973 if (d != 0.f)
974 {
975 const double step = pParam->GetStep();
976 double v = pParam->FromNormalized(oldValue);
977 v += d > 0 ? step : -step;
978 newValue = pParam->ToNormalized(v);
979 }
980 else
981 {
982 newValue = oldValue;
983 }
984 }
985 else
986 {
987 newValue = oldValue + gearing * d;
988 }
989
990 SetValue(newValue);
991 SetDirty();
992}
993
994bool ISliderControlBase::IsFineControl(const IMouseMod& mod, bool wheel) const
995{
996#ifdef PROTOOLS
997#ifdef OS_WIN
998 return mod.C;
999#else
1000 return wheel ? mod.C : mod.R;
1001#endif
1002#else
1003 return (mod.C || mod.S);
1004#endif
1005}
1006
1007
1008IDirBrowseControlBase::~IDirBrowseControlBase()
1009{
1010 ClearPathList();
1011}
1012
1013int IDirBrowseControlBase::NItems() const
1014{
1015 return mItems.GetSize();
1016}
1017
1018void IDirBrowseControlBase::AddPath(const char* path, const char* label)
1019{
1020 assert(strlen(path));
1021
1022 mPaths.Add(new WDL_String(path));
1023 mPathLabels.Add(new WDL_String(label));
1024}
1025
1026void IDirBrowseControlBase::CollectSortedItems(IPopupMenu* pMenu)
1027{
1028 int nItems = pMenu->NItems();
1029
1030 for (int i = 0; i < nItems; i++)
1031 {
1032 IPopupMenu::Item* pItem = pMenu->GetItem(i);
1033
1034 if (pItem->GetSubmenu())
1035 CollectSortedItems(pItem->GetSubmenu());
1036 else
1037 mItems.Add(pItem);
1038 }
1039}
1040
1042{
1043 mFiles.Empty(true);
1044 mItems.Empty(false);
1045
1046 mMainMenu.Clear();
1047 mSelectedItemIndex = -1;
1048
1049 int idx = 0;
1050
1051 if (mPaths.GetSize() == 1)
1052 {
1053 ScanDirectory(mPaths.Get(0)->Get(), mMainMenu);
1054 }
1055 else
1056 {
1057 for (int p = 0; p<mPaths.GetSize(); p++)
1058 {
1059 IPopupMenu* pNewMenu = new IPopupMenu();
1060 mMainMenu.AddItem(mPathLabels.Get(p)->Get(), idx++, pNewMenu);
1061 ScanDirectory(mPaths.Get(p)->Get(), *pNewMenu);
1062 }
1063 }
1064
1065 CollectSortedItems(&mMainMenu);
1066}
1067
1069{
1070 mPaths.Empty(true);
1071 mPathLabels.Empty(true);
1072 mFiles.Empty(true);
1073 mItems.Empty(false);
1074}
1075
1077{
1078 for (auto fileIdx = 0; fileIdx < mFiles.GetSize(); fileIdx ++)
1079 {
1080 if (strcmp(mFiles.Get(fileIdx)->Get(), filePath) == 0)
1081 {
1082 for (auto itemIdx = 0; itemIdx < mItems.GetSize(); itemIdx++)
1083 {
1084 IPopupMenu::Item* pItem = mItems.Get(itemIdx);
1085
1086 if (pItem->GetTag() == fileIdx)
1087 {
1088 mSelectedItemIndex = itemIdx;
1089 return;
1090 }
1091 }
1092 }
1093 }
1094
1095 mSelectedItemIndex = -1;
1096}
1097
1098void IDirBrowseControlBase::GetSelectedFile(WDL_String& path) const
1099{
1100 if (mSelectedItemIndex > -1)
1101 {
1102 IPopupMenu::Item* pItem = mItems.Get(mSelectedItemIndex);
1103 path.Set(mFiles.Get(pItem->GetTag()));
1104 }
1105 else
1106 {
1107 path.Set("");
1108 }
1109}
1110
1112{
1113 if (mSelectedItemIndex > -1)
1114 {
1115 IPopupMenu::Item* pItem = mItems.Get(mSelectedItemIndex);
1116 mMainMenu.CheckItemAlone(pItem);
1117 }
1118}
1119
1120void IDirBrowseControlBase::ScanDirectory(const char* path, IPopupMenu& menuToAddTo)
1121{
1122 WDL_DirScan d;
1123
1124 if (!d.First(path))
1125 {
1126 do
1127 {
1128 const char* f = d.GetCurrentFN();
1129 if (f && f[0] != '.')
1130 {
1131 if (mScanRecursively && d.GetCurrentIsDirectory())
1132 {
1133 WDL_String subdir;
1134 d.GetCurrentFullFN(&subdir);
1135 IPopupMenu* pNewMenu = new IPopupMenu();
1136 menuToAddTo.AddItem(d.GetCurrentFN(), pNewMenu, -2);
1137 ScanDirectory(subdir.Get(), *pNewMenu);
1138 }
1139 else
1140 {
1141 // Find the last occurrence of str2 in str1.
1142 // Return a pointer to the first character of the match.
1143 // Return a pointer to the start of str1 if str2 is empty.
1144 // Return a nullptr if str2 isn't found in str1.
1145 auto strrstr = [](const char* str1, const char* str2) -> const char* {
1146 if (*str2 == '\0')
1147 return str1;
1148
1149 const char* result = nullptr;
1150
1151 while (*str1 != '\0') {
1152 if (std::strncmp(str1, str2, std::strlen(str2)) == 0)
1153 result = str1;
1154
1155 str1++;
1156 }
1157
1158 return result;
1159 };
1160
1161 const char* a = strrstr(f, mExtension.Get());
1162 if (a && a > f && strlen(a) == strlen(mExtension.Get()))
1163 {
1164 WDL_String menuEntry {f};
1165
1166 if (!mShowFileExtensions)
1167 menuEntry.Set(f, (int) (a - f) - 1);
1168
1169 IPopupMenu::Item* pItem = new IPopupMenu::Item(menuEntry.Get(), IPopupMenu::Item::kNoFlags, mFiles.GetSize());
1170 menuToAddTo.AddItem(pItem, -2 /* sort alphabetically */);
1171 WDL_String* pFullPath = new WDL_String("");
1172 d.GetCurrentFullFN(pFullPath);
1173 mFiles.Add(pFullPath);
1174 }
1175 }
1176 }
1177 } while (!d.Next());
1178 }
1179
1180 if (!mShowEmptySubmenus)
1181 menuToAddTo.RemoveEmptySubmenus();
1182}
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:709
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:646
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:474
IControl(const IRECT &bounds, int paramIdx=kNoParameter, IActionFunction actionFunc=nullptr)
Constructor.
Definition: IControl.cpp:83
IGraphics * GetUI()
Definition: IControl.h:467
virtual void OnMouseOut()
Implement this method to respond to a mouseout event on this control.
Definition: IControl.cpp:275
bool mMouseIsOver
if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control.
Definition: IControl.h:560
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:311
int LinkedToParam(int paramIdx) const
Check if the control is linked to a particular parameter.
Definition: IControl.cpp:132
void SetTargetRECT(const IRECT &bounds)
Set the rectangular mouse tracking target area, within the graphics context for this control.
Definition: IControl.h:323
IGEditorDelegate * GetDelegate()
Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes...
Definition: IControl.h:449
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:527
T * As()
Helper function to dynamic cast an IControl to a subclass.
Definition: IControl.h:513
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:315
void StartAnimation(int duration)
Definition: IControl.cpp:425
virtual void SetDisabled(bool disable)
Sets disabled mode for the control, the default implementation modifies the mBlend member.
Definition: IControl.cpp:245
virtual void SetValue(double value, int valIdx=0)
Set one of the control's values.
Definition: IControl.cpp:147
double GetValue(int valIdx=0) const
Get the control's value.
Definition: IControl.cpp:153
void SetTargetAndDrawRECTs(const IRECT &bounds)
Set BOTH the draw rect and the target area, within the graphics context for this control.
Definition: IControl.h:327
virtual int GetValIdxForPos(float x, float y) const
Check to see which of the control's values relates to this x and y coordinate.
Definition: IControl.h:245
int NVals() const
Definition: IControl.h:239
IAnimationFunction GetAnimationFunction()
Get the control's animation function, if it exists.
Definition: IControl.h:500
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
Definition: IControl.cpp:198
IControl * SetActionFunction(IActionFunction actionFunc)
Set an Action Function for this control.
Definition: IControl.h:206
void SetAnimation(IAnimationFunction func)
Set the animation function.
Definition: IControl.h:492
void ClearPathList()
Clear the menu.
Definition: IControl.cpp:1068
void CheckSelectedItem()
Check the currently selected menu item.
Definition: IControl.cpp:1111
void SetupMenu()
Call after adding one or more paths, to populate the menu.
Definition: IControl.cpp:1041
void GetSelectedFile(WDL_String &path) const
Get the full path to the file if something has been selected in the menu.
Definition: IControl.cpp:1098
void SetSelectedFile(const char *filePath)
Set the selected file based on a file path.
Definition: IControl.cpp:1076
void AddPath(const char *path, const char *displayText)
Used to add a path to scan for files.
Definition: IControl.cpp:1018
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:670
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:603
virtual void AttachGestureRecognizer(EGestureType type)
Registers a gesture recognizer with the graphics context.
Definition: IGraphics.cpp:2378
void ReleaseMouseCapture()
Used to tell the graphics context to stop tracking mouse interaction with a control.
Definition: IGraphics.cpp:1278
virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
Definition: IGraphics.cpp:2569
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:2416
void GetMouseDownPoint(float &x, float &y) const
Get the x, y position of the last mouse down message.
Definition: IGraphics.h:1593
virtual void FillTriangle(const IColor &color, float x1, float y1, float x2, float y2, float x3, float y3, const IBlend *pBlend=0)
Fill a triangle with a color.
Definition: IGraphics.cpp:2562
IControl * GetControlInTextEntry()
Definition: IGraphics.h:1131
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:622
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:2606
virtual float MeasureText(const IText &text, const char *str, IRECT &bounds) const
Measure the rectangular region that some text will occupy.
Definition: IGraphics.cpp:678
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:799
void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod &mod) override
Implement this method to respond to a mouse drag event on this control.
Definition: IControl.cpp:819
void OnMouseWheel(float x, float y, const IMouseMod &mod, float d) override
Implement this method to respond to a mouse wheel event on this control.
Definition: IControl.cpp:842
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControl.cpp:810
virtual IRECT GetKnobDragBounds()
Get the area for which mouse deltas will be used to calculate the amount dragging changes the control...
Definition: IControl.h:1387
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:964
void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod &mod) override
Implement this method to respond to a mouse drag event on this control.
Definition: IControl.cpp:924
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:895
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.cpp:888
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControl.cpp:915
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
Definition: IControl.cpp:762
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControl.cpp:754
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
Definition: IControl.cpp:780
A basic control to display some text.
Definition: IControl.h:2152
virtual void SetStrFmt(int maxlen, const char *fmt,...)
Set the text to display, using a printf-like format string.
Definition: IControl.cpp:469
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:479
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
Definition: IControl.cpp:450
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:757
void Draw(IGraphics &g) override
Draw the control to the graphics context.
Definition: IControl.cpp:664
void OnResize() override
Called when IControl is constructed or resized using SetRect().
Definition: IControl.cpp:696
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 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
IRECT FracRectHorizontal(float frac, bool rhs=false) const
Returns a new IRECT with a width that is multiplied by frac.
void Constrain(float &x, float &y) const
Ensure the point (x,y) is inside this IRECT.
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,...