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;
219 inline const char*
GetTooltip()
const {
return mTooltip.Get(); }
231 virtual void SetParamIdx(
int paramIdx,
int valIdx = 0);
239 int NVals()
const {
return (
int) mVals.size(); }
245 virtual int GetValIdxForPos(
float x,
float y)
const {
return mVals.size() == 1 ? 0 : kNoValIdx; }
271 virtual void SetValue(
double value,
int valIdx = 0);
276 double GetValue(
int valIdx = 0)
const;
337 virtual void SetSize(
float w,
float h);
352 virtual void Hide(
bool hide);
395 virtual bool IsHit(
float x,
float y)
const {
return mTargetRECT.
Contains(x, y); }
401 virtual void SetDirty(
bool triggerAction =
true,
int valIdx = kNoValIdx);
404 virtual void SetClean() { mDirty =
false; }
441 virtual bool GetWantsGestures()
const {
return mGestureFuncs.size() > 0 && !mAnimationFunc; }
455 mGraphics = dlg.
GetUI();
482 virtual void SnapToMouse(
float x,
float y, EDirection direction,
const IRECT& bounds,
int valIdx = -1,
double minClip = 0.,
double maxClip = 1.);
485 virtual void OnEndAnimation();
513 T*
As() {
return dynamic_cast<T*
>(
this); }
515#if defined VST3_API || defined VST3C_API
516 Steinberg::tresult PLUGIN_API executeMenuItem (Steinberg::int32 tag)
override {
OnContextSelection(tag);
return Steinberg::kResultOk; }
519#pragma mark - IControl Member variables
526 template<
typename T,
typename... Args>
529 if (valIdx > kNoValIdx)
530 func(valIdx, args...);
533 const int nVals =
NVals();
534 for (
int v = 0; v < nVals; v++)
547 int mTextEntryLength = DEFAULT_TEXT_ENTRY_LEN;
550 bool mDisabled =
false;
551 bool mDisablePrompt =
true;
552 bool mDblAsSingleClick =
false;
553 bool mMouseOverWhenDisabled =
false;
554 bool mMouseEventsWhenDisabled =
false;
555 bool mIgnoreMouse =
false;
556 bool mWantsMidi =
false;
557 bool mWantsMultiTouch =
false;
558 bool mPromptShowsParamLabel =
false;
563 IColor mPTHighlightColor = COLOR_RED;
564 bool mPTisHighlighted =
false;
566 void SetNVals(
int nVals)
572#if defined VST3_API || defined VST3C_API
575 DEF_INTERFACE (IContextMenuTarget)
576 END_DEFINE_INTERFACES (FObject)
577 REFCOUNT_METHODS(FObject)
584 IActionFunction mActionFunc =
nullptr;
585 IActionFunction mAnimationEndActionFunc =
nullptr;
586 IAnimationFunction mAnimationFunc =
nullptr;
587 TimePoint mAnimationStartTime;
588 Milliseconds mAnimationDuration;
589 std::vector<ParamTuple> mVals { {kNoParameter, 0.} };
590 std::unordered_map<EGestureType, IGestureFunc> mGestureFuncs;
591 EGestureType mLastGesture = EGestureType::Unknown;
594#pragma mark - Base Controls
611 IContainerBase(
const IRECT& bounds,
int paramIdx = kNoParameter, IActionFunction actionFunc =
nullptr)
612 :
IControl(bounds, paramIdx, actionFunc)
615 IContainerBase(
const IRECT& bounds,
const std::initializer_list<int>& params, IActionFunction actionFunc =
nullptr)
616 :
IControl(bounds, params, actionFunc)
625 , mAttachFunc(attachFunc)
626 , mResizeFunc(resizeFunc)
631 void SetAttachFunc(AttachFunc attachFunc)
633 mAttachFunc = attachFunc;
636 void SetResizeFunc(ResizeFunc resizeFunc)
638 mResizeFunc = resizeFunc;
648 mChildren.Empty(
false);
654 mAttachFunc(
this, mRECT);
661 if (mResizeFunc && mChildren.GetSize())
662 mResizeFunc(
this, mRECT);
667 ForAllChildrenFunc([disable](
int childIdx,
IControl* pChild) {
676 ForAllChildrenFunc([hide](
int childIdx,
IControl* pChild) {
683 IControl* AddChildControl(
IControl* pControl,
int ctrlTag = kNoTag,
const char* group =
"")
685 pControl->SetParent(
this);
686 return mChildren.Add(
GetUI()->AttachControl(pControl, ctrlTag, group));
689 void RemoveChildControl(
IControl* pControl)
691 pControl->SetParent(
nullptr);
692 mChildren.DeletePtr(pControl,
false);
698 return mChildren.Get(idx);
701 int NChildren()
const {
return mChildren.GetSize(); }
703 void ForAllChildrenFunc(std::function<
void(
int childIdx,
IControl* pControl)> func)
705 for (
int i=0; i<mChildren.GetSize(); i++)
707 func(i, mChildren.Get(i));
712 AttachFunc mAttachFunc =
nullptr;
713 ResizeFunc mResizeFunc =
nullptr;
714 WDL_PtrList<IControl> mChildren;
742 i = 1 + int(0.5 + mControl->
GetValue() *
static_cast<double>(mBitmap.
N() - 1));
743 i =
Clip(i, 1, mBitmap.
N());
764 : mLabelInWidget(labelInWidget)
765 , mValueInWidget(valueInWidget)
778 mLabelStr.Set(label);
789 mStyle.colorSpec.mColors[
static_cast<int>(colorIdx)] = color;
797 mStyle.colorSpec = spec;
803 return mStyle.colorSpec.
GetColor(color);
806 void SetLabelStr(
const char* label) { mLabelStr.Set(label); mControl->
SetDirty(
false);
OnStyleChanged(); }
807 const char* GetLabelStr()
const {
return mLabelStr.Get(); }
808 void SetValueStr(
const char* value) { mValueStr.Set(value); mControl->
SetDirty(
false);
OnStyleChanged(); }
813 void SetRoundness(
float roundness) { mStyle.roundness =
Clip(roundness, 0.f, 1.f); mControl->
SetDirty(
false);
OnStyleChanged(); }
815 void SetDrawShadows(
bool draw) { mStyle.drawShadows = draw; mControl->
SetDirty(
false);
OnStyleChanged(); }
817 void SetShadowOffset(
float offset) { mStyle.shadowOffset = offset; mControl->
SetDirty(
false);
OnStyleChanged(); }
818 void SetFrameThickness(
float thickness) { mStyle.frameThickness = thickness; mControl->
SetDirty(
false);
OnStyleChanged(); }
819 void SetSplashRadius(
float radius) { mSplashRadius = radius * mMaxSplashRadius;
OnStyleChanged(); }
820 void SetSplashPoint(
float x,
float y) { mSplashPoint.x = x; mSplashPoint.y = y;
OnStyleChanged(); }
841 if (mStyle.drawFrame)
842 handleBounds.
Pad(- 0.5f * mStyle.frameThickness);
844 if (mStyle.drawShadows)
845 handleBounds.
Offset(mStyle.shadowOffset, 0, -mStyle.shadowOffset, -mStyle.shadowOffset);
855 if (bounds.
W() < bounds.
H())
856 return mStyle.roundness * (bounds.
W() / 2.f);
858 return mStyle.roundness * (bounds.
H() / 2.f);
861 IRECT GetWidgetBounds()
const {
return mWidgetBounds; }
862 IRECT GetLabelBounds()
const {
return mLabelBounds; }
863 IRECT GetValueBounds()
const {
return mValueBounds; }
891 if (mLabelBounds.
H() && mStyle.showLabel)
894 g.
DrawText(mStyle.labelText, mLabelStr.Get(), mLabelBounds, &blend);
902 g.
FillRect(COLOR_TRANSLUCENT, mValueBounds);
904 if (mStyle.showValue)
907 g.
DrawText(mStyle.valueText, mValueStr.Get(), mValueBounds, &blend);
922 case EVShape::Ellipse:
925 case EVShape::Rectangle:
928 case EVShape::Triangle:
931 case EVShape::EndsRounded:
934 case EVShape::AllRounded:
950 IRECT handleBounds = bounds;
954 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
956 if(!pressed && !disabled && mStyle.drawShadows)
1009 if (mStyle.drawFrame)
1021 bool rtl =
true,
bool rtr =
true,
bool rbl =
true,
bool rbr =
true)
1024 IRECT centreBounds = handleBounds.
GetPadded(-mStyle.shadowOffset);
1025 IRECT shadowBounds = handleBounds.
GetTranslated(mStyle.shadowOffset, mStyle.shadowOffset);
1027 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1030 const float tlr = rtl ? cR : 0.f;
1031 const float trr = rtr ? cR : 0.f;
1032 const float blr = rbl ? cR : 0.f;
1033 const float brr = rbr ? cR : 0.f;
1060 if (mStyle.drawShadows)
1092 if (mStyle.drawFrame)
1095 return handleBounds;
1105 float x1, x2, x3, y1, y2, y3;
1107 float theta = DegToRad(angle);
1112 float xT = handleBounds.L + handleBounds.
W() * 0.5f;
1113 float yT = handleBounds.T + handleBounds.
H() * 0.5f;
1117 float c = cosf(theta);
1118 float s = sinf(theta);
1119 x1 = centered.L * c - centered.B * s + xT;
1120 y1 = centered.L * s + centered.B * c + yT;
1121 x2 = centered.
MW() * c - centered.T * s + xT;
1122 y2 = centered.
MW() * s + centered.T * c + yT;
1123 x3 = centered.R * c - centered.B * s + xT;
1124 y3 = centered.R * s + centered.B * c + yT;
1127 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1134 if (mStyle.drawShadows)
1136 x2 + mStyle.shadowOffset, y2 + mStyle.shadowOffset,
1137 x3 + mStyle.shadowOffset, y3 + mStyle.shadowOffset, &blend);
1148 if (mStyle.drawFrame)
1151 return handleBounds;
1160 IRECT clickableArea = parent;
1164 if(mStyle.showLabel && CStringHasContents(mLabelStr.Get()))
1167 mControl->
GetUI()->
MeasureText(mStyle.labelText, mLabelStr.Get(), textRect);
1169 switch (mStyle.labelOrientation)
1171 case EOrientation::North:
1174 case EOrientation::East:
1177 case EOrientation::South:
1180 case EOrientation::West:
1186 mLabelBounds =
IRECT();
1188 if (!mLabelBounds.
Empty())
1190 switch (mStyle.labelOrientation)
1192 case EOrientation::North:
1195 case EOrientation::East:
1198 case EOrientation::South:
1201 case EOrientation::West:
1208 if (mStyle.showValue && !mValueInWidget)
1212 if(CStringHasContents(mValueStr.Get()))
1213 mControl->
GetUI()->
MeasureText(mStyle.valueText, mValueStr.Get(), textRect);
1215 const float valueDisplayWidth = textRect.
W() * mValueDisplayFrac;
1217 switch (mStyle.valueText.mVAlign)
1219 case EVAlign::Middle:
1223 case EVAlign::Bottom:
1246 mLabelBounds = mWidgetBounds;
1249 mValueBounds = mWidgetBounds;
1251 return clickableArea;
1257 bool mLabelInWidget =
false;
1258 bool mValueInWidget =
false;
1259 float mSplashRadius = 0.f;
1260 IVec2 mSplashPoint = {0.f, 0.f};
1261 float mMaxSplashRadius = 50.f;
1262 float mTrackSize = 2.f;
1263 float mValueDisplayFrac = 0.66f;
1264 IRECT mWidgetBounds;
1267 WDL_String mLabelStr;
1268 WDL_String mValueStr;
1269 EVShape mShape = EVShape::Rectangle;
1284 TimePoint startTime;
1286 TrackedTouch(
int index,
float x,
float y,
float radius, TimePoint time)
1287 : index(index), x(x), y(y), sx(x), sy(y), radius(radius), startTime(time)
1296 virtual void AddTouch(ITouchID touchID,
float x,
float y,
float radius)
1299 for (
int i = 0; i < MAX_TOUCHES; i++)
1301 if (mTouchStatus[i] ==
false)
1304 mTouchStatus[i] =
true;
1309 if(NTrackedTouches() < MAX_TOUCHES)
1310 mTrackedTouches.insert(std::make_pair(touchID, TrackedTouch(touchIndex, x, y, radius, std::chrono::high_resolution_clock::now())));
1313 virtual void ReleaseTouch(ITouchID touchID)
1315 mTouchStatus[GetTouchWithIdentifier(touchID)->index] =
false;
1316 mTrackedTouches.erase(touchID);
1319 virtual void UpdateTouch(ITouchID touchID,
float x,
float y,
float radius)
1321 mTrackedTouches[touchID].x = x;
1322 mTrackedTouches[touchID].y = y;
1323 mTrackedTouches[touchID].radius = radius;
1326 void ClearAllTouches()
1328 mTrackedTouches.clear();
1329 memset(mTouchStatus, 0, MAX_TOUCHES *
sizeof(
bool));
1332 int NTrackedTouches()
const
1334 return static_cast<int>(mTrackedTouches.size());
1337 TrackedTouch* GetTouch(
int index)
1339 auto itr = std::find_if(mTrackedTouches.begin(), mTrackedTouches.end(),
1340 [index](
auto element) {
1341 return(element.second.index == index);
1344 if(itr != mTrackedTouches.end())
1345 return &itr->second;
1350 TrackedTouch* GetTouchWithIdentifier(ITouchID touchID)
1352 auto itr = mTrackedTouches.find(touchID);
1354 if(itr != mTrackedTouches.end())
1355 return &itr->second;
1361 static constexpr int MAX_TOUCHES = 10;
1362 std::unordered_map<ITouchID, TrackedTouch> mTrackedTouches;
1363 bool mTouchStatus[MAX_TOUCHES] = { 0 };
1370 IKnobControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, EDirection direction = EDirection::Vertical,
double gearing = DEFAULT_GEARING)
1372 , mDirection(direction)
1381 void SetGearing(
double gearing) { mGearing = gearing; }
1382 bool IsFineControl(
const IMouseMod& mod,
bool wheel)
const;
1389 bool mHideCursorOnDrag =
true;
1390 EDirection mDirection;
1392 bool mMouseDown =
false;
1393 double mMouseDragValue = 0.0;
1400 ISliderControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical,
double gearing = DEFAULT_GEARING,
float handleSize = 0.f);
1401 ISliderControlBase(
const IRECT& bounds, IActionFunction aF =
nullptr, EDirection dir = EDirection::Vertical,
double gearing = DEFAULT_GEARING,
float handleSize = 0.f);
1409 void SetGearing(
double gearing) { mGearing = gearing; }
1410 bool IsFineControl(
const IMouseMod& mod,
bool wheel)
const;
1413 bool mHideCursorOnDrag =
true;
1414 EDirection mDirection;
1418 bool mMouseDown =
false;
1419 double mMouseDragValue;
1428 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 = {})
1434 SetNVals(maxNTracks);
1435 mTrackBounds.Resize(maxNTracks);
1437 for (
int i=0; i<maxNTracks; i++)
1442 if(trackNames.size())
1444 assert(trackNames.size() == maxNTracks);
1446 for (
auto& trackName : trackNames)
1448 mTrackNames.Add(
new WDL_String(trackName));
1455 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 = {})
1461 SetNVals(maxNTracks);
1462 mTrackBounds.Resize(maxNTracks);
1464 for (
int i = 0; i < maxNTracks; i++)
1469 if(trackNames.size())
1471 assert(trackNames.size() == maxNTracks);
1473 for (
auto& trackName : trackNames)
1475 mTrackNames.Add(
new WDL_String(trackName));
1482 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 = {})
1488 int maxNTracks =
static_cast<int>(params.size());
1489 SetNVals(maxNTracks);
1490 mTrackBounds.Resize(maxNTracks);
1493 for (
auto param : params)
1498 if(trackNames.size())
1500 assert(trackNames.size() == params.size());
1502 for (
auto& trackName : trackNames)
1504 mTrackNames.Add(
new WDL_String(trackName));
1513 mTrackNames.Empty(
true);
1524 mMouseOverTrack = -1;
1531 MakeTrackRects(mWidgetBounds);
1532 MakeStepRects(mWidgetBounds, mNSteps);
1538 int nVals =
NVals();
1540 for (
auto v = 0; v < nVals; v++)
1542 if (mTrackBounds.Get()[v].Contains(x, y))
1553 const int nVals =
NVals();
1555 for (
int ch = 0; ch < nVals; ch++)
1557 DrawTrack(g, mTrackBounds.Get()[ch], ch);
1566 std::vector<int> paramIdsForGroup;
1568 for (
auto p = 0; p < nParams; p++)
1572 if(strcmp(pParam->
GetGroup(), paramGroup) == 0)
1574 paramIdsForGroup.push_back(p);
1585 int nParams =
static_cast<int>(paramIds.size());
1588 mTrackBounds.Resize(nParams);
1591 for (
auto param : paramIds)
1597 const int range =
static_cast<int>(pFirstParam->
GetRange() / pFirstParam->
GetStep());
1598 mZeroValueStepHasBounds = !(range == 1);
1599 SetNSteps(pFirstParam->
GetStepped() ? range : 0);
1602 void SetNTracks(
int nTracks)
1605 mTrackBounds.Resize(nTracks);
1609 void SetBaseValue(
double value)
1614 void SetTrackPadding(
float value)
1619 void SetPeakSize(
float value)
1624 void SetNSteps(
int nSteps)
1629 void SetHighlightedTrack(
int highlightIdx)
1631 mHighlightedTrack = highlightIdx;
1635 void SetZeroValueStepHasBounds(
bool val)
1637 mZeroValueStepHasBounds = val;
1641 bool HasTrackNames()
const
1643 return mTrackNames.GetSize() > 0;
1646 const char* GetTrackName(
int chIdx)
const
1648 WDL_String* pStr = mTrackNames.Get(chIdx);
1649 return pStr ? pStr->Get() :
"";
1652 void SetTrackName(
int chIdx,
const char* newName)
1654 assert(chIdx >= 0 && chIdx < mTrackNames.GetSize());
1656 if(chIdx >= 0 && chIdx < mTrackNames.GetSize())
1658 mTrackNames.Get(chIdx)->Set(newName);
1669 if(mDirection == EDirection::Horizontal)
1678 DrawTrackBackground(g, r, chIdx);
1681 DrawTrackName(g, r, chIdx);
1683 const float trackPos =
static_cast<float>(
GetValue(chIdx));
1685 const bool stepped = GetStepped();
1688 const float bv =
static_cast<float>(mBaseValue);
1692 if(mDirection == EDirection::Vertical)
1694 fillRect =
IRECT(r.L,
1695 trackPos < bv ? r.B - r.
H() * bv : r.B - r.
H() * trackPos,
1697 trackPos < bv ? r.B - r.
H() * trackPos : r.B - r.
H() * bv);
1701 fillRect =
IRECT(trackPos < bv ? r.L + r.
W() * trackPos : r.L + r.
W() * bv,
1703 trackPos < bv ? r.L + r.
W() * bv : r.L + r.
W() * trackPos,
1709 fillRect = r.
FracRect(mDirection, trackPos);
1711 if(stepped && mZeroValueStepHasBounds && trackPos == 0.f)
1713 if(mDirection == EDirection::Vertical)
1714 fillRect.T = mStepBounds.Get()[0].T;
1720 int step = GetStepIdxForPos(fillRect.R, fillRect.T);
1724 if(mDirection == EDirection::Horizontal)
1726 fillRect.L = mStepBounds.Get()[step].L;
1727 fillRect.R = mStepBounds.Get()[step].R;
1731 fillRect.T = mStepBounds.Get()[step].T;
1732 fillRect.B = mStepBounds.Get()[step].B;
1736 if(mZeroValueStepHasBounds ||
GetValue(chIdx) > 0.)
1745 if(mDirection == EDirection::Vertical)
1747 peakRect =
IRECT(fillRect.L,
1748 trackPos < mBaseValue ? fillRect.B : fillRect.T,
1750 trackPos < mBaseValue ? fillRect.B - mPeakSize: fillRect.T + mPeakSize);
1754 peakRect =
IRECT(trackPos < mBaseValue ? fillRect.L + mPeakSize : fillRect.R - mPeakSize,
1756 trackPos < mBaseValue ? fillRect.L : fillRect.R,
1760 DrawPeak(g, peakRect, chIdx, trackPos > mBaseValue);
1763 if(mStyle.drawFrame && mDrawTrackFrame)
1767 virtual void DrawTrackBackground(
IGraphics& g,
const IRECT& r,
int chIdx)
1769 g.
FillRect(chIdx == mHighlightedTrack ? this->
GetColor(kHL) : COLOR_TRANSPARENT, r);
1772 virtual void DrawTrackName(
IGraphics& g,
const IRECT& r,
int chIdx)
1774 g.
DrawText(mText, GetTrackName(chIdx), r);
1786 if(chIdx == mMouseOverTrack)
1790 virtual void DrawPeak(
IGraphics& g,
const IRECT& r,
int chIdx,
bool aboveBaseValue)
1795 int GetStepIdxForPos(
float x,
float y)
const
1797 int nSteps = mStepBounds.GetSize();
1799 for (
auto v = 0; v < nSteps; v++)
1801 if (mStepBounds.Get()[v].ContainsEdge(x, y))
1810 virtual void MakeTrackRects(
const IRECT& bounds)
1812 int nVals =
NVals();
1813 int dir =
static_cast<int>(mDirection);
1814 for (
int ch = 0; ch < nVals; ch++)
1816 mTrackBounds.Get()[ch] = bounds.
SubRect(EDirection(!dir), nVals, ch).
1817 GetPadded(0, -mTrackPadding * (
float) dir, -mTrackPadding * (float) !dir, -mTrackPadding);
1821 virtual void MakeStepRects(
const IRECT& bounds,
int nSteps)
1825 int dir =
static_cast<int>(mDirection);
1827 nSteps += (int) mZeroValueStepHasBounds;
1829 mStepBounds.Resize(nSteps);
1831 for (
int step = 0; step < nSteps; step++)
1833 mStepBounds.Get()[step] = bounds.
SubRect(EDirection(dir), nSteps, nSteps - 1 - step);
1837 mStepBounds.Resize(0);
1840 bool GetStepped()
const
1842 return mStepBounds.GetSize() > 0;
1846 EDirection mDirection = EDirection::Vertical;
1847 WDL_TypedBuf<IRECT> mTrackBounds;
1848 WDL_TypedBuf<IRECT> mStepBounds;
1849 WDL_PtrList<WDL_String> mTrackNames;
1851 float mTrackPadding = 0.;
1852 float mPeakSize = 1.;
1853 int mHighlightedTrack = -1;
1854 int mMouseOverTrack = -1;
1855 double mBaseValue = 0.;
1856 bool mDrawTrackFrame =
true;
1857 bool mZeroValueStepHasBounds =
true;
1869 void OnEndAnimation()
override;
1876 ISwitchControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, IActionFunction aF =
nullptr,
int numStates = 2);
1883 int GetSelectedIdx()
const {
return int(0.5 +
GetValue() * (
double) (mNumStates - 1)); }
1885 void SetStateDisabled(
int stateIdx,
bool disabled);
1886 void SetAllStatesDisabled(
bool disabled);
1887 bool GetStateDisabled(
int stateIdx)
const;
1890 WDL_TypedBuf<bool> mDisabledState;
1891 bool mMouseDown =
false;
1908 IDirBrowseControlBase(
const IRECT& bounds,
const char* extension,
bool showFileExtensions =
true,
bool scanRecursively =
true,
bool showEmptySubmenus =
false)
1910 , mExtension(extension)
1911 , mShowFileExtensions(showFileExtensions)
1912 , mScanRecursively(scanRecursively)
1913 , mShowEmptySubmenus(showEmptySubmenus)
1924 void AddPath(
const char* path,
const char* displayText);
1942 void ScanDirectory(
const char* path,
IPopupMenu& menuToAddTo);
1946 const bool mScanRecursively;
1947 const bool mShowFileExtensions;
1948 const bool mShowEmptySubmenus;
1949 int mSelectedItemIndex = -1;
1951 WDL_PtrList<WDL_String> mPaths;
1952 WDL_PtrList<WDL_String> mPathLabels;
1953 WDL_PtrList<WDL_String> mFiles;
1954 WDL_PtrList<IPopupMenu::Item> mItems;
1955 WDL_String mExtension;
1960#pragma mark - BASIC CONTROLS
1972 AttachFunc attachFunc =
nullptr, ResizeFunc resizeFunc =
nullptr)
1975 , mDrawFrame(drawFrame)
1977 mIgnoreMouse =
true;
1981 AttachFunc attachFunc =
nullptr, ResizeFunc resizeFunc =
nullptr)
1984 , mDrawFrame(drawFrame)
1986 mIgnoreMouse =
true;
1995 g.
DrawRect(COLOR_LIGHT_GRAY, mRECT, &mBlend);
1998 void SetPattern(
const IPattern& pattern)
2004 IPattern GetPattern()
const {
return mPattern; }
2015 ILambdaControl(
const IRECT& bounds, ILambdaDrawFunction drawFunc,
int animationDuration = DEFAULT_ANIMATION_DURATION,
2016 bool loopAnimation =
false,
bool startImmediately =
false,
int paramIdx = kNoParameter,
bool ignoreMouse =
false)
2018 , mDrawFunc(drawFunc)
2019 , mLoopAnimation(loopAnimation)
2020 , mAnimationDuration(animationDuration)
2022 if (startImmediately)
2025 mIgnoreMouse = ignoreMouse;
2026 mDblAsSingleClick =
true;
2032 mDrawFunc(
this, g, mRECT);
2035 virtual void OnEndAnimation() override
2037 if (mLoopAnimation && mAnimationDuration)
2040 IControl::OnEndAnimation();
2047 mMouseInfo.x = x; mMouseInfo.y = y; mMouseInfo.ms = mod;
2065 mMouseInfo.ms = mod;
2073 ILambdaDrawFunction mDrawFunc =
nullptr;
2074 bool mLoopAnimation;
2075 int mAnimationDuration;
2116 , mUseLayer(useLayer)
2136 g.
DrawSVG(mSVG, mRECT, &mBlend);
2139 void SetSVG(
const ISVG& svg)
2154 ITextControl(
const IRECT& bounds,
const char* str =
"",
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR,
bool setBoundsBasedOnStr =
false);
2161 virtual void SetStr(
const char* str);
2165 virtual void SetStrFmt(
int maxlen,
const char* fmt, ...);
2171 const char*
GetStr()
const {
return mStr.Get(); }
2179 bool mSetBoundsBasedOnStr =
false;
2189 mIgnoreMouse =
false;
2215 g.
FillRect(mBGColor, mRECT, &mBlend);
2225 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);
2242 IColor mOriginalColor, mMOColor, mCLColor;
2243 bool mClicked =
false;
2250 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);
2252 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);
2255 void SetDirty(
bool push,
int valIdx = 0)
override;
2257 WDL_String mOffText;
2271 ICaptionControl(
const IRECT& bounds,
int paramIdx,
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR,
bool showParamLabel =
true);
2276 bool mShowParamLabel;
2277 IColor mTriangleColor = COLOR_BLACK;
2278 IColor mTriangleMouseOverColor = COLOR_WHITE;
2294 IRECT mCentreLabelBounds;
2295 WDL_String mTLHCStr;
2296 WDL_String mWidthStr;
2297 WDL_String mHeightStr;
2298 IText mTLGCText = DEFAULT_TEXT.WithAlign(EAlign::Near);
2299 IText mWidthText = DEFAULT_TEXT;
2300 IText mHeightText = DEFAULT_TEXT.WithAngle(270.f);
2301 static constexpr float mInset = 10.f;
2304END_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 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 for a SOMETHING that uses IGraphics for it's 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 DrawMultiLineText(const IText &text, const char *str, IRECT &bounds, const IBlend *pBlend=0)
Draw some multi-line text to the graphics context in a specific rectangle (NanoVG only)
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.
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.