iPlug 2: IControl.cpp Source File

1

2

3

4

5

6

7

8

9

10

11#include <cmath>

12#include <cstring>

13#include "dirscan.h"

14

17

18

19BEGIN_IPLUG_NAMESPACE

20BEGIN_IGRAPHICS_NAMESPACE

22{

24 {

25 pCaller->OnEndAnimation();

26 return;

27 }

28};

29

31{

33

34 if(progress > 1.) {

35 pCaller->OnEndAnimation();

36 return;

37 }

38

39 pCaller->As<IVectorBase>()->SetSplashRadius((float) progress);

41};

42

44

46

48{

49 float x, y;

53}

54

56{

59 assert(pParam && "ShowBubbleHorizontalActionFunc requires a parameter");

61 WDL_String display;

63 pGraphics->ShowBubbleControl(pCaller, bounds.R, bounds.MH(), display.Get(), EDirection::Horizontal, IRECT(0, 0, 50, 30));

64}

65

67{

70 assert(pParam && "ShowBubbleVerticalActionFunc requires a parameter");

72 WDL_String 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

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

103: mRECT(bounds)

104, mTargetRECT(bounds)

105, mActionFunc(aF)

106{

107}

108

110{

111 assert(valIdx > kNoValIdx && valIdx < NVals());

112 return mVals[valIdx].idx;

113}

114

116{

117 assert(valIdx > kNoValIdx && valIdx < NVals());

118 mVals.at(valIdx).idx = paramIdx;

120}

121

123{

125

126 if(paramIdx > kNoParameter)

127 return mDelegate->GetParam(paramIdx);

128 else

129 return nullptr;

130}

131

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

148{

149 assert(valIdx > kNoValIdx && valIdx < NVals());

150 mVals[valIdx].value = value;

151}

152

154{

155 assert(valIdx > kNoValIdx && valIdx < NVals());

156 return mVals[valIdx].value;

157}

158

160{

161

162

163

164 if (!GetUI()->ControlIsCaptured(this))

165 {

166 if(GetValue(valIdx) != value)

167 {

170 }

171 }

172}

173

175{

176 if (GetValue(valIdx) != value)

177 {

180 }

181}

182

184{

185 valIdx = (NVals() == 1) ? 0 : valIdx;

186

187 auto paramDefault = [this](int v)

188 {

190 if (pParam)

192 };

193

196}

197

199{

200 valIdx = (NVals() == 1) ? 0 : valIdx;

201

204

205 mDirty = true;

206

207 if (triggerAction)

208 {

209 auto paramUpdate = [this](int v)

210 {

212 {

215 }

216 };

217

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

240{

241 mHide = hide;

243}

244

246{

247 mBlend.mWeight = (disable ? GRAYED_ALPHA : 1.0f);

248 mDisabled = disable;

250}

251

253{

254 if (mod.R)

256}

257

259{

260 #ifdef AAX_API

262 #else

264 #endif

265}

266

268{

271 if (prev == false)

273}

274

276{

279 if (prev == true)

281}

282

284{

285 if (pSelectedMenu && valIdx > kNoValIdx && GetParamIdx(valIdx) > kNoParameter && !mDisablePrompt)

286 {

288 }

289}

290

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

304{

305 if (w < 0.f) w = 0.f;

306 if (h < 0.f) h = 0.f;

307

309}

310

312{

313 mGestureFuncs.insert(std::make_pair(type, func));

314

316

317 return this;

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())

339 {

341 }

342 else

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);

351 }

352

354 }

355}

356

358{

359 if (valIdx > kNoValIdx && GetParamIdx(valIdx) > kNoParameter && !mDisablePrompt)

360 {

362 }

363}

364

366{

367 switch (color)

368 {

369 case 0:

370 mPTHighlightColor = COLOR_RED;

371 break;

372 case 1:

373 mPTHighlightColor = COLOR_BLUE;

374 break;

375 case 2:

376 mPTHighlightColor = COLOR_GREEN;

377 break;

378 case 3:

379 mPTHighlightColor = COLOR_YELLOW;

380 break;

381 default:

382 break;

383 }

384

385 mPTisHighlighted = isHighlighted;

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{

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

414}

415

416void IControl::OnEndAnimation()

417{

418 mAnimationFunc = nullptr;

420

421 if(mAnimationEndActionFunc)

422 mAnimationEndActionFunc(this);

423}

424

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)

442, mStr(str)

443, mBGColor(BGColor)

444, mSetBoundsBasedOnStr(setBoundsBasedOnStr)

445{

446 mIgnoreMouse = true;

447 mText = text;

448}

449

451{

452 if(mSetBoundsBasedOnStr)

454}

455

457{

458 if (strcmp(mStr.Get(), str))

459 {

460 mStr.Set(str);

461

462 if(mSetBoundsBasedOnStr)

464

466 }

467}

468

470{

471 va_list arglist;

472 va_start(arglist, fmt);

473 mStr.SetAppendFormattedArgs(false, maxlen, fmt, arglist);

474 va_end(arglist);

475

477}

478

480{

481 g.FillRect(mBGColor, mRECT, &mBlend);

482

484 g.DrawText(mText, mStr.Get(), mRECT, &mBlend);

485}

486

488{

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)

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

509 mText.mFGColor = mMOColor;

510 else

511 mText.mFGColor = mClicked ? mCLColor : mOriginalColor;

512

513 if (mStr.GetLength())

514 {

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

551{

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{

569

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

585{

588 else

590

592}

593

595{

597 SetStr(mOnText.Get());

598 else

599 SetStr(mOffText.Get());

600

602}

603

604

607, mShowParamLabel(showParamLabel)

608{

610 mDblAsSingleClick = true;

611 mDisablePrompt = false;

612 mIgnoreMouse = false;

613}

614

616{

617 if (mod.L || mod.R)

618 {

620 }

621}

622

624{

626

627 if (pParam)

628 {

630

631 if (mShowParamLabel)

632 {

633 mStr.Append(" ");

634 mStr.Append(pParam->GetLabel());

635 }

636 }

637

639

640 if (mTriangleRect.W() > 0.f)

641 {

643 mTriangleRect.L, mTriangleRect.T, mTriangleRect.R, mTriangleRect.T, mTriangleRect.MW(), mTriangleRect.B,

645 }

646}

647

649{

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)

661

662 mTriangleRect = dropDownAreaRect.GetCentredInside(IRECT(0.f, 0.f, triangleWidth, triangleHeight));

663 }

664}

665

666PlaceHolder::PlaceHolder(const IRECT& bounds, const char* str)

668{

669 mBGColor = COLOR_WHITE;

670 mDisablePrompt = false;

671 mDblAsSingleClick = false;

672 mIgnoreMouse = false;

673}

674

676{

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

682 g.MeasureText(mHeightText, mHeightStr.Get(), r);

684 g.DrawText(mHeightText, mHeightStr.Get(), mRECT.L + mInset, mRECT.MH());

685

686 r = {};

687 g.MeasureText(mWidthText, mWidthStr.Get(), r);

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;

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

721{

724}

725

726void IButtonControlBase::OnEndAnimation()

727{

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 }

748}

749

750void ISwitchControlBase::SetStateDisabled(int stateIdx, bool disabled)

751{

752 if(stateIdx >= 0 && stateIdx < mNumStates && mDisabledState.GetSize())

753 mDisabledState.Get()[stateIdx] = disabled;

754

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{

769

770 assert(mNumStates > 1);

771}

772

774{

775 if (mNumStates == 2)

777 else

778 {

779 const double step = 1.0 / (double(mNumStates-1));

781 val += step;

782 if (val > (1.0 + std::numeric_limits<double>::epsilon()))

783 val = 0.0;

785 }

786

787 mMouseDown = true;

789}

790

792{

793 mMouseDown = 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

811{

812 mMouseDown = true;

813 mMouseDragValue = GetValue();

814

815 if (mHideCursorOnDrag)

817

819}

820

822{

823 if (mHideCursorOnDrag)

825

826 mMouseDown = false;

828}

829

831{

832 double gearing = IsFineControl(mod, false) ? mGearing * 10.0 : mGearing;

833

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;

845

848

851}

852

854{

855 const double gearing = IsFineControl(mod, true) ? 0.001 : 0.01;

856 double newValue = 0.0;

857 const double oldValue = GetValue();

859

861 {

862 if (d != 0.f)

863 {

864 const double step = pParam->GetStep();

866 v += d > 0 ? step : -step;

868 }

869 else

870 {

871 newValue = oldValue;

872 }

873 }

874 else

875 {

876 newValue = oldValue + gearing * d;

877 }

878

881}

882

883ISliderControlBase::ISliderControlBase(const IRECT& bounds, int paramIdx, EDirection dir, double gearing, float handleSize)

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)

893, mDirection(dir)

894, mHandleSize(handleSize)

895, mGearing(gearing)

896{

897}

898

900{

902 mTrackBounds = mRECT;

904}

905

907{

908 mMouseDown = true;

909

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)

922

924}

925

927{

928 if (mHideCursorOnDrag)

930

931 mMouseDown = false;

933}

934

936{

938

939 if(mod.touchID || !mHideCursorOnDrag)

940 {

941 if(pParam)

942 {

944 {

945 SnapToMouse(x, y, mDirection, mTrackBounds);

946 return;

947 }

948

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

970

973}

974

976{

977 const double gearing = IsFineControl(mod, true) ? 0.001 : 0.01;

978 double newValue = 0.0;

979 const double oldValue = GetValue();

981

983 {

984 if (d != 0.f)

985 {

986 const double step = pParam->GetStep();

988 v += d > 0 ? step : -step;

990 }

991 else

992 {

993 newValue = oldValue;

994 }

995 }

996 else

997 {

998 newValue = oldValue + gearing * d;

999 }

1000

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{

1022}

1023

1024int IDirBrowseControlBase::NItems() const

1025{

1026 return mItems.GetSize();

1027}

1028

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 {

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 {

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 {

1096

1097 if (pItem->GetTag() == fileIdx)

1098 {

1099 mSelectedItemIndex = itemIdx;

1100 return;

1101 }

1102 }

1103 }

1104 }

1105

1106 mSelectedItemIndex = -1;

1107}

1108

1110{

1111 if (mSelectedItemIndex > -1)

1112 {

1114 path.Set(mFiles.Get(pItem->GetTag()));

1115 }

1116 else

1117 {

1118 path.Set("");

1119 }

1120}

1121

1123{

1124 if (mSelectedItemIndex > -1)

1125 {

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);

1147 menuToAddTo.AddItem(d.GetCurrentFN(), pNewMenu, -2);

1148 ScanDirectory(subdir.Get(), *pNewMenu);

1149 }

1150 else

1151 {

1152

1153

1154

1155

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

1181 menuToAddTo.AddItem(pItem, -2 );

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.

void OnMouseDown(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse down event on this control.

ICaptionControl(const IRECT &bounds, int paramIdx, const IText &text=DEFAULT_TEXT, const IColor &BGColor=DEFAULT_BGCOLOR, bool showParamLabel=true)

Creates an ICaptionControl.

void OnResize() override

Called when IControl is constructed or resized using SetRect().

void Draw(IGraphics &g) override

Draw the control to the graphics context.

The lowest level base class of an IGraphics control.

bool GetMouseIsOver() const

This can be used in IControl::Draw() to check if the mouse is over the control, without implementing ...

IControl(const IRECT &bounds, int paramIdx=kNoParameter, IActionFunction actionFunc=nullptr)

Constructor.

virtual void OnMouseOut()

Implement this method to respond to a mouseout event on this control.

bool mMouseIsOver

if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control.

virtual void OnMouseOver(float x, float y, const IMouseMod &mod)

Implement this method to respond to a mouseover event on this control.

virtual void SetPosition(float x, float y)

Set the position of the control, preserving the width and height.

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...

virtual void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx)

Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControlPromptU...

virtual void OnMouseDown(float x, float y, const IMouseMod &mod)

Implement this method to respond to a mouse down event on this control.

virtual void SetValueFromUserInput(double value, int valIdx=0)

Set the control's value after user input.

virtual bool IsDirty()

Called at each display refresh by the IGraphics draw loop, after IControl::Animate(),...

virtual void Hide(bool hide)

Shows or hides the IControl.

IControl * AttachGestureRecognizer(EGestureType type, IGestureFunc func)

Add a IGestureFunc that should be triggered in response to a certain type of gesture.

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...

const IRECT & GetRECT() const

Get the rectangular draw area for this control, within the graphics context.

int LinkedToParam(int paramIdx) const

Check if the control is linked to a particular parameter.

void SetTargetRECT(const IRECT &bounds)

Set the rectangular mouse tracking target area, within the graphics context for this control.

IGEditorDelegate * GetDelegate()

Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes...

virtual void OnMouseDblClick(float x, float y, const IMouseMod &mod)

Implement this method to respond to a mouse double click event on this control.

double GetAnimationProgress() const

Get the progress in a control's animation, in the range 0-1.

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,...

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.

virtual void DrawPTHighlight(IGraphics &g)

Implement this to customise how a colored highlight is drawn on the control in ProTools (AAX format o...

virtual void SetValueToDefault(int valIdx=kNoValIdx)

Set one or all of the control's values to the default value of the associated parameter.

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...

virtual bool OnGesture(const IGestureInfo &info)

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...

void ForValIdx(int valIdx, T func, Args... args)

A helper template function to call a method for an individual value, or for all values.

T * As()

Helper function to dynamic cast an IControl to a subclass.

virtual void SetSize(float w, float h)

Set the size of the control, preserving the current position.

void SetPTParameterHighlight(bool isHighlighted, int color)

Used internally by the AAX wrapper view interface to set the control parmeter highlight.

void SetRECT(const IRECT &bounds)

Set the rectangular draw area for this control, within the graphics context.

void StartAnimation(int duration)

virtual void SetDisabled(bool disable)

Sets disabled mode for the control, the default implementation modifies the mBlend member.

virtual void SetValue(double value, int valIdx=0)

Set one of the control's values.

double GetValue(int valIdx=0) const

Get the control's value.

void SetTargetAndDrawRECTs(const IRECT &bounds)

Set BOTH the draw rect and the target area, within the graphics context for this control.

virtual int GetValIdxForPos(float x, float y) const

Check to see which of the control's values relates to this x and y coordinate.

IAnimationFunction GetAnimationFunction()

Get the control's animation function, if it exists.

virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)

Mark the control as dirty, i.e.

IControl * SetActionFunction(IActionFunction actionFunc)

Set an Action Function for this control.

void SetAnimation(IAnimationFunction func)

Set the animation function.

void ClearPathList()

Clear the menu.

void CheckSelectedItem()

Check the currently selected menu item.

void SetupMenu()

Call after adding one or more paths, to populate the menu.

void GetSelectedFile(WDL_String &path) const

Get the full path to the file if something has been selected in the menu.

void SetSelectedFile(const char *filePath)

Set the selected file based on a file path.

void AddPath(const char *path, const char *displayText)

Used to add a path to scan for files.

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.

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.

void UpdatePeers(IControl *pCaller, int callerValIdx)

This method is called after interacting with a control, so that any other controls linked to the same...

virtual void AttachGestureRecognizer(EGestureType type)

Registers a gesture recognizer with the graphics context.

void ReleaseMouseCapture()

Used to tell the graphics context to stop tracking mouse interaction with a control.

virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)

Fill a rectangular region of the graphics context with a color.

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.

void GetMouseDownPoint(float &x, float &y) const

Get the x, y position of the last mouse down message.

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.

IControl * GetControlInTextEntry()

void PromptUserInput(IControl &control, const IRECT &bounds, int valIdx=0)

Prompt for user input either using a text entry or pop up menu.

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.

virtual float MeasureText(const IText &text, const char *str, IRECT &bounds) const

Measure the rectangular region that some text will occupy.

void OnMouseDown(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse down event on this control.

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.

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.

void OnMouseUp(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse up event on this control.

virtual IRECT GetKnobDragBounds()

Get the area for which mouse deltas will be used to calculate the amount dragging changes the control...

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.

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.

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.

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.

void OnMouseDown(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse down event on this control.

void OnResize() override

Called when IControl is constructed or resized using SetRect().

void OnMouseUp(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse up event on this control.

void OnMouseDown(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse down event on this control.

void OnInit() override

Called just prior to when the control is attached, after its delegate and graphics member variable se...

void OnMouseUp(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse up event on this control.

A basic control to display some text.

virtual void SetStrFmt(int maxlen, const char *fmt,...)

Set the text to display, using a printf-like format string.

void Draw(IGraphics &g) override

Draw the control to the graphics context.

void OnInit() override

Called just prior to when the control is attached, after its delegate and graphics member variable se...

void SetBoundsBasedOnStr()

Measures the bounds of the text that the control displays and compacts/expands the control's bounds t...

virtual void SetStr(const char *str)

Set the text to display.

void SetDirty(bool push, int valIdx=0) override

Mark the control as dirty, i.e.

void OnMouseDown(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse down event on this control.

void SetText(const IText &) override

Set the Text object typically used to determine font/layout/size etc of the main text in a control.

void OnMouseDown(float x, float y, const IMouseMod &mod) override

Implement this method to respond to a mouse down event on this control.

void Draw(IGraphics &g) override

Draw the control to the graphics context.

A base interface to be combined with IControl for vectorial controls "IVControls",...

void Draw(IGraphics &g) override

Draw the control to the graphics context.

void OnResize() override

Called when IControl is constructed or resized using SetRect().

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 ...

void EmptyClickActionFunc(IControl *pCaller)

A click action function that does nothing.

void DefaultClickActionFunc(IControl *pCaller)

A click action function that triggers the default animation function for DEFAULT_ANIMATION_DURATION.

void SplashClickActionFunc(IControl *pCaller)

The splash click action function is used by IVControls to start SplashAnimationFunc.

void SplashAnimationFunc(IControl *pCaller)

The splash animation function is used by IVControls to animate the splash.

void ShowBubbleVerticalActionFunc(IControl *pCaller)

Use with a param-linked control to popup the bubble control vertically.

void ShowBubbleHorizontalActionFunc(IControl *pCaller)

Use with a param-linked control to popup the bubble control horizontally.

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.

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'.

IText is used to manage font and text/text entry style for a piece of text on the UI,...