21#include <unordered_map>
23#if defined VST3_API || defined VST3C_API
26#include "pluginterfaces/vst/ivstcontextmenu.h"
27#include "base/source/fobject.h"
38BEGIN_IGRAPHICS_NAMESPACE
45#if defined VST3_API || defined VST3C_API
46:
public Steinberg::Vst::IContextMenuTarget
47,
public Steinberg::FObject
58 IControl(
const IRECT& bounds,
int paramIdx = kNoParameter, IActionFunction actionFunc =
nullptr);
67 IControl(
const IRECT& bounds,
const std::initializer_list<int>& params, IActionFunction actionFunc =
nullptr);
78 void operator=(
const IControl&) =
delete;
224 inline const char*
GetTooltip()
const {
return mTooltip.Get(); }
236 virtual void SetParamIdx(
int paramIdx,
int valIdx = 0);
244 int NVals()
const {
return (
int) mVals.size(); }
250 virtual int GetValIdxForPos(
float x,
float y)
const {
return mVals.size() == 1 ? 0 : kNoValIdx; }
276 virtual void SetValue(
double value,
int valIdx = 0);
281 double GetValue(
int valIdx = 0)
const;
342 virtual void SetSize(
float w,
float h);
357 virtual void Hide(
bool hide);
400 virtual bool IsHit(
float x,
float y)
const {
return mTargetRECT.
Contains(x, y); }
406 virtual void SetDirty(
bool triggerAction =
true,
int valIdx = kNoValIdx);
409 virtual void SetClean() { mDirty =
false; }
446 virtual bool GetWantsGestures()
const {
return mGestureFuncs.size() > 0 && !mAnimationFunc; }
460 mGraphics = dlg.
GetUI();
487 virtual void SnapToMouse(
float x,
float y, EDirection direction,
const IRECT& bounds,
int valIdx = -1,
double minClip = 0.,
double maxClip = 1.);
490 virtual void OnEndAnimation();
518 T*
As() {
return dynamic_cast<T*
>(
this); }
520#if defined VST3_API || defined VST3C_API
521 Steinberg::tresult PLUGIN_API executeMenuItem (Steinberg::int32 tag)
override {
OnContextSelection(tag);
return Steinberg::kResultOk; }
524#pragma mark - IControl Member variables
531 template<
typename T,
typename... Args>
534 if (valIdx > kNoValIdx)
535 func(valIdx, args...);
538 const int nVals =
NVals();
539 for (
int v = 0; v < nVals; v++)
552 int mTextEntryLength = DEFAULT_TEXT_ENTRY_LEN;
555 bool mDisabled =
false;
556 bool mDisablePrompt =
true;
557 bool mDblAsSingleClick =
false;
558 bool mMouseOverWhenDisabled =
false;
559 bool mMouseEventsWhenDisabled =
false;
560 bool mIgnoreMouse =
false;
561 bool mWantsMidi =
false;
562 bool mWantsMultiTouch =
false;
563 bool mPromptShowsParamLabel =
false;
568 IColor mPTHighlightColor = COLOR_RED;
569 bool mPTisHighlighted =
false;
571 void SetNVals(
int nVals)
577#if defined VST3_API || defined VST3C_API
580 DEF_INTERFACE (IContextMenuTarget)
581 END_DEFINE_INTERFACES (FObject)
582 REFCOUNT_METHODS(FObject)
589 IActionFunction mActionFunc =
nullptr;
590 IActionFunction mAnimationEndActionFunc =
nullptr;
591 IAnimationFunction mAnimationFunc =
nullptr;
592 TimePoint mAnimationStartTime;
593 Milliseconds mAnimationDuration;
594 std::vector<ParamTuple> mVals { {kNoParameter, 0.} };
595 std::unordered_map<EGestureType, IGestureFunc> mGestureFuncs;
596 EGestureType mLastGesture = EGestureType::Unknown;
599#pragma mark - Base Controls
616 IContainerBase(
const IRECT& bounds,
int paramIdx = kNoParameter, IActionFunction actionFunc =
nullptr)
617 :
IControl(bounds, paramIdx, actionFunc)
620 IContainerBase(
const IRECT& bounds,
const std::initializer_list<int>& params, IActionFunction actionFunc =
nullptr)
621 :
IControl(bounds, params, actionFunc)
630 , mAttachFunc(attachFunc)
631 , mResizeFunc(resizeFunc)
636 void SetAttachFunc(AttachFunc attachFunc)
638 mAttachFunc = attachFunc;
641 void SetResizeFunc(ResizeFunc resizeFunc)
643 mResizeFunc = resizeFunc;
653 mChildren.Empty(
false);
659 mAttachFunc(
this, mRECT);
666 if (mResizeFunc && mChildren.GetSize())
667 mResizeFunc(
this, mRECT);
672 ForAllChildrenFunc([disable](
int childIdx,
IControl* pChild) {
681 ForAllChildrenFunc([hide](
int childIdx,
IControl* pChild) {
688 IControl* AddChildControl(
IControl* pControl,
int ctrlTag = kNoTag,
const char* group =
"")
690 pControl->SetParent(
this);
691 return mChildren.Add(
GetUI()->AttachControl(pControl, ctrlTag, group));
694 void RemoveChildControl(
IControl* pControl)
696 pControl->SetParent(
nullptr);
697 mChildren.DeletePtr(pControl,
false);
703 return mChildren.Get(idx);
706 int NChildren()
const {
return mChildren.GetSize(); }
708 void ForAllChildrenFunc(std::function<
void(
int childIdx,
IControl* pControl)> func)
710 for (
int i=0; i<mChildren.GetSize(); i++)
712 func(i, mChildren.Get(i));
717 AttachFunc mAttachFunc =
nullptr;
718 ResizeFunc mResizeFunc =
nullptr;
719 WDL_PtrList<IControl> mChildren;
747 i = 1 + int(0.5 + mControl->
GetValue() *
static_cast<double>(mBitmap.
N() - 1));
748 i =
Clip(i, 1, mBitmap.
N());
769 : mLabelInWidget(labelInWidget)
770 , mValueInWidget(valueInWidget)
783 mLabelStr.Set(label);
794 mStyle.colorSpec.mColors[
static_cast<int>(colorIdx)] = color;
802 mStyle.colorSpec = spec;
808 return mStyle.colorSpec.
GetColor(color);
811 void SetLabelStr(
const char* label) { mLabelStr.Set(label); mControl->
SetDirty(
false);
OnStyleChanged(); }
812 const char* GetLabelStr()
const {
return mLabelStr.Get(); }
813 void SetValueStr(
const char* value) { mValueStr.Set(value); mControl->
SetDirty(
false);
OnStyleChanged(); }
818 void SetRoundness(
float roundness) { mStyle.roundness =
Clip(roundness, 0.f, 1.f); mControl->
SetDirty(
false);
OnStyleChanged(); }
820 void SetDrawShadows(
bool draw) { mStyle.drawShadows = draw; mControl->
SetDirty(
false);
OnStyleChanged(); }
822 void SetShadowOffset(
float offset) { mStyle.shadowOffset = offset; mControl->
SetDirty(
false);
OnStyleChanged(); }
823 void SetFrameThickness(
float thickness) { mStyle.frameThickness = thickness; mControl->
SetDirty(
false);
OnStyleChanged(); }
824 void SetSplashRadius(
float radius) { mSplashRadius = radius * mMaxSplashRadius;
OnStyleChanged(); }
825 void SetSplashPoint(
float x,
float y) { mSplashPoint.x = x; mSplashPoint.y = y;
OnStyleChanged(); }
846 if (mStyle.drawFrame)
847 handleBounds.
Pad(- 0.5f * mStyle.frameThickness);
849 if (mStyle.drawShadows)
850 handleBounds.
Offset(mStyle.shadowOffset, 0, -mStyle.shadowOffset, -mStyle.shadowOffset);
860 if (bounds.
W() < bounds.
H())
861 return mStyle.roundness * (bounds.
W() / 2.f);
863 return mStyle.roundness * (bounds.
H() / 2.f);
866 IRECT GetWidgetBounds()
const {
return mWidgetBounds; }
867 IRECT GetLabelBounds()
const {
return mLabelBounds; }
868 IRECT GetValueBounds()
const {
return mValueBounds; }
896 if (mLabelBounds.
H() && mStyle.showLabel)
899 g.
DrawText(mStyle.labelText, mLabelStr.Get(), mLabelBounds, &blend);
907 g.
FillRect(COLOR_TRANSLUCENT, mValueBounds);
909 if (mStyle.showValue)
912 g.
DrawText(mStyle.valueText, mValueStr.Get(), mValueBounds, &blend);
927 case EVShape::Ellipse:
930 case EVShape::Rectangle:
933 case EVShape::Triangle:
936 case EVShape::EndsRounded:
939 case EVShape::AllRounded:
955 IRECT handleBounds = bounds;
959 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
961 if(!pressed && !disabled && mStyle.drawShadows)
1014 if (mStyle.drawFrame)
1026 bool rtl =
true,
bool rtr =
true,
bool rbl =
true,
bool rbr =
true)
1029 IRECT centreBounds = handleBounds.
GetPadded(-mStyle.shadowOffset);
1030 IRECT shadowBounds = handleBounds.
GetTranslated(mStyle.shadowOffset, mStyle.shadowOffset);
1032 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1035 const float tlr = rtl ? cR : 0.f;
1036 const float trr = rtr ? cR : 0.f;
1037 const float blr = rbl ? cR : 0.f;
1038 const float brr = rbr ? cR : 0.f;
1065 if (mStyle.drawShadows)
1097 if (mStyle.drawFrame)
1100 return handleBounds;
1110 float x1, x2, x3, y1, y2, y3;
1112 float theta = DegToRad(angle);
1117 float xT = handleBounds.L + handleBounds.
W() * 0.5f;
1118 float yT = handleBounds.T + handleBounds.
H() * 0.5f;
1122 float c = cosf(theta);
1123 float s = sinf(theta);
1124 x1 = centered.L * c - centered.B * s + xT;
1125 y1 = centered.L * s + centered.B * c + yT;
1126 x2 = centered.
MW() * c - centered.T * s + xT;
1127 y2 = centered.
MW() * s + centered.T * c + yT;
1128 x3 = centered.R * c - centered.B * s + xT;
1129 y3 = centered.R * s + centered.B * c + yT;
1132 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1139 if (mStyle.drawShadows)
1141 x2 + mStyle.shadowOffset, y2 + mStyle.shadowOffset,
1142 x3 + mStyle.shadowOffset, y3 + mStyle.shadowOffset, &blend);
1153 if (mStyle.drawFrame)
1156 return handleBounds;
1165 IRECT clickableArea = parent;
1169 if(mStyle.showLabel && CStringHasContents(mLabelStr.Get()))
1172 mControl->
GetUI()->
MeasureText(mStyle.labelText, mLabelStr.Get(), textRect);
1174 switch (mStyle.labelOrientation)
1176 case EOrientation::North:
1179 case EOrientation::East:
1182 case EOrientation::South:
1185 case EOrientation::West:
1191 mLabelBounds =
IRECT();
1193 if (!mLabelBounds.
Empty())
1195 switch (mStyle.labelOrientation)
1197 case EOrientation::North:
1200 case EOrientation::East:
1203 case EOrientation::South:
1206 case EOrientation::West:
1213 if (mStyle.showValue && !mValueInWidget)
1217 if(CStringHasContents(mValueStr.Get()))
1218 mControl->
GetUI()->
MeasureText(mStyle.valueText, mValueStr.Get(), textRect);
1220 const float valueDisplayWidth = textRect.
W() * mValueDisplayFrac;
1222 switch (mStyle.valueText.mVAlign)
1224 case EVAlign::Middle:
1228 case EVAlign::Bottom:
1251 mLabelBounds = mWidgetBounds;
1254 mValueBounds = mWidgetBounds;
1256 return clickableArea;
1262 bool mLabelInWidget =
false;
1263 bool mValueInWidget =
false;
1264 float mSplashRadius = 0.f;
1265 IVec2 mSplashPoint = {0.f, 0.f};
1266 float mMaxSplashRadius = 50.f;
1267 float mTrackSize = 2.f;
1268 float mValueDisplayFrac = 0.66f;
1269 IRECT mWidgetBounds;
1272 WDL_String mLabelStr;
1273 WDL_String mValueStr;
1274 EVShape mShape = EVShape::Rectangle;
1289 TimePoint startTime;
1291 TrackedTouch(
int index,
float x,
float y,
float radius, TimePoint time)
1292 : index(index), x(x), y(y), sx(x), sy(y), radius(radius), startTime(time)
1301 virtual void AddTouch(ITouchID touchID,
float x,
float y,
float radius)
1304 for (
int i = 0; i < MAX_TOUCHES; i++)
1306 if (mTouchStatus[i] ==
false)
1309 mTouchStatus[i] =
true;
1314 if(NTrackedTouches() < MAX_TOUCHES)
1315 mTrackedTouches.insert(std::make_pair(touchID, TrackedTouch(touchIndex, x, y, radius, std::chrono::high_resolution_clock::now())));
1318 virtual void ReleaseTouch(ITouchID touchID)
1320 mTouchStatus[GetTouchWithIdentifier(touchID)->index] =
false;
1321 mTrackedTouches.erase(touchID);
1324 virtual void UpdateTouch(ITouchID touchID,
float x,
float y,
float radius)
1326 mTrackedTouches[touchID].x = x;
1327 mTrackedTouches[touchID].y = y;
1328 mTrackedTouches[touchID].radius = radius;
1331 void ClearAllTouches()
1333 mTrackedTouches.clear();
1334 memset(mTouchStatus, 0, MAX_TOUCHES *
sizeof(
bool));
1337 int NTrackedTouches()
const
1339 return static_cast<int>(mTrackedTouches.size());
1342 TrackedTouch* GetTouch(
int index)
1344 auto itr = std::find_if(mTrackedTouches.begin(), mTrackedTouches.end(),
1345 [index](
auto element) {
1346 return(element.second.index == index);
1349 if(itr != mTrackedTouches.end())
1350 return &itr->second;
1355 TrackedTouch* GetTouchWithIdentifier(ITouchID touchID)
1357 auto itr = mTrackedTouches.find(touchID);
1359 if(itr != mTrackedTouches.end())
1360 return &itr->second;
1366 static constexpr int MAX_TOUCHES = 10;
1367 std::unordered_map<ITouchID, TrackedTouch> mTrackedTouches;
1368 bool mTouchStatus[MAX_TOUCHES] = { 0 };
1375 IKnobControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, EDirection direction = EDirection::Vertical,
double gearing = DEFAULT_GEARING)
1377 , mDirection(direction)
1386 void SetGearing(
double gearing) { mGearing = gearing; }
1387 bool IsFineControl(
const IMouseMod& mod,
bool wheel)
const;
1394 bool mHideCursorOnDrag =
true;
1395 EDirection mDirection;
1397 bool mMouseDown =
false;
1398 double mMouseDragValue = 0.0;
1405 ISliderControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical,
double gearing = DEFAULT_GEARING,
float handleSize = 0.f);
1406 ISliderControlBase(
const IRECT& bounds, IActionFunction aF =
nullptr, EDirection dir = EDirection::Vertical,
double gearing = DEFAULT_GEARING,
float handleSize = 0.f);
1414 void SetGearing(
double gearing) { mGearing = gearing; }
1415 bool IsFineControl(
const IMouseMod& mod,
bool wheel)
const;
1418 bool mHideCursorOnDrag =
true;
1419 EDirection mDirection;
1423 bool mMouseDown =
false;
1424 double mMouseDragValue;
1433 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 = {})
1439 SetNVals(maxNTracks);
1440 mTrackBounds.Resize(maxNTracks);
1442 for (
int i=0; i<maxNTracks; i++)
1447 if(trackNames.size())
1449 assert(trackNames.size() == maxNTracks);
1451 for (
auto& trackName : trackNames)
1453 mTrackNames.Add(
new WDL_String(trackName));
1460 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 = {})
1466 SetNVals(maxNTracks);
1467 mTrackBounds.Resize(maxNTracks);
1469 for (
int i = 0; i < maxNTracks; i++)
1474 if(trackNames.size())
1476 assert(trackNames.size() == maxNTracks);
1478 for (
auto& trackName : trackNames)
1480 mTrackNames.Add(
new WDL_String(trackName));
1487 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 = {})
1493 int maxNTracks =
static_cast<int>(params.size());
1494 SetNVals(maxNTracks);
1495 mTrackBounds.Resize(maxNTracks);
1498 for (
auto param : params)
1503 if(trackNames.size())
1505 assert(trackNames.size() == params.size());
1507 for (
auto& trackName : trackNames)
1509 mTrackNames.Add(
new WDL_String(trackName));
1518 mTrackNames.Empty(
true);
1529 mMouseOverTrack = -1;
1536 MakeTrackRects(mWidgetBounds);
1537 MakeStepRects(mWidgetBounds, mNSteps);
1543 int nVals =
NVals();
1545 for (
auto v = 0; v < nVals; v++)
1547 if (mTrackBounds.Get()[v].Contains(x, y))
1558 const int nVals =
NVals();
1560 for (
int ch = 0; ch < nVals; ch++)
1562 DrawTrack(g, mTrackBounds.Get()[ch], ch);
1571 std::vector<int> paramIdsForGroup;
1573 for (
auto p = 0; p < nParams; p++)
1577 if(strcmp(pParam->
GetGroup(), paramGroup) == 0)
1579 paramIdsForGroup.push_back(p);
1590 int nParams =
static_cast<int>(paramIds.size());
1593 mTrackBounds.Resize(nParams);
1596 for (
auto param : paramIds)
1602 const int range =
static_cast<int>(pFirstParam->
GetRange() / pFirstParam->
GetStep());
1603 mZeroValueStepHasBounds = !(range == 1);
1604 SetNSteps(pFirstParam->
GetStepped() ? range : 0);
1607 void SetNTracks(
int nTracks)
1610 mTrackBounds.Resize(nTracks);
1614 void SetBaseValue(
double value)
1619 void SetTrackPadding(
float value)
1624 void SetPeakSize(
float value)
1629 void SetNSteps(
int nSteps)
1634 void SetHighlightedTrack(
int highlightIdx)
1636 mHighlightedTrack = highlightIdx;
1640 void SetZeroValueStepHasBounds(
bool val)
1642 mZeroValueStepHasBounds = val;
1646 bool HasTrackNames()
const
1648 return mTrackNames.GetSize() > 0;
1651 const char* GetTrackName(
int chIdx)
const
1653 WDL_String* pStr = mTrackNames.Get(chIdx);
1654 return pStr ? pStr->Get() :
"";
1657 void SetTrackName(
int chIdx,
const char* newName)
1659 assert(chIdx >= 0 && chIdx < mTrackNames.GetSize());
1661 if(chIdx >= 0 && chIdx < mTrackNames.GetSize())
1663 mTrackNames.Get(chIdx)->Set(newName);
1674 if(mDirection == EDirection::Horizontal)
1683 DrawTrackBackground(g, r, chIdx);
1686 DrawTrackName(g, r, chIdx);
1688 const float trackPos =
static_cast<float>(
GetValue(chIdx));
1690 const bool stepped = GetStepped();
1693 const float bv =
static_cast<float>(mBaseValue);
1697 if(mDirection == EDirection::Vertical)
1699 fillRect =
IRECT(r.L,
1700 trackPos < bv ? r.B - r.
H() * bv : r.B - r.
H() * trackPos,
1702 trackPos < bv ? r.B - r.
H() * trackPos : r.B - r.
H() * bv);
1706 fillRect =
IRECT(trackPos < bv ? r.L + r.
W() * trackPos : r.L + r.
W() * bv,
1708 trackPos < bv ? r.L + r.
W() * bv : r.L + r.
W() * trackPos,
1714 fillRect = r.
FracRect(mDirection, trackPos);
1716 if(stepped && mZeroValueStepHasBounds && trackPos == 0.f)
1718 if(mDirection == EDirection::Vertical)
1719 fillRect.T = mStepBounds.Get()[0].T;
1725 int step = GetStepIdxForPos(fillRect.R, fillRect.T);
1729 if(mDirection == EDirection::Horizontal)
1731 fillRect.L = mStepBounds.Get()[step].L;
1732 fillRect.R = mStepBounds.Get()[step].R;
1736 fillRect.T = mStepBounds.Get()[step].T;
1737 fillRect.B = mStepBounds.Get()[step].B;
1741 if(mZeroValueStepHasBounds ||
GetValue(chIdx) > 0.)
1750 if(mDirection == EDirection::Vertical)
1752 peakRect =
IRECT(fillRect.L,
1753 trackPos < mBaseValue ? fillRect.B : fillRect.T,
1755 trackPos < mBaseValue ? fillRect.B - mPeakSize: fillRect.T + mPeakSize);
1759 peakRect =
IRECT(trackPos < mBaseValue ? fillRect.L + mPeakSize : fillRect.R - mPeakSize,
1761 trackPos < mBaseValue ? fillRect.L : fillRect.R,
1765 DrawPeak(g, peakRect, chIdx, trackPos > mBaseValue);
1768 if(mStyle.drawFrame && mDrawTrackFrame)
1772 virtual void DrawTrackBackground(
IGraphics& g,
const IRECT& r,
int chIdx)
1774 g.
FillRect(chIdx == mHighlightedTrack ? this->
GetColor(kHL) : COLOR_TRANSPARENT, r);
1777 virtual void DrawTrackName(
IGraphics& g,
const IRECT& r,
int chIdx)
1779 g.
DrawText(mText, GetTrackName(chIdx), r);
1791 if(chIdx == mMouseOverTrack)
1795 virtual void DrawPeak(
IGraphics& g,
const IRECT& r,
int chIdx,
bool aboveBaseValue)
1800 int GetStepIdxForPos(
float x,
float y)
const
1802 int nSteps = mStepBounds.GetSize();
1804 for (
auto v = 0; v < nSteps; v++)
1806 if (mStepBounds.Get()[v].ContainsEdge(x, y))
1815 virtual void MakeTrackRects(
const IRECT& bounds)
1817 int nVals =
NVals();
1818 int dir =
static_cast<int>(mDirection);
1819 for (
int ch = 0; ch < nVals; ch++)
1821 mTrackBounds.Get()[ch] = bounds.
SubRect(EDirection(!dir), nVals, ch).
1822 GetPadded(0, -mTrackPadding * (
float) dir, -mTrackPadding * (float) !dir, -mTrackPadding);
1826 virtual void MakeStepRects(
const IRECT& bounds,
int nSteps)
1830 int dir =
static_cast<int>(mDirection);
1832 nSteps += (int) mZeroValueStepHasBounds;
1834 mStepBounds.Resize(nSteps);
1836 for (
int step = 0; step < nSteps; step++)
1838 mStepBounds.Get()[step] = bounds.
SubRect(EDirection(dir), nSteps, nSteps - 1 - step);
1842 mStepBounds.Resize(0);
1845 bool GetStepped()
const
1847 return mStepBounds.GetSize() > 0;
1851 EDirection mDirection = EDirection::Vertical;
1852 WDL_TypedBuf<IRECT> mTrackBounds;
1853 WDL_TypedBuf<IRECT> mStepBounds;
1854 WDL_PtrList<WDL_String> mTrackNames;
1856 float mTrackPadding = 0.;
1857 float mPeakSize = 1.;
1858 int mHighlightedTrack = -1;
1859 int mMouseOverTrack = -1;
1860 double mBaseValue = 0.;
1861 bool mDrawTrackFrame =
true;
1862 bool mZeroValueStepHasBounds =
true;
1874 void OnEndAnimation()
override;
1881 ISwitchControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, IActionFunction aF =
nullptr,
int numStates = 2);
1888 int GetSelectedIdx()
const {
return int(0.5 +
GetValue() * (
double) (mNumStates - 1)); }
1890 void SetStateDisabled(
int stateIdx,
bool disabled);
1891 void SetAllStatesDisabled(
bool disabled);
1892 bool GetStateDisabled(
int stateIdx)
const;
1895 WDL_TypedBuf<bool> mDisabledState;
1896 bool mMouseDown =
false;
1913 IDirBrowseControlBase(
const IRECT& bounds,
const char* extension,
bool showFileExtensions =
true,
bool scanRecursively =
true,
bool showEmptySubmenus =
false)
1915 , mExtension(extension)
1916 , mShowFileExtensions(showFileExtensions)
1917 , mScanRecursively(scanRecursively)
1918 , mShowEmptySubmenus(showEmptySubmenus)
1929 void AddPath(
const char* path,
const char* displayText);
1947 void ScanDirectory(
const char* path,
IPopupMenu& menuToAddTo);
1951 const bool mScanRecursively;
1952 const bool mShowFileExtensions;
1953 const bool mShowEmptySubmenus;
1954 int mSelectedItemIndex = -1;
1956 WDL_PtrList<WDL_String> mPaths;
1957 WDL_PtrList<WDL_String> mPathLabels;
1958 WDL_PtrList<WDL_String> mFiles;
1959 WDL_PtrList<IPopupMenu::Item> mItems;
1960 WDL_String mExtension;
1965#pragma mark - BASIC CONTROLS
1977 AttachFunc attachFunc =
nullptr, ResizeFunc resizeFunc =
nullptr)
1980 , mDrawFrame(drawFrame)
1982 mIgnoreMouse =
true;
1986 AttachFunc attachFunc =
nullptr, ResizeFunc resizeFunc =
nullptr)
1989 , mDrawFrame(drawFrame)
1991 mIgnoreMouse =
true;
2000 g.
DrawRect(COLOR_LIGHT_GRAY, mRECT, &mBlend);
2003 void SetPattern(
const IPattern& pattern)
2009 IPattern GetPattern()
const {
return mPattern; }
2020 ILambdaControl(
const IRECT& bounds, ILambdaDrawFunction drawFunc,
int animationDuration = DEFAULT_ANIMATION_DURATION,
2021 bool loopAnimation =
false,
bool startImmediately =
false,
int paramIdx = kNoParameter,
bool ignoreMouse =
false)
2023 , mDrawFunc(drawFunc)
2024 , mLoopAnimation(loopAnimation)
2025 , mAnimationDuration(animationDuration)
2027 if (startImmediately)
2030 mIgnoreMouse = ignoreMouse;
2031 mDblAsSingleClick =
true;
2037 mDrawFunc(
this, g, mRECT);
2040 virtual void OnEndAnimation() override
2042 if (mLoopAnimation && mAnimationDuration)
2045 IControl::OnEndAnimation();
2052 mMouseInfo.x = x; mMouseInfo.y = y; mMouseInfo.ms = mod;
2070 mMouseInfo.ms = mod;
2078 ILambdaDrawFunction mDrawFunc =
nullptr;
2079 bool mLoopAnimation;
2080 int mAnimationDuration;
2121 , mUseLayer(useLayer)
2141 g.
DrawSVG(mSVG, mRECT, &mBlend);
2144 void SetSVG(
const ISVG& svg)
2159 ITextControl(
const IRECT& bounds,
const char* str =
"",
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR,
bool setBoundsBasedOnStr =
false);
2166 virtual void SetStr(
const char* str);
2170 virtual void SetStrFmt(
int maxlen,
const char* fmt, ...);
2176 const char*
GetStr()
const {
return mStr.Get(); }
2184 bool mSetBoundsBasedOnStr =
false;
2194 mIgnoreMouse =
false;
2220 g.
FillRect(mBGColor, mRECT, &mBlend);
2230 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);
2247 IColor mOriginalColor, mMOColor, mCLColor;
2248 bool mClicked =
false;
2255 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);
2257 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);
2260 void SetDirty(
bool push,
int valIdx = 0)
override;
2262 WDL_String mOffText;
2276 ICaptionControl(
const IRECT& bounds,
int paramIdx,
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR,
bool showParamLabel =
true);
2281 bool mShowParamLabel;
2282 IColor mTriangleColor = COLOR_BLACK;
2283 IColor mTriangleMouseOverColor = COLOR_WHITE;
2284 IRECT mTriangleRect;
2299 IRECT mCentreLabelBounds;
2300 WDL_String mTLHCStr;
2301 WDL_String mWidthStr;
2302 WDL_String mHeightStr;
2303 IText mTLGCText = DEFAULT_TEXT.WithAlign(EAlign::Near);
2304 IText mWidthText = DEFAULT_TEXT;
2305 IText mHeightText = DEFAULT_TEXT.WithAngle(270.f);
2306 static constexpr float mInset = 10.f;
2309END_IGRAPHICS_NAMESPACE
A base interface to be combined with IControl for bitmap-based controls "IBControls",...
void AttachIControl(IControl *pControl)
Call in the constructor of your IBControl to link the IBitmapBase and IControl.
IBitmapBase(const IBitmap &bitmap)
IBitmapBase Constructor.
void DrawBitmap(IGraphics &g)
Draw a frame of a multi-frame bitmap based on the IControl value.
A basic control to draw a bitmap, or one frame of a stacked bitmap depending on the current value.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
IBitmapControl(float x, float y, const IBitmap &bitmap, int paramIdx=kNoParameter, EBlend blend=EBlend::Default)
Creates a bitmap control.
void OnRescale() override
If you override this make sure you call the parent method in order to rescale mBitmap.
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
A control to display the textual representation of a parameter.
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 Draw(IGraphics &g) override
Draw the control to the graphics context.
IContainerBase allows a control to nest sub controls and it clips the drawing of those subcontrols In...
void Hide(bool hide) override
Shows or hides the IControl.
virtual void OnResize() override
Called when IControl is constructed or resized using SetRect().
virtual void OnAttached() override
Called after the control has been attached, and its delegate and graphics member variable set.
void SetDisabled(bool disable) override
Sets disabled mode for the control, the default implementation modifies the mBlend member.
virtual void Draw(IGraphics &g) override
Draw the control to the graphics context.
The lowest level base class of an IGraphics control.
const IGraphics * GetUI() const
virtual bool GetWantsGestures() const
bool GetMouseIsOver() const
This can be used in IControl::Draw() to check if the mouse is over the control, without implementing ...
WDL_String mGroup
Controls can be grouped for hiding and showing panels.
IBlend GetBlend() const
Get the Blend for this control.
void SetMouseOverWhenDisabled(bool allow)
Specify whether the control should respond to mouse overs when disabled.
virtual void OnResize()
Called when IControl is constructed or resized using SetRect().
const char * GetGroup() const
Get the group that the control belongs to, if any.
bool GetWantsMidi() const
Milliseconds GetAnimationDuration() const
Get the duration of animations applied to the control.
virtual void SetIgnoreMouse(bool ignore)
Specify whether the control should respond to mouse events.
int GetTextEntryLength() const
Get the max number of characters that are allowed in text entry.
virtual void OnDropMultiple(const std::vector< const char * > &paths)
Implement to handle multiple items drag 'n dropped onto this control.
virtual bool OnKeyUp(float x, float y, const IKeyPress &key)
Implement this method to respond to a key up event on this control.
virtual void OnMouseOut()
Implement this method to respond to a mouseout event on this control.
bool GetWantsMultiTouch() const
void SetWantsMultiTouch(bool enable=true)
Specify whether this control supports multiple touches.
const char * GetTooltip() const
virtual void OnGUIIdle()
This is an idle timer tick call on the GUI thread, only active if USE_IDLE_CALLS is defined.
bool GetMouseEventsWhenDisabled() const
bool mMouseIsOver
if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control.
bool GetMouseOverWhenDisabled() const
virtual void OnMouseOver(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouseover event on this control.
void SetMouseEventsWhenDisabled(bool allow)
Specify whether the control should respond to other mouse events when disabled.
void SetWantsMidi(bool enable=true)
Specify whether this control wants to know about MIDI messages sent to the UI.
virtual ~IControl()
Destructor.
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...
void SetGroup(const char *groupName)
Assign the control to a control group.
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.
IActionFunction GetActionFunction()
Get the control's action function, if it exists.
virtual bool IsDirty()
Called at each display refresh by the IGraphics draw loop, after IControl::Animate(),...
virtual bool IsHit(float x, float y) const
Hit test the control.
virtual void Hide(bool hide)
Shows or hides the IControl.
virtual void OnRescale()
Implement to do something when graphics is scaled globally (e.g.
void SetDelegate(IGEditorDelegate &dlg)
Used internally to set the mDelegate (and mGraphics) variables.
virtual void OnDeleteFromPopupMenu(IPopupMenu *pMenu, int itemIdx)
Implement this method to handle popup menu deletion interactions (on IOS) after IGraphics::CreatePopu...
virtual void OnTouchCancelled(float x, float y, const IMouseMod &mod)
Implement this method to respond to a touch cancel event on this control.
virtual void OnDrop(const char *str)
Implement to do something when something was drag 'n dropped onto this control.
IControl * AttachGestureRecognizer(EGestureType type, IGestureFunc func)
Add a IGestureFunc that should be triggered in response to a certain type of gesture.
const IRECT & GetTargetRECT() const
Get the rectangular mouse tracking target area, within the graphics context for this control.
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.
virtual bool OnKeyDown(float x, float y, const IKeyPress &key)
Implement this method to respond to a key down event on this control.
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.
bool GetIgnoreMouse() const
IGEditorDelegate * GetDelegate()
Gets a pointer to the class implementing the IEditorDelegate interface that handles parameter changes...
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.
virtual void OnMouseDblClick(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse double click event on this control.
virtual void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData)
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate()
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,...
int GetTag() const
Get the control's tag.
virtual void OnMouseUp(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouse up event on this control.
void SetPromptShowsParamLabel(bool enable)
Set if the control should show parameter labels/units e.g.
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 CreateContextMenu(IPopupMenu &contextMenu)
Called by default when the user right clicks a control.
virtual void OnAttached()
Called after the control has been attached, and its delegate and graphics member variable set.
IControl * SetAnimationEndActionFunction(IActionFunction actionFunc)
Set an Action Function to be called at the end of an animation.
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)
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.
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.
virtual void Draw(IGraphics &g)=0
Draw the control to the graphics context.
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.
const IText & GetText() const
Get the Text object for the control.
virtual void OnMidi(const IMidiMsg &msg)
Implement to receive MIDI messages sent to the control if mWantsMidi == true, see IEditorDelegate:Sen...
bool GetMouseDblAsSingleClick() const
Get double click as single click By default, mouse double click has its own handler.
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.
virtual void OnTextEntryCompletion(const char *str, int valIdx)
Implement this method to handle text input after IGraphics::CreateTextEntry/IControlPromptUserInput.
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 OnInit()
Called just prior to when the control is attached, after its delegate and graphics member variable se...
IControl * SetTooltip(const char *str)
Set a tooltip for the control.
void SetAnimation(IAnimationFunction func, int duration)
Set the animation function and starts it.
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 void OnContextSelection(int itemSelected)
Implement this to respond to a menu selection from CreateContextMenu();.
void SetBlend(const IBlend &blend)
Set the Blend 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.
IContainerBase * GetParent() const
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.
EGestureType GetLastGesture() const
void SetTextEntryLength(int len)
Set the max number of characters that are allowed in text entry.
bool GetPromptShowsParamLabel() const
void DisablePrompt(bool disable)
Disable/enable default prompt for user input.
IControl * SetActionFunction(IActionFunction actionFunc)
Set an Action Function for this control.
void SetAnimation(IAnimationFunction func)
Set the animation function.
An abstract IControl base class that you can inherit from in order to make a control that pops up a m...
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.
IDirBrowseControlBase(const IRECT &bounds, const char *extension, bool showFileExtensions=true, bool scanRecursively=true, bool showEmptySubmenus=false)
Creates an IDirBrowseControlBase.
void AddPath(const char *path, const char *displayText)
Used to add a path to scan for files.
A basic control to display some editable text.
void OnTextEntryCompletion(const char *str, int valIdx) override
Implement this method to handle text input after IGraphics::CreateTextEntry/IControlPromptUserInput.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
IParam * GetParam(int paramIdx)
Get a pointer to one of the delegate's IParam objects.
An editor delegate base class that uses IGraphics for the UI.
IGraphics * GetUI()
Get a pointer to the IGraphics context.
The lowest level base class of an IGraphics context.
virtual void DrawRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw a rectangle to the graphics context.
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.
void RemoveControl(int idx)
Remove a control at a particular index, (frees memory).
virtual void PathFill(const IPattern &pattern, const IFillOptions &options=IFillOptions(), const IBlend *pBlend=0)=0
Fill the current current path.
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 CreateTextEntry(IControl &control, const IText &text, const IRECT &bounds, const char *str="", int valIdx=0)
Create a text entry box.
void PathRect(const IRECT &bounds)
Add a rectangle to the current path.
virtual ECursor SetMouseCursor(ECursor cursorType=ECursor::ARROW)
Sets the mouse cursor to one of ECursor (implementations should return the result of the base impleme...
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.
bool CheckLayer(const ILayerPtr &layer)
Test to see if a layer needs drawing, for instance if the control's bounds were changed.
void DrawLayer(const ILayerPtr &layer, const IBlend *pBlend=nullptr)
Draw a layer to the main IGraphics context.
virtual void FillRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0)
Fill a rectangular region of the graphics context with a color.
void PathClipRegion(const IRECT r=IRECT())
Clip the current path to a particular region.
virtual void FillRoundRect(const IColor &color, const IRECT &bounds, float cornerRadius=5.f, const IBlend *pBlend=0)
Fill a rounded rectangle with a color.
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.
IBitmap GetScaledBitmap(IBitmap &inBitmap)
Get a version of the input bitmap from the cache that corresponds to the current screen scale For exa...
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 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.
virtual void DrawMultiLineText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend=0)
Draw some multi-line text to the graphics context in a specific rectangle (NanoVG only)
void StartLayer(IControl *pOwner, const IRECT &r, bool cacheable=false)
Create an IGraphics layer.
int GetControlTag(const IControl *pControl) const
Get the tag given to a control.
virtual void DrawSVG(const ISVG &svg, const IRECT &bounds, const IBlend *pBlend=0, const IColor *pStrokeColor=nullptr, const IColor *pFillColor=nullptr)
Draw an SVG image to the graphics context.
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.
virtual void FillCircle(const IColor &color, float cx, float cy, float r, const IBlend *pBlend=0)
Fill a circle with a color.
ILayerPtr EndLayer()
End an IGraphics layer.
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.
virtual float MeasureText(const IText &text, const char *str, IRECT &bounds) const
Measure the rectangular region that some text will occupy.
A base class for knob/dial controls, to handle mouse action and Sender.
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...
A control that can be specialised with a lambda function, for quick experiments without making a cust...
void Draw(IGraphics &g) override
Draw the control to the graphics context.
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 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 that needs to span multiple lines.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
A base class for controls that can do do multitouch.
A basic control to fill a rectangle with a color or gradient.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
double GetStep() const
Returns the parameter's step size.
double GetRange() const
Returns the parameter's range.
const char * GetGroup() const
Returns the parameter's group.
A basic control to draw an SVG image to the screen.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
A base class for slider/fader controls, to handle mouse action and Sender.
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.
A base class for switch controls.
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...
const char * GetStr() const
virtual void ClearStr()
Clear the text .
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.
A control to toggle between two text strings on click.
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.
A control to show a clickable URL, that changes color after clicking.
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 SetCLColor(const IColor &color)
Sets the color of the text when the URL has been clicked.
void OnMouseOut() override
Implement this method to respond to a mouseout 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 OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void SetMOColor(const IColor &color)
Sets the color of the text on Mouse Over.
A base class for mult-strip/track controls, such as multi-sliders, meters Track refers to the channel...
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
void OnMouseOut() override
Implement this method to respond to a mouseout event on this control.
void SetParamsByGroup(const char *paramGroup)
Update the parameters based on a parameter group name.
virtual void DrawTrackHandle(IGraphics &g, const IRECT &r, int chIdx, bool aboveBaseValue)
Draw the main body of the track.
void SetParams(const std::vector< int > ¶mIds)
Update the parameters based on a parameter group name.
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
int GetValIdxForPos(float x, float y) const override
Check to see which of the control's values relates to this x and y coordinate.
virtual void DrawBackground(IGraphics &g, const IRECT &r) override
Draw the IVControl background (usually transparent)
virtual void OnResize() override
Called when IControl is constructed or resized using SetRect().
A base interface to be combined with IControl for vectorial controls "IVControls",...
virtual void DrawPressableShape(IGraphics &g, EVShape shape, const IRECT &bounds, bool pressed, bool mouseOver, bool disabled)
Call one of the DrawPressableShape methods.
void SetColor(EVColor colorIdx, const IColor &color)
Set one of the IVColors that style the IVControl.
IRECT MakeRects(const IRECT &parent, bool hasHandle=false)
Calculate the rectangles for the various areas, depending on the style.
virtual void DrawBackground(IGraphics &g, const IRECT &rect)
Draw the IVControl background (usually transparent)
virtual void SetStyle(const IVStyle &style)
Set the Style of this IVControl.
virtual void DrawWidget(IGraphics &g)
Draw the IVControl main widget (override)
IVectorBase(const IVStyle &style, bool labelInWidget=false, bool valueInWidget=false)
IVectorBase Constructor.
IRECT GetAdjustedHandleBounds(IRECT handleBounds) const
Get the adjusted bounds for the widget handle, based on the style settings.
void DrawPressableEllipse(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, bool disabled)
Draw an ellipse-shaped vector button.
IRECT DrawPressableTriangle(IGraphics &g, const IRECT &bounds, bool pressed, bool mouseOver, float angle, bool disabled)
Draw a triangle-shaped vector button.
float GetRoundedCornerRadius(const IRECT &bounds) const
Get the radius of rounded corners for a rectangle, based on the style roundness factor.
virtual void DrawValue(IGraphics &g, bool mouseOver)
Draw the IVControl value text.
void DrawSplash(IGraphics &g, const IRECT &clipRegion=IRECT())
Draw a splash effect when a widget handle is clicked (via SplashClickAnimationFunc)
void AttachIControl(IControl *pControl, const char *label)
Call in the constructor of your IVControl to link the IVectorBase and IControl.
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.
virtual void DrawLabel(IGraphics &g)
Draw the IVControl label text.
virtual void OnStyleChanged()
Implement if extra changes are required in response to style changing.
const IColor & GetColor(EVColor color) const
Get value of a specific EVColor in the IVControl.
void SetColors(const IVColorSpec &spec)
Set the colors of this IVControl.
IVStyle GetStyle() const
Get the style of this IVControl.
A control to use as a placeholder during development.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnResize() override
Called when IControl is constructed or resized using SetRect().
void OnTextEntryCompletion(const char *str, int valIdx) override
Implement this method to handle text input after IGraphics::CreateTextEntry/IControlPromptUserInput.
void OnMouseDblClick(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse double click event on this control.
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 DefaultClickActionFunc(IControl *pCaller)
A click action function that triggers the default animation function for DEFAULT_ANIMATION_DURATION.
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
Used to describe a particular gesture.
Used to group mouse coordinates with mouse modifier information.
BEGIN_IPLUG_NAMESPACE T Clip(T x, T lo, T hi)
Clips the value x between lo and hi.
Used to manage composite/blend operations, independent of draw class/platform.
Used to manage color data, independent of draw class/platform.
Used to manage fill behaviour.
Used for key press info, such as ASCII representation, virtual key (mapped to win32 codes) and modifi...
Encapsulates a MIDI message and provides helper functions.
Used to manage mouse modifiers i.e.
Used to store pattern information for gradients.
Used to manage a rectangular area, independent of draw class/platform.
IRECT ReduceFromRight(float amount)
Reduce in width from the right edge by 'amount' and return the removed region.
IRECT GetReducedFromTop(float amount) const
Get a subrect of this IRECT reduced in height from the top edge by 'amount'.
IRECT GetReducedFromLeft(float amount) const
Get a subrect of this IRECT reduced in width from the left edge by 'amount'.
IRECT GetReducedFromRight(float amount) const
Get a subrect of this IRECT reduced in width from the right edge by 'amount'.
void Pad(float padding)
Pad this IRECT N.B.
IRECT GetFromRight(float amount) const
Get a subrect of this IRECT bounded in X by 'amount' and the right edge.
IRECT GetFromBottom(float amount) const
Get a subrect of this IRECT bounded in Y by 'amount' and the bottom 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.
IRECT GetScaledAboutCentre(float scale) const
Get a copy of this IRECT where the width and height are multiplied by scale without changing the cent...
IRECT GetReducedFromBottom(float amount) const
Get a subrect of this IRECT reduced in height from the bottom edge by 'amount'.
void Offset(float l, float t, float r, float b)
Offset each field of the rectangle.
IRECT SubRect(EDirection layoutDir, int numSlices, int sliceIdx) const
Get a new rectangle which is a "slice" of this rectangle.
IRECT FracRect(EDirection layoutDir, float frac, bool fromTopOrRight=false) const
Get a new rectangle which is a fraction of this rectangle.
IRECT ReduceFromBottom(float amount)
Reduce in height from the bottom edge by 'amount' and return the removed region.
IRECT GetFromLeft(float amount) const
Get a subrect of this IRECT bounded in X by the left edge and 'amount'.
IRECT GetFromTop(float amount) const
Get a subrect of this IRECT bounded in Y by the top edge and 'amount'.
IRECT GetMidHPadded(float padding) const
Get a copy of this IRECT where its width = 2 * padding but the center point on the X-axis has not cha...
bool Contains(const IRECT &rhs) const
Returns true if this IRECT completely contains rhs.
IRECT GetPadded(float padding) const
Get a copy of this IRECT with each value padded by padding N.B.
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...
User-facing SVG abstraction that you use to manage SVG data ISVG doesn't actually own the image data.
IText is used to manage font and text/text entry style for a piece of text on the UI,...
Contains a set of 9 colors used to theme IVControls.
const IColor & GetColor(EVColor color) const
A struct encapsulating a set of properties used to configure IVControls.
Encapsulate an xy point in one struct.