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