21 #include <unordered_map> 23 #if defined VST3_API || defined VST3C_API 26 #include "pluginterfaces/vst/ivstcontextmenu.h" 27 #include "base/source/fobject.h" 32 #include "wdlstring.h" 38 BEGIN_IGRAPHICS_NAMESPACE
43 #if defined VST3_API || defined VST3C_API
44 :
public Steinberg::Vst::IContextMenuTarget
45 ,
public Steinberg::FObject
56 IControl(
const IRECT& bounds,
int paramIdx = kNoParameter, IActionFunction actionFunc =
nullptr);
65 IControl(
const IRECT& bounds,
const std::initializer_list<int>& params, IActionFunction actionFunc =
nullptr);
76 void operator=(
const IControl&) =
delete;
210 inline void SetTooltip(
const char* str) { mTooltip.Set(str); }
213 inline const char*
GetTooltip()
const {
return mTooltip.Get(); }
225 virtual void SetParamIdx(
int paramIdx,
int valIdx = 0);
233 int NVals()
const {
return (
int) mVals.size(); }
239 virtual int GetValIdxForPos(
float x,
float y)
const {
return mVals.size() == 1 ? 0 : kNoValIdx; }
265 virtual void SetValue(
double value,
int valIdx = 0);
270 double GetValue(
int valIdx = 0)
const;
331 virtual void SetSize(
float w,
float h);
346 virtual void Hide(
bool hide);
385 virtual bool IsHit(
float x,
float y)
const {
return mTargetRECT.
Contains(x, y); }
391 virtual void SetDirty(
bool triggerAction =
true,
int valIdx = kNoValIdx);
394 virtual void SetClean() { mDirty =
false; }
445 mGraphics = dlg.
GetUI();
467 virtual void SnapToMouse(
float x,
float y, EDirection direction,
const IRECT& bounds,
int valIdx = -1,
double minClip = 0.,
double maxClip = 1.);
470 virtual void OnEndAnimation();
498 T*
As() {
return dynamic_cast<T*
>(
this); }
500 #if defined VST3_API || defined VST3C_API 501 Steinberg::tresult PLUGIN_API executeMenuItem (Steinberg::int32 tag)
override {
OnContextSelection(tag);
return Steinberg::kResultOk; }
504 #pragma mark - IControl Member variables 511 template<
typename T,
typename... Args>
514 if (valIdx > kNoValIdx)
515 func(valIdx, args...);
518 const int nVals =
NVals();
519 for (
int v = 0; v < nVals; v++)
532 int mTextEntryLength = DEFAULT_TEXT_ENTRY_LEN;
535 bool mDisabled =
false;
536 bool mDisablePrompt =
true;
537 bool mDblAsSingleClick =
false;
538 bool mMouseOverWhenDisabled =
false;
539 bool mMouseEventsWhenDisabled =
false;
540 bool mIgnoreMouse =
false;
541 bool mWantsMidi =
false;
542 bool mWantsMultiTouch =
false;
543 bool mPromptShowsParamLabel =
false;
548 IColor mPTHighlightColor = COLOR_RED;
549 bool mPTisHighlighted =
false;
551 void SetNVals(
int nVals)
557 #if defined VST3_API || defined VST3C_API 560 DEF_INTERFACE (IContextMenuTarget)
561 END_DEFINE_INTERFACES (FObject)
562 REFCOUNT_METHODS(FObject)
568 IActionFunction mActionFunc =
nullptr;
569 IActionFunction mAnimationEndActionFunc =
nullptr;
570 IAnimationFunction mAnimationFunc =
nullptr;
571 TimePoint mAnimationStartTime;
572 Milliseconds mAnimationDuration;
573 std::vector<ParamTuple> mVals { {kNoParameter, 0.} };
574 std::unordered_map<EGestureType, IGestureFunc> mGestureFuncs;
575 EGestureType mLastGesture = EGestureType::Unknown;
578 #pragma mark - Base Controls 610 i = 1 + int(0.5 + mControl->GetValue() * (double) (mBitmap.N() - 1));
611 i =
Clip(i, 1, mBitmap.N());
613 IBlend blend = mControl->GetBlend();
614 g.
DrawBitmap(mBitmap, mControl->GetRECT().GetCentredInside(
IRECT(0, 0, mBitmap)), i, &blend);
632 : mLabelInWidget(labelInWidget)
633 , mValueInWidget(valueInWidget)
644 mLabelStr.Set(label);
652 mStyle.colorSpec.mColors[
static_cast<int>(colorIdx)] = color;
653 mControl->SetDirty(
false);
660 mStyle.colorSpec = spec;
666 return mStyle.colorSpec.GetColor(color);
669 void SetLabelStr(
const char* label) { mLabelStr.
Set(label); mControl->SetDirty(
false); }
670 void SetValueStr(
const char* value) { mValueStr.Set(value); mControl->SetDirty(
false); }
671 void SetWidgetFrac(
float frac) { mStyle.widgetFrac =
Clip(frac, 0.f, 1.f); mControl->OnResize(); mControl->SetDirty(
false); }
672 void SetAngle(
float angle) { mStyle.angle =
Clip(angle, 0.f, 360.f); mControl->SetDirty(
false); }
673 void SetShowLabel(
bool show) { mStyle.showLabel = show; mControl->OnResize(); mControl->SetDirty(
false); }
674 void SetShowValue(
bool show) { mStyle.showValue = show; mControl->OnResize(); mControl->SetDirty(
false); }
675 void SetRoundness(
float roundness) { mStyle.roundness =
Clip(roundness, 0.f, 1.f); mControl->SetDirty(
false); }
676 void SetDrawFrame(
bool draw) { mStyle.drawFrame = draw; mControl->SetDirty(
false); }
677 void SetDrawShadows(
bool draw) { mStyle.drawShadows = draw; mControl->SetDirty(
false); }
678 void SetEmboss(
bool draw) { mStyle.emboss = draw; mControl->SetDirty(
false); }
679 void SetShadowOffset(
float offset) { mStyle.shadowOffset = offset; mControl->SetDirty(
false); }
680 void SetFrameThickness(
float thickness) { mStyle.frameThickness = thickness; mControl->SetDirty(
false); }
681 void SetSplashRadius(
float radius) { mSplashRadius = radius * mMaxSplashRadius; }
682 void SetSplashPoint(
float x,
float y) { mSplashPoint.x = x; mSplashPoint.y = y; }
683 void SetShape(EVShape shape) { mShape = shape; mControl->SetDirty(
false); }
690 SetColors(style.colorSpec);
703 handleBounds.
Pad(- 0.5f * mStyle.frameThickness);
705 if (mStyle.drawShadows)
706 handleBounds.
Offset(mStyle.shadowOffset, 0, -mStyle.shadowOffset, -mStyle.shadowOffset);
716 if(bounds.
W() < bounds.
H())
717 return mStyle.roundness * (bounds.
W() / 2.f);
719 return mStyle.roundness * (bounds.
H() / 2.f);
728 g.
FillCircle(GetColor(kHL), mSplashPoint.x, mSplashPoint.y, mSplashRadius);
735 IBlend blend = mControl->GetBlend();
736 g.
FillRect(GetColor(kBG), rect, &blend);
748 if (mLabelBounds.H() && mStyle.showLabel)
750 IBlend blend = mControl->GetBlend();
751 g.
DrawText(mStyle.labelText, mLabelStr.Get(), mLabelBounds, &blend);
759 g.
FillRect(COLOR_TRANSLUCENT, mValueBounds);
761 if (mStyle.showValue)
763 IBlend blend = mControl->GetBlend();
764 g.
DrawText(mStyle.valueText, mValueStr.Get(), mValueBounds, &blend);
779 case EVShape::Ellipse:
780 DrawPressableEllipse(g, bounds, pressed, mouseOver, disabled);
782 case EVShape::Rectangle:
783 DrawPressableRectangle(g, bounds, pressed, mouseOver, disabled);
785 case EVShape::Triangle:
786 DrawPressableTriangle(g, bounds, pressed, mouseOver, mStyle.angle, disabled);
788 case EVShape::EndsRounded:
789 DrawPressableRectangle(g, bounds, pressed, mouseOver, disabled,
true,
true,
false,
false);
791 case EVShape::AllRounded:
792 DrawPressableRectangle(g, bounds, pressed, mouseOver, disabled,
true,
true,
true,
true);
806 IRECT handleBounds = bounds;
809 const IBlend blend = mControl->GetBlend();
810 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
812 if(!pressed && !disabled && mStyle.drawShadows)
826 g.
FillEllipse(GetColor(kFG).WithContrast(contrast), shadowBounds);
829 g.
FillEllipse(GetColor(kPR).WithContrast(contrast), centreBounds);
832 g.
FillEllipse(GetColor(kPR).WithContrast(contrast), handleBounds);
840 g.
FillEllipse(GetColor(kPR).WithContrast(contrast), bounds);
843 g.
FillEllipse(GetColor(kSH).WithContrast(contrast), shadowBounds);
846 g.
FillEllipse(GetColor(kFG).WithContrast(contrast), centreBounds);
850 g.
FillEllipse(GetColor(kHL), centreBounds, &blend);
854 g.
FillEllipse(GetColor(kFG).WithContrast(contrast), handleBounds);
858 g.
FillEllipse(GetColor(kHL), handleBounds, &blend);
862 if(pressed && mControl->GetAnimationFunction())
863 DrawSplash(g, handleBounds);
866 g.
DrawEllipse(GetColor(kFR), handleBounds, &blend, mStyle.frameThickness);
877 bool rtl =
true,
bool rtr =
true,
bool rbl =
true,
bool rbr =
true)
879 IRECT handleBounds = GetAdjustedHandleBounds(bounds);
880 IRECT centreBounds = handleBounds.
GetPadded(-mStyle.shadowOffset);
881 IRECT shadowBounds = handleBounds.
GetTranslated(mStyle.shadowOffset, mStyle.shadowOffset);
882 const IBlend blend = mControl->GetBlend();
883 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
884 float cR = GetRoundedCornerRadius(handleBounds);
886 const float tlr = rtl ? cR : 0.f;
887 const float trr = rtr ? cR : 0.f;
888 const float blr = rbl ? cR : 0.f;
889 const float brr = rbr ? cR : 0.f;
899 g.
FillRoundRect(GetColor(kPR), handleBounds, tlr, trr, blr, brr, &blend);
900 g.
FillRoundRect(GetColor(kSH), handleBounds, tlr, trr, blr, brr, &blend);
903 g.
FillRoundRect(GetColor(kFG).WithContrast(contrast), shadowBounds, tlr, trr, blr, brr);
906 g.
FillRoundRect(GetColor(kPR), centreBounds, tlr, trr, blr, brr, &blend);
910 g.
FillRoundRect(GetColor(kPR).WithContrast(contrast), handleBounds, tlr, trr, blr, brr);
916 if (mStyle.drawShadows)
917 g.
FillRoundRect(GetColor(kSH), shadowBounds, tlr, trr, blr, brr, &blend);
923 g.
FillRoundRect(GetColor(kPR).WithContrast(contrast), handleBounds, tlr, trr, blr, brr);
926 g.
FillRoundRect(GetColor(kSH).WithContrast(contrast), shadowBounds, tlr, trr, blr, brr);
929 g.
FillRoundRect(GetColor(kFG).WithContrast(contrast), centreBounds, tlr, trr, blr, brr);
933 g.
FillRoundRect(GetColor(kHL), centreBounds, tlr, trr, blr, brr, &blend);
937 g.
FillRoundRect(GetColor(kFG).WithContrast(contrast), handleBounds, tlr, trr, blr, brr);
941 g.
FillRoundRect(GetColor(kHL), handleBounds, tlr, trr, blr, brr, &blend);
945 if(pressed && mControl->GetAnimationFunction())
946 DrawSplash(g, handleBounds);
949 g.
DrawRoundRect(GetColor(kFR), handleBounds, tlr, trr, blr, brr, &blend, mStyle.frameThickness);
961 float x1, x2, x3, y1, y2, y3;
963 float theta = DegToRad(angle);
965 IRECT handleBounds = GetAdjustedHandleBounds(bounds);
968 float xT = handleBounds.
L + handleBounds.
W() * 0.5f;
969 float yT = handleBounds.
T + handleBounds.
H() * 0.5f;
973 float c = cosf(theta);
974 float s = sinf(theta);
975 x1 = centered.
L * c - centered.
B * s + xT;
976 y1 = centered.
L * s + centered.
B * c + yT;
977 x2 = centered.
MW() * c - centered.
T * s + xT;
978 y2 = centered.
MW() * s + centered.
T * c + yT;
979 x3 = centered.
R * c - centered.
B * s + xT;
980 y3 = centered.
R * s + centered.
B * c + yT;
982 const IBlend blend = mControl->GetBlend();
983 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
986 g.
FillTriangle(GetColor(kPR).WithContrast(contrast), x1, y1, x2, y2, x3, y3);
990 if (mStyle.drawShadows)
991 g.
FillTriangle(GetColor(kSH), x1 + mStyle.shadowOffset, y1 + mStyle.shadowOffset,
992 x2 + mStyle.shadowOffset, y2 + mStyle.shadowOffset,
993 x3 + mStyle.shadowOffset, y3 + mStyle.shadowOffset, &blend);
995 g.
FillTriangle(GetColor(kFG).WithContrast(contrast), x1, y1, x2, y2, x3, y3);
999 g.
FillTriangle(GetColor(kHL), x1, y1, x2, y2, x3, y3, &blend);
1001 if(pressed && mControl->GetAnimationFunction())
1004 if (mStyle.drawFrame)
1005 g.
DrawTriangle(GetColor(kFR), x1, y1, x2, y2, x3, y3, &blend, mStyle.frameThickness);
1007 return handleBounds;
1016 IRECT clickableArea = parent;
1020 if(mStyle.showLabel && CStringHasContents(mLabelStr.Get()))
1023 mControl->GetUI()->MeasureText(mStyle.labelText, mLabelStr.Get(), textRect);
1025 mLabelBounds = parent.
GetFromTop(textRect.
H()).GetCentredInside(textRect.
W(), textRect.
H());
1028 mLabelBounds =
IRECT();
1030 if(mLabelBounds.H())
1034 if (mStyle.showValue && !mValueInWidget)
1038 if(CStringHasContents(mValueStr.Get()))
1039 mControl->GetUI()->MeasureText(mStyle.valueText, mValueStr.Get(), textRect);
1041 const float valueDisplayWidth = textRect.
W() * mValueDisplayFrac;
1043 switch (mStyle.valueText.mVAlign)
1045 case EVAlign::Middle:
1046 mValueBounds = clickableArea.
GetMidVPadded(textRect.
H()/2.f).GetMidHPadded(valueDisplayWidth);
1049 case EVAlign::Bottom:
1051 mValueBounds = clickableArea.
GetFromBottom(textRect.
H()).GetMidHPadded(valueDisplayWidth);
1052 mWidgetBounds = clickableArea.
GetReducedFromBottom(textRect.
H()).GetScaledAboutCentre(mStyle.widgetFrac);
1056 mValueBounds = clickableArea.
GetFromTop(textRect.
H()).GetMidHPadded(valueDisplayWidth);
1057 mWidgetBounds = clickableArea.
GetReducedFromTop(textRect.
H()).GetScaledAboutCentre(mStyle.widgetFrac);
1069 mWidgetBounds = GetAdjustedHandleBounds(clickableArea).
GetScaledAboutCentre(mStyle.widgetFrac);
1072 mLabelBounds = mWidgetBounds;
1075 mValueBounds = mWidgetBounds;
1077 return clickableArea;
1083 bool mLabelInWidget =
false;
1084 bool mValueInWidget =
false;
1085 float mSplashRadius = 0.f;
1086 IVec2 mSplashPoint = {0.f, 0.f};
1087 float mMaxSplashRadius = 50.f;
1088 float mTrackSize = 2.f;
1089 float mValueDisplayFrac = 0.66f;
1090 IRECT mWidgetBounds;
1093 WDL_String mLabelStr;
1094 WDL_String mValueStr;
1095 EVShape mShape = EVShape::Rectangle;
1110 TimePoint startTime;
1112 TrackedTouch(
int index,
float x,
float y,
float radius, TimePoint time)
1113 : index(index), x(x), y(y), sx(x), sy(y), radius(radius), startTime(time)
1120 virtual void AddTouch(ITouchID touchID,
float x,
float y,
float radius)
1123 for (
int i = 0; i < MAX_TOUCHES; i++)
1125 if (mTouchStatus[i] ==
false)
1128 mTouchStatus[i] =
true;
1133 if(NTrackedTouches() < MAX_TOUCHES)
1134 mTrackedTouches.insert(std::make_pair(touchID,
TrackedTouch(touchIndex, x, y, radius, std::chrono::high_resolution_clock::now())));
1137 virtual void ReleaseTouch(ITouchID touchID)
1139 mTouchStatus[GetTouchWithIdentifier(touchID)->index] =
false;
1140 mTrackedTouches.erase(touchID);
1143 virtual void UpdateTouch(ITouchID touchID,
float x,
float y,
float radius)
1145 mTrackedTouches[touchID].x = x;
1146 mTrackedTouches[touchID].y = y;
1147 mTrackedTouches[touchID].radius = radius;
1150 void ClearAllTouches()
1152 mTrackedTouches.clear();
1153 memset(mTouchStatus, 0, MAX_TOUCHES *
sizeof(
bool));
1156 int NTrackedTouches()
const 1158 return static_cast<int>(mTrackedTouches.size());
1163 auto itr = std::find_if(mTrackedTouches.begin(), mTrackedTouches.end(),
1164 [index](
auto element) {
1165 return(element.second.index == index);
1168 if(itr != mTrackedTouches.end())
1169 return &itr->second;
1176 auto itr = mTrackedTouches.find(touchID);
1178 if(itr != mTrackedTouches.end())
1179 return &itr->second;
1185 static constexpr
int MAX_TOUCHES = 10;
1186 std::unordered_map<ITouchID, TrackedTouch> mTrackedTouches;
1187 bool mTouchStatus[MAX_TOUCHES] = { 0 };
1194 IKnobControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, EDirection direction = EDirection::Vertical,
double gearing = DEFAULT_GEARING)
1196 , mDirection(direction)
1205 void SetGearing(
double gearing) { mGearing = gearing; }
1206 bool IsFineControl(
const IMouseMod& mod,
bool wheel)
const;
1213 bool mHideCursorOnDrag =
true;
1214 EDirection mDirection;
1216 bool mMouseDown =
false;
1217 double mMouseDragValue = 0.0;
1224 ISliderControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical,
double gearing = DEFAULT_GEARING,
float handleSize = 0.f);
1225 ISliderControlBase(
const IRECT& bounds, IActionFunction aF =
nullptr, EDirection dir = EDirection::Vertical,
double gearing = DEFAULT_GEARING,
float handleSize = 0.f);
1233 void SetGearing(
double gearing) { mGearing = gearing; }
1234 bool IsFineControl(
const IMouseMod& mod,
bool wheel)
const;
1237 bool mHideCursorOnDrag =
true;
1238 EDirection mDirection;
1242 bool mMouseDown =
false;
1243 double mMouseDragValue;
1252 IVTrackControlBase(
const IRECT& bounds,
const char* label,
const IVStyle& style,
int maxNTracks = 1,
int nSteps = 0, EDirection dir = EDirection::Horizontal, std::initializer_list<const char*> trackNames = {})
1258 SetNVals(maxNTracks);
1259 mTrackBounds.Resize(maxNTracks);
1261 for (
int i=0; i<maxNTracks; i++)
1266 if(trackNames.size())
1268 assert(trackNames.size() == maxNTracks);
1270 for (
auto& trackName : trackNames)
1272 mTrackNames.Add(
new WDL_String(trackName));
1276 AttachIControl(
this, label);
1279 IVTrackControlBase(
const IRECT& bounds,
const char* label,
const IVStyle& style,
int lowParamidx,
int maxNTracks = 1,
int nSteps = 0, EDirection dir = EDirection::Horizontal, std::initializer_list<const char*> trackNames = {})
1285 SetNVals(maxNTracks);
1286 mTrackBounds.Resize(maxNTracks);
1288 for (
int i = 0; i < maxNTracks; i++)
1293 if(trackNames.size())
1295 assert(trackNames.size() == maxNTracks);
1297 for (
auto& trackName : trackNames)
1299 mTrackNames.Add(
new WDL_String(trackName));
1303 AttachIControl(
this, label);
1306 IVTrackControlBase(
const IRECT& bounds,
const char* label,
const IVStyle& style,
const std::initializer_list<int>& params,
int nSteps = 0, EDirection dir = EDirection::Horizontal, std::initializer_list<const char*> trackNames = {})
1312 int maxNTracks =
static_cast<int>(params.size());
1313 SetNVals(maxNTracks);
1314 mTrackBounds.Resize(maxNTracks);
1317 for (
auto param : params)
1322 if(trackNames.size())
1324 assert(trackNames.size() == params.size());
1326 for (
auto& trackName : trackNames)
1328 mTrackNames.Add(
new WDL_String(trackName));
1332 AttachIControl(
this, label);
1337 mTrackNames.Empty(
true);
1348 mMouseOverTrack = -1;
1355 MakeTrackRects(mWidgetBounds);
1356 MakeStepRects(mWidgetBounds, mNSteps);
1362 int nVals =
NVals();
1364 for (
auto v = 0; v < nVals; v++)
1366 if (mTrackBounds.Get()[v].Contains(x, y))
1377 const int nVals =
NVals();
1379 for (
int ch = 0; ch < nVals; ch++)
1381 DrawTrack(g, mTrackBounds.Get()[ch], ch);
1390 std::vector<int> paramIdsForGroup;
1392 for (
auto p = 0; p < nParams; p++)
1396 if(strcmp(pParam->
GetGroup(), paramGroup) == 0)
1398 paramIdsForGroup.push_back(p);
1402 SetParams(paramIdsForGroup);
1409 int nParams =
static_cast<int>(paramIds.size());
1412 mTrackBounds.Resize(nParams);
1415 for (
auto param : paramIds)
1421 const int range =
static_cast<int>(pFirstParam->
GetRange() / pFirstParam->
GetStep());
1422 mZeroValueStepHasBounds = !(range == 1);
1423 SetNSteps(pFirstParam->
GetStepped() ? range : 0);
1426 void SetBaseValue(
double value)
1431 void SetTrackPadding(
float value)
1436 void SetPeakSize(
float value)
1441 void SetNSteps(
int nSteps)
1446 void SetHighlightedTrack(
int highlightIdx)
1448 mHighlightedTrack = highlightIdx;
1452 void SetZeroValueStepHasBounds(
bool val)
1454 mZeroValueStepHasBounds = val;
1458 bool HasTrackNames()
const 1460 return mTrackNames.GetSize() > 0;
1463 const char* GetTrackName(
int chIdx)
const 1465 WDL_String* pStr = mTrackNames.Get(chIdx);
1466 return pStr ? pStr->Get() :
"";
1469 void SetTrackName(
int chIdx,
const char* newName)
1471 assert(chIdx >= 0 && chIdx < mTrackNames.GetSize());
1473 if(chIdx >= 0 && chIdx < mTrackNames.GetSize())
1475 mTrackNames.Get(chIdx)->Set(newName);
1486 if(mDirection == EDirection::Horizontal)
1495 DrawTrackBackground(g, r, chIdx);
1498 DrawTrackName(g, r, chIdx);
1500 const float trackPos =
static_cast<float>(
GetValue(chIdx));
1502 const bool stepped = GetStepped();
1505 const float bv =
static_cast<float>(mBaseValue);
1509 if(mDirection == EDirection::Vertical)
1512 trackPos < bv ? r.
B - r.
H() * bv : r.
B - r.
H() * trackPos,
1514 trackPos < bv ? r.
B - r.
H() * trackPos : r.
B - r.
H() * bv);
1518 fillRect =
IRECT(trackPos < bv ? r.
L + r.
W() * trackPos : r.
L + r.
W() * bv,
1520 trackPos < bv ? r.
L + r.
W() * bv : r.
L + r.
W() * trackPos,
1526 fillRect = r.
FracRect(mDirection, trackPos);
1528 if(stepped && mZeroValueStepHasBounds && trackPos == 0.f)
1530 if(mDirection == EDirection::Vertical)
1531 fillRect.
T = mStepBounds.Get()[0].T;
1537 int step = GetStepIdxForPos(fillRect.
R, fillRect.
T);
1541 if(mDirection == EDirection::Horizontal)
1543 fillRect.
L = mStepBounds.Get()[step].L;
1544 fillRect.
R = mStepBounds.Get()[step].R;
1548 fillRect.
T = mStepBounds.Get()[step].T;
1549 fillRect.
B = mStepBounds.Get()[step].B;
1553 if(mZeroValueStepHasBounds ||
GetValue(chIdx) > 0.)
1554 DrawTrackHandle(g, fillRect, chIdx, trackPos > mBaseValue);
1558 DrawTrackHandle(g, fillRect, chIdx, trackPos > mBaseValue);
1562 if(mDirection == EDirection::Vertical)
1564 peakRect =
IRECT(fillRect.
L,
1565 trackPos < mBaseValue ? fillRect.
B : fillRect.
T,
1567 trackPos < mBaseValue ? fillRect.
B - mPeakSize: fillRect.
T + mPeakSize);
1571 peakRect =
IRECT(trackPos < mBaseValue ? fillRect.
L + mPeakSize : fillRect.
R - mPeakSize,
1573 trackPos < mBaseValue ? fillRect.
L : fillRect.
R,
1577 DrawPeak(g, peakRect, chIdx, trackPos > mBaseValue);
1580 if(mStyle.drawFrame && mDrawTrackFrame)
1581 g.
DrawRect(GetColor(kFR), r, &mBlend, mStyle.frameThickness);
1584 virtual void DrawTrackBackground(
IGraphics& g,
const IRECT& r,
int chIdx)
1586 g.
FillRect(chIdx == mHighlightedTrack ? this->GetColor(kHL) : COLOR_TRANSPARENT, r);
1589 virtual void DrawTrackName(
IGraphics& g,
const IRECT& r,
int chIdx)
1591 g.
DrawText(mText, GetTrackName(chIdx), r);
1601 g.
FillRect(chIdx == mHighlightedTrack ? GetColor(kX1) : GetColor(kFG), r, &mBlend);
1603 if(chIdx == mMouseOverTrack)
1604 g.
FillRect(GetColor(kHL), r, &mBlend);
1607 virtual void DrawPeak(
IGraphics& g,
const IRECT& r,
int chIdx,
bool aboveBaseValue)
1609 g.
FillRect(GetColor(kFR), r, &mBlend);
1612 int GetStepIdxForPos(
float x,
float y)
const 1614 int nSteps = mStepBounds.GetSize();
1616 for (
auto v = 0; v < nSteps; v++)
1618 if (mStepBounds.Get()[v].ContainsEdge(x, y))
1627 virtual void MakeTrackRects(
const IRECT& bounds)
1629 int nVals =
NVals();
1630 int dir =
static_cast<int>(mDirection);
1631 for (
int ch = 0; ch < nVals; ch++)
1633 mTrackBounds.Get()[ch] = bounds.
SubRect(EDirection(!dir), nVals, ch).
1634 GetPadded(0, -mTrackPadding * (
float) dir, -mTrackPadding * (
float) !dir, -mTrackPadding);
1638 virtual void MakeStepRects(
const IRECT& bounds,
int nSteps)
1642 int dir =
static_cast<int>(mDirection);
1644 nSteps += (int) mZeroValueStepHasBounds;
1646 mStepBounds.Resize(nSteps);
1648 for (
int step = 0; step < nSteps; step++)
1650 mStepBounds.Get()[step] = bounds.
SubRect(EDirection(dir), nSteps, nSteps - 1 - step);
1654 mStepBounds.Resize(0);
1657 bool GetStepped()
const 1659 return mStepBounds.GetSize() > 0;
1663 EDirection mDirection = EDirection::Vertical;
1664 WDL_TypedBuf<IRECT> mTrackBounds;
1665 WDL_TypedBuf<IRECT> mStepBounds;
1666 WDL_PtrList<WDL_String> mTrackNames;
1668 float mTrackPadding = 0.;
1669 float mPeakSize = 1.;
1670 int mHighlightedTrack = -1;
1671 int mMouseOverTrack = -1;
1672 double mBaseValue = 0.;
1673 bool mDrawTrackFrame =
true;
1674 bool mZeroValueStepHasBounds =
true;
1686 void OnEndAnimation()
override;
1693 ISwitchControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, IActionFunction aF =
nullptr,
int numStates = 2);
1700 int GetSelectedIdx()
const {
return int(0.5 +
GetValue() * (
double) (mNumStates - 1)); }
1702 void SetStateDisabled(
int stateIdx,
bool disabled);
1703 void SetAllStatesDisabled(
bool disabled);
1704 bool GetStateDisabled(
int stateIdx)
const;
1707 WDL_TypedBuf<bool> mDisabledState;
1708 bool mMouseDown =
false;
1721 , mShowFileExtensions(showFileExtensions)
1723 mExtension.Set(extension);
1730 void AddPath(
const char* path,
const char* label);
1738 void ScanDirectory(
const char* path,
IPopupMenu& menuToAddTo);
1742 bool mShowEmptySubmenus =
false;
1743 bool mShowFileExtensions =
true;
1744 int mSelectedIndex = -1;
1747 WDL_PtrList<WDL_String> mPaths;
1748 WDL_PtrList<WDL_String> mPathLabels;
1749 WDL_PtrList<WDL_String> mFiles;
1750 WDL_PtrList<IPopupMenu::Item> mItems;
1751 WDL_String mExtension;
1756 #pragma mark - BASIC CONTROLS 1770 , mDrawFrame(drawFrame)
1772 mIgnoreMouse =
true;
1778 , mDrawFrame(drawFrame)
1780 mIgnoreMouse =
true;
1789 g.
DrawRect(COLOR_LIGHT_GRAY, mRECT);
1792 void SetPattern(
const IPattern& pattern)
1798 IPattern GetPattern()
const {
return mPattern; }
1809 ILambdaControl(
const IRECT& bounds, ILambdaDrawFunction drawFunc,
int animationDuration = DEFAULT_ANIMATION_DURATION,
1810 bool loopAnimation =
false,
bool startImmediately =
false,
int paramIdx = kNoParameter,
bool ignoreMouse =
false)
1812 , mDrawFunc(drawFunc)
1813 , mLoopAnimation(loopAnimation)
1814 , mAnimationDuration(animationDuration)
1816 if (startImmediately)
1819 mIgnoreMouse = ignoreMouse;
1820 mDblAsSingleClick =
true;
1826 mDrawFunc(
this, g, mRECT);
1829 virtual void OnEndAnimation()
override 1831 if(mLoopAnimation && mAnimationDuration)
1841 mMouseInfo.x = x; mMouseInfo.y = y; mMouseInfo.ms = mod;
1859 mMouseInfo.ms = mod;
1867 ILambdaDrawFunction mDrawFunc =
nullptr;
1868 bool mLoopAnimation;
1869 int mAnimationDuration;
1884 AttachIControl(
this);
1892 AttachIControl(
this);
1910 , mUseLayer(useLayer)
1930 g.
DrawSVG(mSVG, mRECT, &mBlend);
1933 void SetSVG(
const ISVG& svg)
1948 ITextControl(
const IRECT& bounds,
const char* str =
"",
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR,
bool setBoundsBasedOnStr =
false);
1955 virtual void SetStr(
const char* str);
1959 virtual void SetStrFmt(
int maxlen,
const char* fmt, ...);
1965 const char*
GetStr()
const {
return mStr.Get(); }
1968 void SetBoundsBasedOnStr();
1973 bool mSetBoundsBasedOnStr =
false;
1983 mIgnoreMouse =
false;
2002 IURLControl(
const IRECT& bounds,
const char* str,
const char* url,
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR,
const IColor& MOColor = COLOR_WHITE,
const IColor& CLColor = COLOR_BLUE);
2019 IColor mOriginalColor, mMOColor, mCLColor;
2020 bool mClicked =
false;
2027 ITextToggleControl(
const IRECT& bounds,
int paramIdx = kNoParameter,
const char* offText =
"OFF",
const char* onText =
"ON",
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR);
2029 ITextToggleControl(
const IRECT& bounds, IActionFunction aF =
nullptr,
const char* offText =
"OFF",
const char* onText =
"ON",
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR);
2032 void SetDirty(
bool push,
int valIdx = 0)
override;
2034 WDL_String mOffText;
2048 ICaptionControl(
const IRECT& bounds,
int paramIdx,
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR,
bool showParamLabel =
true);
2053 bool mShowParamLabel;
2054 IColor mTriangleColor = COLOR_BLACK;
2055 IColor mTriangleMouseOverColor = COLOR_WHITE;
2071 IRECT mCentreLabelBounds;
2072 WDL_String mTLHCStr;
2073 WDL_String mWidthStr;
2074 WDL_String mHeightStr;
2075 IText mTLGCText = DEFAULT_TEXT.WithAlign(EAlign::Near);
2076 IText mWidthText = DEFAULT_TEXT;
2077 IText mHeightText = DEFAULT_TEXT.WithAngle(270.f);
2078 static constexpr
float mInset = 10.f;
2081 END_IGRAPHICS_NAMESPACE
Encapsulate an xy point in one struct.
IRECT DrawPressableRectangle(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, bool disabled, bool rtl=true, bool rtr=true, bool rbl=true, bool rbr=true)
Draw a rectangle-shaped vector button.
void PathRect(const IRECT &bounds)
Add a rectangle to the current path.
Contains a set of 9 colors used to theme IVControls.
bool Contains(const IRECT &rhs) const
Returns true if this IRECT completely contains rhs.
void SetMouseOverWhenDisabled(bool allow)
Specify whether the control should respond to mouse overs when disabled.
void SetWantsMultiTouch(bool enable=true)
Specify whether this control supports multiple touches.
virtual void OnResize() override
Called when IControl is constructed or resized using SetRect().
virtual void OnAttached()
Called after the control has been attached, and its delegate and graphics member variable set...
IRECT SubRect(EDirection layoutDir, int numSlices, int sliceIdx) const
Get a new rectangle which is a "slice" of this rectangle.
void StartLayer(IControl *pOwner, const IRECT &r, bool cacheable=false)
Create an IGraphics layer.
The lowest level base class of an IGraphics control.
void SetPTParameterHighlight(bool isHighlighted, int color)
Used internally by the AAX wrapper view interface to set the control parmeter highlight.
virtual void SetText(const IText &txt)
Set the Text object typically used to determine font/layout/size etc of the main text in a control...
Used to manage a rectangular area, independent of draw class/platform.
virtual void OnResize()
Called when IControl is constructed or resized using SetRect().
virtual void SetValueFromUserInput(double value, int valIdx=0)
Set the control's value after user input.
void SetTextEntryLength(int len)
Set the max number of characters that are allowed in text entry.
IGEditorDelegate * GetDelegate()
Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes...
bool GetWantsMidi() const
void SetColor(EVColor colorIdx, const IColor &color)
Set one of the IVColors that style the IVControl.
virtual void OnMouseDown(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse down event on this control.
int LinkedToParam(int paramIdx) const
Check if the control is linked to a particular parameter.
virtual void DrawValue(IGraphics &g, bool mouseOver)
Draw the IVControl value text.
A basic control to draw a bitmap, or one frame of a stacked bitmap depending on the current value...
virtual void DrawRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw a rectangle to the graphics context.
A basic control to display some text.
Used to manage composite/blend operations, independent of draw class/platform.
virtual void DrawBackground(IGraphics &g, const IRECT &rect)
Draw the IVControl background (usually transparent)
int GetTag() const
Get the control's tag.
bool GetMouseEventsWhenDisabled() const
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
virtual ECursor SetMouseCursor(ECursor cursorType=ECursor::ARROW)
Sets the mouse cursor to one of ECursor (implementations should return the result of the base impleme...
Encapsulates a MIDI message and provides helper functions.
virtual bool OnKeyUp(float x, float y, const IKeyPress &key)
Implement this method to respond to a key up event on this control.
void CreateTextEntry(IControl &control, const IText &text, const IRECT &bounds, const char *str="", int valIdx=0)
Create a text entry box.
void SetColors(const IVColorSpec &spec)
Set the colors of this IVControl.
const IRECT & GetTargetRECT() const
Get the rectangular mouse tracking target area, within the graphics context for this control...
void DisablePrompt(bool disable)
Disable/enable default prompt for user input.
Used to manage mouse modifiers i.e.
A base class for switch controls.
A basic control to display some editable text.
bool mMouseIsOver
if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control.
int GetTextEntryLength() const
Get the max number of characters that are allowed in text entry.
EGestureType GetLastGesture() const
virtual void Hide(bool hide)
Shows or hides the IControl.
void SetMouseEventsWhenDisabled(bool allow)
Specify whether the control should respond to other mouse events when disabled.
virtual void FillCircle(const IColor &color, float cx, float cy, float r, const IBlend *pBlend=0)
Fill a circle with a color.
void SetPromptShowsParamLabel(bool enable)
Set if the control should show parameter labels/units e.g.
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...
A control to use as a placeholder during development.
bool GetMouseDblAsSingleClick() const
Get double click as single click By default, mouse double click has its own handler.
IPlug's parameter class.
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...
IRECT FracRect(EDirection layoutDir, float frac, bool fromTopOrRight=false) const
Get a new rectangle which is a fraction of this rectangle.
virtual void SetValueToDefault(int valIdx=kNoValIdx)
Set one or all of the control's values to the default value of the associated parameter.
float GetRoundedCornerRadius(const IRECT &bounds) const
Get the radius of rounded corners for a rectangle, based on the style roundness factor.
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
IControl * SetActionFunction(IActionFunction actionFunc)
Set an Action Function for this control.
void SetMOColor(const IColor &color)
Sets the color of the text on Mouse Over.
virtual void OnContextSelection(int itemSelected)
Implement this to respond to a menu selection from CreateContextMenu();.
void SetTooltip(const char *str)
Set a tooltip for the control.
virtual void DrawRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0, float thickness=1.f)
Draw a rounded rectangle to the graphics context.
Used to manage color data, independent of draw class/platform.
IRECT GetTranslated(float x, float y) const
Get a translated copy of this rectangle.
const char * GetStr() const
Used to describe a particular gesture.
void SetParams(const std::vector< int > ¶mIds)
Update the parameters based on a parameter group name.
A base interface to be combined with IControl for bitmap-based controls "IBControls", managing an IBitmap.
bool GetIgnoreMouse() const
void DefaultClickActionFunc(IControl *pCaller)
A click action function that triggers the default animation function for DEFAULT_ANIMATION_DURATION.
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.
virtual void OnMouseDrag(float x, float y, float dX, float dY, const IMouseMod &mod)
Implement this method to respond to a mouse drag event on this control.
void OnRescale() override
If you override this make sure you call the parent method in order to rescale mBitmap.
IRECT ReduceFromBottom(float amount)
Reduce in height from the bottom edge by 'amount' and return the removed region.
void DrawSplash(IGraphics &g, const IRECT &clipRegion=IRECT())
Draw a splash effect when a widget handle is clicked (via SplashClickAnimationFunc) ...
IControl * SetAnimationEndActionFunction(IActionFunction actionFunc)
Set an Action Function to be called at the end of an animation.
IRECT ReduceFromRight(float amount)
Reduce in width from the right edge by 'amount' and return the removed region.
User-facing SVG abstraction that you use to manage SVG data ISVG doesn't actually own the image data...
void AttachIControl(IControl *pControl, const char *label)
Call in the constructor of your IVControl to link the IVectorBase and IControl.
double GetRange() const
Returns the parameter's range.
virtual void Draw(IGraphics &g)=0
Draw the control to the graphics context.
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...
virtual int GetValIdxForPos(float x, float y) const
Check to see which of the control's values relates to this x and y coordinate.
void DrawPressableEllipse(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, bool disabled)
Draw an ellipse-shaped vector button.
float R
Right side of the rectangle (X + W)
virtual bool IsHit(float x, float y) const
Hit test the control.
virtual void OnMouseUp(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse up event on this control.
virtual void ClearStr()
Clear the text .
IRECT DrawPressableTriangle(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, float angle, bool disabled)
Draw a triangle-shaped vector button.
A base class for mult-strip/track controls, such as multi-sliders, meters Track refers to the channel...
IRECT MakeRects(const IRECT &parent, bool hasHandle=false)
Calculate the rectangles for the various areas, depending on the style.
void SetRECT(const IRECT &bounds)
Set the rectangular draw area for this control, within the graphics context.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
double GetAnimationProgress() const
Get the progress in a control's animation, in the range 0-1.
The lowest level base class of an IGraphics context.
A control to display the textual representation of a parameter.
An editor delegate base class for a SOMETHING that uses IGraphics for it's UI.
virtual void OnTouchCancelled(float x, float y, const IMouseMod &mod)
Implement this method to respond to a touch cancel event on this control.
int GetControlTag(const IControl *pControl) const
Get the tag given to a control.
const IRECT & GetRECT() const
Get the rectangular draw area for this control, within the graphics context.
void ForValIdx(int valIdx, T func, Args...args)
A helper template function to call a method for an individual value, or for all values.
bool GetWantsMultiTouch() const
void OnTextEntryCompletion(const char *str, int valIdx) override
Implement this method to handle text input after IGraphics::CreateTextEntry/IControl::PromptUserInput...
const char * GetTooltip() const
void SetAnimation(IAnimationFunction func, int duration)
Set the animation function and starts it.
IBitmapBase(const IBitmap &bitmap)
IBitmapBase Constructor.
IText is used to manage font and text/text entry style for a piece of text on the UI...
IRECT GetScaledAboutCentre(float scale) const
Get a copy of this IRECT where the width and height are multiplied by scale without changing the cent...
void Offset(float l, float t, float r, float b)
Offset each field of the rectangle.
bool CheckLayer(const ILayerPtr &layer)
Test to see if a layer needs drawing, for instance if the control's bounds were changed.
const IColor & GetColor(EVColor color) const
Get value of a specific EVColor in the IVControl.
virtual void OnInit()
Called just prior to when the control is attached, after its delegate and graphics member variable se...
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
virtual void DrawSVG(const ISVG &svg, const IRECT &bounds, const IBlend *pBlend=0)
Draw an SVG image to the graphics context.
virtual void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx)
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControl::Promp...
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.
virtual void DrawTrackHandle(IGraphics &g, const IRECT &r, int chIdx, bool aboveBaseValue)
Draw the main body of the track.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
IControl(const IRECT &bounds, int paramIdx=kNoParameter, IActionFunction actionFunc=nullptr)
Constructor.
IRECT GetReducedFromBottom(float amount) const
Get a subrect of this IRECT reduced in height from the bottom edge by 'amount'.
WDL_String mGroup
Controls can be grouped for hiding and showing panels.
Used to group mouse coordinates with mouse modifier information.
const char * GetGroup() const
Get the group that the control belongs to, if any.
virtual void PathFill(const IPattern &pattern, const IFillOptions &options=IFillOptions(), const IBlend *pBlend=0)=0
Fill the current current path.
IBitmap GetScaledBitmap(IBitmap &inBitmap)
Get a version of the input bitmap from the cache that corresponds to the current screen scale For exa...
IDirBrowseControlBase(const IRECT &bounds, const char *extension, bool showFileExtensions=true)
Creates an IDirBrowseControlBase.
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
bool GetMouseIsOver() const
This can be used in IControl::Draw() to check if the mouse is over the control, without implementing ...
virtual void OnMouseWheel(float x, float y, const IMouseMod &mod, float d)
Implement this method to respond to a mouse wheel event on this control.
void PathClipRegion(const IRECT r=IRECT())
Clip the current path to a particular region.
The lowest level base class of an IGraphics context.
IVectorBase(const IVStyle &style, bool labelInWidget=false, bool valueInWidget=false)
IVectorBase Constructor.
void SetAnimation(IAnimationFunction func)
Set the animation function.
virtual void DrawPressableShape(IGraphics &g, EVShape shape, const IRECT &bounds, bool pressed, bool mouseOver, bool disabled)
Call one of the DrawPressableShape methods.
virtual void OnMouseOver(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouseover event on this control.
virtual void DrawLabel(IGraphics &g)
Draw the IVControl label text.
const char * GetGroup() const
Returns the parameter's group.
IBlend GetBlend() const
Get the Blend for this control.
void SetBlend(const IBlend &blend)
Set the Blend for this control.
virtual void OnMidi(const IMidiMsg &msg)
Implement to receive MIDI messages sent to the control if mWantsMidi == true, see IEditorDelegate:Sen...
IVStyle GetStyle() const
Get the style of this IVControl.
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
virtual void FillRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0)
Fill a rounded rectangle with a color.
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 FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
virtual void OnGUIIdle()
This is an idle timer tick call on the GUI thread, only active if USE_IDLE_CALLS is defined...
BEGIN_IPLUG_NAMESPACE T Clip(T x, T lo, T hi)
Clips the value x between lo and hi.
virtual void FillEllipse(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill an ellipse within a rectangular region of the graphics context.
virtual void DrawEllipse(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw an ellipse within a rectangular region of the graphics context.
A basic control to fill a rectangle with a color or gradient.
A control that can be specialised with a lambda function, for quick experiments without making a cust...
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 Draw(IGraphics &g) override
Draw the control to the graphics context.
void SetTargetAndDrawRECTs(const IRECT &bounds)
Set BOTH the draw rect and the target area, within the graphics context for this control.
virtual void OnTextEntryCompletion(const char *str, int valIdx)
Implement this method to handle text input after IGraphics::CreateTextEntry/IControl::PromptUserInput...
IAnimationFunction GetAnimationFunction()
Get the control's animation function, if it exists.
void DrawBitmap(IGraphics &g)
Draw a frame of a multi-frame bitmap based on the IControl value.
A base class for knob/dial controls, to handle mouse action and Sender.
bool GetPromptShowsParamLabel() const
virtual void DrawTriangle(const IColor &color, float x1, float y1, float x2, float y2, float x3, float y3, const IBlend *pBlend=0, float thickness=1.f)
Draw a triangle to the graphics context.
void DrawLayer(const ILayerPtr &layer, const IBlend *pBlend=nullptr)
Draw a layer to the main IGraphics context.
void Pad(float padding)
Pad this IRECT N.B.
virtual void DrawPTHighlight(IGraphics &g)
Implement this to customise how a colored highlight is drawn on the control in ProTools (AAX format o...
An abstract IControl base class that you can inherit from in order to make a control that pops up a m...
bool GetMouseOverWhenDisabled() const
void Draw(IGraphics &g) override
Draw the control to the graphics context.
virtual void DrawBitmap(const IBitmap &bitmap, const IRECT &bounds, int srcX, int srcY, const IBlend *pBlend=0)=0
Draw a bitmap (raster) image to the graphics context.
T * As()
Helper function to dynamic cast an IControl to a subclass.
void DrawHorizontalLine(const IColor &color, const IRECT &bounds, float y, const IBlend *pBlend=0, float thickness=1.f)
Draw a horizontal line, within a rectangular region of the graphics context.
void Set(int a=255, int r=0, int g=0, int b=0)
Set the color parts.
A base class for slider/fader controls, to handle mouse action and Sender.
virtual bool OnGesture(const IGestureInfo &info)
virtual void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData)
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate() ...
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
double GetValue(int valIdx=0) const
Get the control's value.
IControl * AttachGestureRecognizer(EGestureType type, IGestureFunc func)
Add a IGestureFunc that should be triggered in response to a certain type of gesture.
void SetTargetRECT(const IRECT &bounds)
Set the rectangular mouse tracking target area, within the graphics context for this control...
A base class for controls that can do do multitouch.
float L
Left side of the rectangle (X)
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
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...
IActionFunction GetActionFunction()
Get the control's action function, if it exists.
virtual void SetStyle(const IVStyle &style)
Set the Style of this IVControl.
ILayerPtr EndLayer()
End an IGraphics layer.
virtual void SetPosition(float x, float y)
Set the position of the control, preserving the width and height.
void SetGroup(const char *groupName)
Assign the control to a control group.
virtual void DrawWidget(IGraphics &g)
Draw the IVControl main widget (override)
IBitmapControl(float x, float y, const IBitmap &bitmap, int paramIdx=kNoParameter, EBlend blend=EBlend::Default)
Creates a bitmap control.
const IGraphics * GetUI() const
void DrawVerticalLine(const IColor &color, const IRECT &bounds, float x, const IBlend *pBlend=0, float thickness=1.f)
Draw a vertical line, within a rectangular region of the graphics context.
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
virtual void OnRescale()
Implement to do something when graphics is scaled globally (e.g.
virtual void OnMouseDblClick(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse double click event on this control.
void OnTextEntryCompletion(const char *str, int valIdx) override
Implement this method to handle text input after IGraphics::CreateTextEntry/IControl::PromptUserInput...
void OnMouseDblClick(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse double click event on this control.
void SetParamsByGroup(const char *paramGroup)
Update the parameters based on a parameter group name.
virtual IRECT GetKnobDragBounds()
Get the area for which mouse deltas will be used to calculate the amount dragging changes the control...
int GetValIdxForPos(float x, float y) const override
Check to see which of the control's values relates to this x and y coordinate.
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.
IRECT GetPadded(float padding) const
Get a copy of this IRECT with each value padded by padding N.B.
void SetWantsMidi(bool enable=true)
Specify whether this control wants to know about MIDI messages sent to the UI.
void SetDelegate(IGEditorDelegate &dlg)
Used internally to set the mDelegate (and mGraphics) variables.
virtual bool OnKeyDown(float x, float y, const IKeyPress &key)
Implement this method to respond to a key down event on this control.
A control to show a clickable URL, that changes color after clicking.
virtual void CreateContextMenu(IPopupMenu &contextMenu)
Called by default when the user right clicks a control.
virtual void SetValue(double value, int valIdx=0)
Set one of the control's values.
bool GetWantsGestures() const
void SetCLColor(const IColor &color)
Sets the color of the text when the URL has been clicked.
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're on your own!
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
Milliseconds GetAnimationDuration() const
Get the duration of animations applied to the control.
IRECT GetAdjustedHandleBounds(IRECT handleBounds) const
Get the adjusted bounds for the widget handle, based on the style settings.
Used to store pattern information for gradients.
IRECT GetFromBottom(float amount) const
Get a subrect of this IRECT bounded in Y by 'amount' and the bottom edge.
A basic control to draw an SVG image to the screen.
void StartAnimation(int duration)
void Draw(IGraphics &g) override
Draw the control to the graphics context.
IGraphics * GetUI()
Get a pointer to the IGraphics context.
double GetStep() const
Returns the parameter's step size.
IRECT GetFromTop(float amount) const
Get a subrect of this IRECT bounded in Y by the top edge and 'amount'.
virtual void OnDrop(const char *str)
Implement to do something when something was drag 'n dropped onto this control.
Used for key press info, such as ASCII representation, virtual key (mapped to win32 codes) and modifi...
virtual void SetSize(float w, float h)
Set the size of the control, preserving the current position.
void AttachIControl(IControl *pControl)
Call in the constructor of your IBControl to link the IBitmapBase and IControl.
virtual ~IControl()
Destructor.
A control to toggle between two text strings on click.
float T
Top of the rectangle (Y)
virtual void DrawBackground(IGraphics &g, const IRECT &r) override
Draw the IVControl background (usually transparent)
IParam * GetParam(int paramIdx)
Get a pointer to one of the delegate'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.
A struct encapsulating a set of properties used to configure IVControls.
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
virtual void SetDisabled(bool disable)
Sets disabled mode for the control, the default implementation modifies the mBlend member...
const IText & GetText() const
Get the Text object for the control.
IRECT GetReducedFromTop(float amount) const
Get a subrect of this IRECT reduced in height from the top edge by 'amount'.
float B
Bottom of the rectangle (Y + H)
virtual void OnMouseOut()
Implement this method to respond to a mouseout event on this control.
IRECT GetMidVPadded(float padding) const
Get a copy of this IRECT where its height = 2 * padding but the center point on the Y-axis has not ch...