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#pragma mark - Accessibility
552#if defined VST3_API || defined VST3C_API
553 Steinberg::tresult PLUGIN_API executeMenuItem (Steinberg::int32 tag)
override {
OnContextSelection(tag);
return Steinberg::kResultOk; }
556#pragma mark - IControl Member variables
563 template<
typename T,
typename... Args>
566 if (valIdx > kNoValIdx)
567 func(valIdx, args...);
570 const int nVals =
NVals();
571 for (
int v = 0; v < nVals; v++)
584 int mTextEntryLength = DEFAULT_TEXT_ENTRY_LEN;
587 bool mDisabled =
false;
588 bool mDisablePrompt =
true;
589 bool mDblAsSingleClick =
false;
590 bool mMouseOverWhenDisabled =
false;
591 bool mMouseEventsWhenDisabled =
false;
592 bool mIgnoreMouse =
false;
593 bool mWantsMidi =
false;
594 bool mWantsMultiTouch =
false;
595 bool mPromptShowsParamLabel =
false;
600 IColor mPTHighlightColor = COLOR_RED;
601 bool mPTisHighlighted =
false;
603 WDL_String mAccessibleLabel;
622 void SetNVals(
int nVals)
628#if defined VST3_API || defined VST3C_API
631 DEF_INTERFACE (IContextMenuTarget)
632 END_DEFINE_INTERFACES (FObject)
633 REFCOUNT_METHODS(FObject)
640 IActionFunction mActionFunc =
nullptr;
641 IActionFunction mAnimationEndActionFunc =
nullptr;
642 IAnimationFunction mAnimationFunc =
nullptr;
643 TimePoint mAnimationStartTime;
644 Milliseconds mAnimationDuration;
645 std::vector<ParamTuple> mVals { {kNoParameter, 0.} };
646 std::unordered_map<EGestureType, IGestureFunc> mGestureFuncs;
647 EGestureType mLastGesture = EGestureType::Unknown;
650#pragma mark - Base Controls
667 IContainerBase(
const IRECT& bounds,
int paramIdx = kNoParameter, IActionFunction actionFunc =
nullptr)
668 :
IControl(bounds, paramIdx, actionFunc)
671 IContainerBase(
const IRECT& bounds,
const std::initializer_list<int>& params, IActionFunction actionFunc =
nullptr)
672 :
IControl(bounds, params, actionFunc)
681 , mAttachFunc(attachFunc)
682 , mResizeFunc(resizeFunc)
687 void SetAttachFunc(AttachFunc attachFunc)
689 mAttachFunc = attachFunc;
692 void SetResizeFunc(ResizeFunc resizeFunc)
694 mResizeFunc = resizeFunc;
704 mChildren.Empty(
false);
710 mAttachFunc(
this, mRECT);
717 if (mResizeFunc && mChildren.GetSize())
718 mResizeFunc(
this, mRECT);
723 ForAllChildrenFunc([disable](
int childIdx,
IControl* pChild) {
732 ForAllChildrenFunc([hide](
int childIdx,
IControl* pChild) {
739 IControl* AddChildControl(
IControl* pControl,
int ctrlTag = kNoTag,
const char* group =
"")
741 pControl->SetParent(
this);
742 return mChildren.Add(
GetUI()->AttachControl(pControl, ctrlTag, group));
745 void RemoveChildControl(
IControl* pControl)
747 pControl->SetParent(
nullptr);
748 mChildren.DeletePtr(pControl,
false);
754 return mChildren.Get(idx);
757 int NChildren()
const {
return mChildren.GetSize(); }
759 void ForAllChildrenFunc(std::function<
void(
int childIdx,
IControl* pControl)> func)
761 for (
int i=0; i<mChildren.GetSize(); i++)
763 func(i, mChildren.Get(i));
768 AttachFunc mAttachFunc =
nullptr;
769 ResizeFunc mResizeFunc =
nullptr;
770 WDL_PtrList<IControl> mChildren;
798 i = 1 + int(0.5 + mControl->
GetValue() *
static_cast<double>(mBitmap.
N() - 1));
799 i =
Clip(i, 1, mBitmap.
N());
820 : mLabelInWidget(labelInWidget)
821 , mValueInWidget(valueInWidget)
834 mLabelStr.Set(label);
845 mStyle.colorSpec.mColors[
static_cast<int>(colorIdx)] = color;
853 mStyle.colorSpec = spec;
859 return mStyle.colorSpec.
GetColor(color);
862 void SetLabelStr(
const char* label) { mLabelStr.Set(label); mControl->
SetDirty(
false);
OnStyleChanged(); }
863 const char* GetLabelStr()
const {
return mLabelStr.Get(); }
864 const char* GetValueStr()
const {
return mValueStr.Get(); }
865 void SetValueStr(
const char* value) { mValueStr.Set(value); mControl->
SetDirty(
false);
OnStyleChanged(); }
870 void SetRoundness(
float roundness) { mStyle.roundness =
Clip(roundness, 0.f, 1.f); mControl->
SetDirty(
false);
OnStyleChanged(); }
872 void SetDrawShadows(
bool draw) { mStyle.drawShadows = draw; mControl->
SetDirty(
false);
OnStyleChanged(); }
874 void SetShadowOffset(
float offset) { mStyle.shadowOffset = offset; mControl->
SetDirty(
false);
OnStyleChanged(); }
875 void SetFrameThickness(
float thickness) { mStyle.frameThickness = thickness; mControl->
SetDirty(
false);
OnStyleChanged(); }
876 void SetSplashRadius(
float radius) { mSplashRadius = radius * mMaxSplashRadius;
OnStyleChanged(); }
877 void SetSplashPoint(
float x,
float y) { mSplashPoint.x = x; mSplashPoint.y = y;
OnStyleChanged(); }
898 if (mStyle.drawFrame)
899 handleBounds.
Pad(- 0.5f * mStyle.frameThickness);
901 if (mStyle.drawShadows)
902 handleBounds.
Offset(mStyle.shadowOffset, 0, -mStyle.shadowOffset, -mStyle.shadowOffset);
912 if (bounds.
W() < bounds.
H())
913 return mStyle.roundness * (bounds.
W() / 2.f);
915 return mStyle.roundness * (bounds.
H() / 2.f);
918 IRECT GetWidgetBounds()
const {
return mWidgetBounds; }
919 IRECT GetLabelBounds()
const {
return mLabelBounds; }
920 IRECT GetValueBounds()
const {
return mValueBounds; }
948 if (mLabelBounds.
H() && mStyle.showLabel)
951 g.
DrawText(mStyle.labelText, mLabelStr.Get(), mLabelBounds, &blend);
959 g.
FillRect(COLOR_TRANSLUCENT, mValueBounds);
961 if (mStyle.showValue)
964 g.
DrawText(mStyle.valueText, mValueStr.Get(), mValueBounds, &blend);
979 case EVShape::Ellipse:
982 case EVShape::Rectangle:
985 case EVShape::Triangle:
988 case EVShape::EndsRounded:
991 case EVShape::AllRounded:
1007 IRECT handleBounds = bounds;
1011 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1013 if(!pressed && !disabled && mStyle.drawShadows)
1066 if (mStyle.drawFrame)
1078 bool rtl =
true,
bool rtr =
true,
bool rbl =
true,
bool rbr =
true)
1081 IRECT centreBounds = handleBounds.
GetPadded(-mStyle.shadowOffset);
1082 IRECT shadowBounds = handleBounds.
GetTranslated(mStyle.shadowOffset, mStyle.shadowOffset);
1084 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1087 const float tlr = rtl ? cR : 0.f;
1088 const float trr = rtr ? cR : 0.f;
1089 const float blr = rbl ? cR : 0.f;
1090 const float brr = rbr ? cR : 0.f;
1117 if (mStyle.drawShadows)
1149 if (mStyle.drawFrame)
1152 return handleBounds;
1162 float x1, x2, x3, y1, y2, y3;
1164 float theta = DegToRad(angle);
1169 float xT = handleBounds.L + handleBounds.
W() * 0.5f;
1170 float yT = handleBounds.T + handleBounds.
H() * 0.5f;
1174 float c = cosf(theta);
1175 float s = sinf(theta);
1176 x1 = centered.L * c - centered.B * s + xT;
1177 y1 = centered.L * s + centered.B * c + yT;
1178 x2 = centered.
MW() * c - centered.T * s + xT;
1179 y2 = centered.
MW() * s + centered.T * c + yT;
1180 x3 = centered.R * c - centered.B * s + xT;
1181 y3 = centered.R * s + centered.B * c + yT;
1184 const float contrast = disabled ? -GRAYED_ALPHA : 0.f;
1191 if (mStyle.drawShadows)
1193 x2 + mStyle.shadowOffset, y2 + mStyle.shadowOffset,
1194 x3 + mStyle.shadowOffset, y3 + mStyle.shadowOffset, &blend);
1205 if (mStyle.drawFrame)
1208 return handleBounds;
1217 IRECT clickableArea = parent;
1221 if(mStyle.showLabel && CStringHasContents(mLabelStr.Get()))
1224 mControl->
GetUI()->
MeasureText(mStyle.labelText, mLabelStr.Get(), textRect);
1226 switch (mStyle.labelOrientation)
1228 case EOrientation::North:
1231 case EOrientation::East:
1234 case EOrientation::South:
1237 case EOrientation::West:
1243 mLabelBounds =
IRECT();
1245 if (!mLabelBounds.
Empty())
1247 switch (mStyle.labelOrientation)
1249 case EOrientation::North:
1252 case EOrientation::East:
1255 case EOrientation::South:
1258 case EOrientation::West:
1265 if (mStyle.showValue && !mValueInWidget)
1269 if(CStringHasContents(mValueStr.Get()))
1270 mControl->
GetUI()->
MeasureText(mStyle.valueText, mValueStr.Get(), textRect);
1272 const float valueDisplayWidth = textRect.
W() * mValueDisplayFrac;
1274 switch (mStyle.valueText.mVAlign)
1276 case EVAlign::Middle:
1280 case EVAlign::Bottom:
1303 mLabelBounds = mWidgetBounds;
1306 mValueBounds = mWidgetBounds;
1308 return clickableArea;
1314 bool mLabelInWidget =
false;
1315 bool mValueInWidget =
false;
1316 float mSplashRadius = 0.f;
1317 IVec2 mSplashPoint = {0.f, 0.f};
1318 float mMaxSplashRadius = 50.f;
1319 float mTrackSize = 2.f;
1320 float mValueDisplayFrac = 0.66f;
1321 IRECT mWidgetBounds;
1324 WDL_String mLabelStr;
1325 WDL_String mValueStr;
1326 EVShape mShape = EVShape::Rectangle;
1341 TimePoint startTime;
1343 TrackedTouch(
int index,
float x,
float y,
float radius, TimePoint time)
1344 : index(index), x(x), y(y), sx(x), sy(y), radius(radius), startTime(time)
1353 virtual void AddTouch(ITouchID touchID,
float x,
float y,
float radius)
1356 for (
int i = 0; i < MAX_TOUCHES; i++)
1358 if (mTouchStatus[i] ==
false)
1361 mTouchStatus[i] =
true;
1366 if(NTrackedTouches() < MAX_TOUCHES)
1367 mTrackedTouches.insert(std::make_pair(touchID, TrackedTouch(touchIndex, x, y, radius, std::chrono::high_resolution_clock::now())));
1370 virtual void ReleaseTouch(ITouchID touchID)
1372 mTouchStatus[GetTouchWithIdentifier(touchID)->index] =
false;
1373 mTrackedTouches.erase(touchID);
1376 virtual void UpdateTouch(ITouchID touchID,
float x,
float y,
float radius)
1378 mTrackedTouches[touchID].x = x;
1379 mTrackedTouches[touchID].y = y;
1380 mTrackedTouches[touchID].radius = radius;
1383 void ClearAllTouches()
1385 mTrackedTouches.clear();
1386 memset(mTouchStatus, 0, MAX_TOUCHES *
sizeof(
bool));
1389 int NTrackedTouches()
const
1391 return static_cast<int>(mTrackedTouches.size());
1394 TrackedTouch* GetTouch(
int index)
1396 auto itr = std::find_if(mTrackedTouches.begin(), mTrackedTouches.end(),
1397 [index](
auto element) {
1398 return(element.second.index == index);
1401 if(itr != mTrackedTouches.end())
1402 return &itr->second;
1407 TrackedTouch* GetTouchWithIdentifier(ITouchID touchID)
1409 auto itr = mTrackedTouches.find(touchID);
1411 if(itr != mTrackedTouches.end())
1412 return &itr->second;
1418 static constexpr int MAX_TOUCHES = 10;
1419 std::unordered_map<ITouchID, TrackedTouch> mTrackedTouches;
1420 bool mTouchStatus[MAX_TOUCHES] = { 0 };
1427 IKnobControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, EDirection direction = EDirection::Vertical,
double gearing = DEFAULT_GEARING)
1429 , mDirection(direction)
1432 mAccessibleRole = EAccessibleRole::Slider;
1440 void SetGearing(
double gearing) { mGearing = gearing; }
1441 bool IsFineControl(
const IMouseMod& mod,
bool wheel)
const;
1448 bool mHideCursorOnDrag =
true;
1449 EDirection mDirection;
1451 bool mMouseDown =
false;
1452 double mMouseDragValue = 0.0;
1459 ISliderControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, EDirection dir = EDirection::Vertical,
double gearing = DEFAULT_GEARING,
float handleSize = 0.f);
1460 ISliderControlBase(
const IRECT& bounds, IActionFunction aF =
nullptr, EDirection dir = EDirection::Vertical,
double gearing = DEFAULT_GEARING,
float handleSize = 0.f);
1468 void SetGearing(
double gearing) { mGearing = gearing; }
1469 bool IsFineControl(
const IMouseMod& mod,
bool wheel)
const;
1472 bool mHideCursorOnDrag =
true;
1473 EDirection mDirection;
1477 bool mMouseDown =
false;
1478 double mMouseDragValue;
1487 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 = {})
1493 SetNVals(maxNTracks);
1494 mTrackBounds.Resize(maxNTracks);
1496 for (
int i=0; i<maxNTracks; i++)
1501 if(trackNames.size())
1503 assert(trackNames.size() == maxNTracks);
1505 for (
auto& trackName : trackNames)
1507 mTrackNames.Add(
new WDL_String(trackName));
1514 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 = {})
1520 SetNVals(maxNTracks);
1521 mTrackBounds.Resize(maxNTracks);
1523 for (
int i = 0; i < maxNTracks; i++)
1528 if(trackNames.size())
1530 assert(trackNames.size() == maxNTracks);
1532 for (
auto& trackName : trackNames)
1534 mTrackNames.Add(
new WDL_String(trackName));
1541 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 = {})
1547 int maxNTracks =
static_cast<int>(params.size());
1548 SetNVals(maxNTracks);
1549 mTrackBounds.Resize(maxNTracks);
1552 for (
auto param : params)
1557 if(trackNames.size())
1559 assert(trackNames.size() == params.size());
1561 for (
auto& trackName : trackNames)
1563 mTrackNames.Add(
new WDL_String(trackName));
1572 mTrackNames.Empty(
true);
1583 mMouseOverTrack = -1;
1590 MakeTrackRects(mWidgetBounds);
1591 MakeStepRects(mWidgetBounds, mNSteps);
1597 int nVals =
NVals();
1599 for (
auto v = 0; v < nVals; v++)
1601 if (mTrackBounds.Get()[v].Contains(x, y))
1612 const int nVals =
NVals();
1614 for (
int ch = 0; ch < nVals; ch++)
1616 DrawTrack(g, mTrackBounds.Get()[ch], ch);
1625 std::vector<int> paramIdsForGroup;
1627 for (
auto p = 0; p < nParams; p++)
1631 if(strcmp(pParam->
GetGroup(), paramGroup) == 0)
1633 paramIdsForGroup.push_back(p);
1644 int nParams =
static_cast<int>(paramIds.size());
1647 mTrackBounds.Resize(nParams);
1650 for (
auto param : paramIds)
1656 const int range =
static_cast<int>(pFirstParam->
GetRange() / pFirstParam->
GetStep());
1657 mZeroValueStepHasBounds = !(range == 1);
1658 SetNSteps(pFirstParam->
GetStepped() ? range : 0);
1661 void SetNTracks(
int nTracks)
1664 mTrackBounds.Resize(nTracks);
1668 void SetBaseValue(
double value)
1673 void SetTrackPadding(
float value)
1678 void SetPeakSize(
float value)
1683 void SetNSteps(
int nSteps)
1688 void SetHighlightedTrack(
int highlightIdx)
1690 mHighlightedTrack = highlightIdx;
1694 void SetZeroValueStepHasBounds(
bool val)
1696 mZeroValueStepHasBounds = val;
1700 bool HasTrackNames()
const
1702 return mTrackNames.GetSize() > 0;
1707 if (mAccessibleRole == EAccessibleRole::None)
1710 const int nVals =
NVals();
1713 if (nVals == 1 || mAccessibleRole != EAccessibleRole::Slider)
1715 nodes.emplace_back();
1720 nodes.emplace_back();
1723 for (
int ch = 0; ch < nVals; ch++)
1725 nodes.emplace_back();
1728 node.bounds = mTrackBounds.Get()[ch];
1730 if (CStringHasContents(GetTrackName(ch)))
1731 node.label.Set(GetTrackName(ch));
1733 node.label.Set(
GetParam(ch)->GetName());
1735 node.label.SetFormatted(64,
"%s %i", nodes[0].label.Get(), ch + 1);
1739 const char* GetTrackName(
int chIdx)
const
1741 WDL_String* pStr = mTrackNames.Get(chIdx);
1742 return pStr ? pStr->Get() :
"";
1745 void SetTrackName(
int chIdx,
const char* newName)
1747 assert(chIdx >= 0 && chIdx < mTrackNames.GetSize());
1749 if(chIdx >= 0 && chIdx < mTrackNames.GetSize())
1751 mTrackNames.Get(chIdx)->Set(newName);
1762 if(mDirection == EDirection::Horizontal)
1771 DrawTrackBackground(g, r, chIdx);
1774 DrawTrackName(g, r, chIdx);
1776 const float trackPos =
static_cast<float>(
GetValue(chIdx));
1778 const bool stepped = GetStepped();
1781 const float bv =
static_cast<float>(mBaseValue);
1785 if(mDirection == EDirection::Vertical)
1787 fillRect =
IRECT(r.L,
1788 trackPos < bv ? r.B - r.
H() * bv : r.B - r.
H() * trackPos,
1790 trackPos < bv ? r.B - r.
H() * trackPos : r.B - r.
H() * bv);
1794 fillRect =
IRECT(trackPos < bv ? r.L + r.
W() * trackPos : r.L + r.
W() * bv,
1796 trackPos < bv ? r.L + r.
W() * bv : r.L + r.
W() * trackPos,
1802 fillRect = r.
FracRect(mDirection, trackPos);
1804 if(stepped && mZeroValueStepHasBounds && trackPos == 0.f)
1806 if(mDirection == EDirection::Vertical)
1807 fillRect.T = mStepBounds.Get()[0].T;
1813 int step = GetStepIdxForPos(fillRect.R, fillRect.T);
1817 if(mDirection == EDirection::Horizontal)
1819 fillRect.L = mStepBounds.Get()[step].L;
1820 fillRect.R = mStepBounds.Get()[step].R;
1824 fillRect.T = mStepBounds.Get()[step].T;
1825 fillRect.B = mStepBounds.Get()[step].B;
1829 if(mZeroValueStepHasBounds ||
GetValue(chIdx) > 0.)
1838 if(mDirection == EDirection::Vertical)
1840 peakRect =
IRECT(fillRect.L,
1841 trackPos < mBaseValue ? fillRect.B : fillRect.T,
1843 trackPos < mBaseValue ? fillRect.B - mPeakSize: fillRect.T + mPeakSize);
1847 peakRect =
IRECT(trackPos < mBaseValue ? fillRect.L + mPeakSize : fillRect.R - mPeakSize,
1849 trackPos < mBaseValue ? fillRect.L : fillRect.R,
1853 DrawPeak(g, peakRect, chIdx, trackPos > mBaseValue);
1856 if(mStyle.drawFrame && mDrawTrackFrame)
1860 virtual void DrawTrackBackground(
IGraphics& g,
const IRECT& r,
int chIdx)
1862 g.
FillRect(chIdx == mHighlightedTrack ? this->
GetColor(kHL) : COLOR_TRANSPARENT, r);
1865 virtual void DrawTrackName(
IGraphics& g,
const IRECT& r,
int chIdx)
1867 g.
DrawText(mText, GetTrackName(chIdx), r);
1879 if(chIdx == mMouseOverTrack)
1883 virtual void DrawPeak(
IGraphics& g,
const IRECT& r,
int chIdx,
bool aboveBaseValue)
1888 int GetStepIdxForPos(
float x,
float y)
const
1890 int nSteps = mStepBounds.GetSize();
1892 for (
auto v = 0; v < nSteps; v++)
1894 if (mStepBounds.Get()[v].ContainsEdge(x, y))
1903 virtual void MakeTrackRects(
const IRECT& bounds)
1905 int nVals =
NVals();
1906 int dir =
static_cast<int>(mDirection);
1907 for (
int ch = 0; ch < nVals; ch++)
1909 mTrackBounds.Get()[ch] = bounds.
SubRect(EDirection(!dir), nVals, ch).
1910 GetPadded(0, -mTrackPadding * (
float) dir, -mTrackPadding * (float) !dir, -mTrackPadding);
1914 virtual void MakeStepRects(
const IRECT& bounds,
int nSteps)
1918 int dir =
static_cast<int>(mDirection);
1920 nSteps += (int) mZeroValueStepHasBounds;
1922 mStepBounds.Resize(nSteps);
1924 for (
int step = 0; step < nSteps; step++)
1926 mStepBounds.Get()[step] = bounds.
SubRect(EDirection(dir), nSteps, nSteps - 1 - step);
1930 mStepBounds.Resize(0);
1933 bool GetStepped()
const
1935 return mStepBounds.GetSize() > 0;
1939 EDirection mDirection = EDirection::Vertical;
1940 WDL_TypedBuf<IRECT> mTrackBounds;
1941 WDL_TypedBuf<IRECT> mStepBounds;
1942 WDL_PtrList<WDL_String> mTrackNames;
1944 float mTrackPadding = 0.;
1945 float mPeakSize = 1.;
1946 int mHighlightedTrack = -1;
1947 int mMouseOverTrack = -1;
1948 double mBaseValue = 0.;
1949 bool mDrawTrackFrame =
true;
1950 bool mZeroValueStepHasBounds =
true;
1962 void OnEndAnimation()
override;
1969 ISwitchControlBase(
const IRECT& bounds,
int paramIdx = kNoParameter, IActionFunction aF =
nullptr,
int numStates = 2);
1978 int GetSelectedIdx()
const {
return int(0.5 +
GetValue() * (
double) (mNumStates - 1)); }
1980 void SetStateDisabled(
int stateIdx,
bool disabled);
1981 void SetAllStatesDisabled(
bool disabled);
1982 bool GetStateDisabled(
int stateIdx)
const;
1985 WDL_TypedBuf<bool> mDisabledState;
1986 bool mMouseDown =
false;
2003 IDirBrowseControlBase(
const IRECT& bounds,
const char* extension,
bool showFileExtensions =
true,
bool scanRecursively =
true,
bool showEmptySubmenus =
false)
2005 , mExtension(extension)
2006 , mShowFileExtensions(showFileExtensions)
2007 , mScanRecursively(scanRecursively)
2008 , mShowEmptySubmenus(showEmptySubmenus)
2019 void AddPath(
const char* path,
const char* displayText);
2037 void ScanDirectory(
const char* path,
IPopupMenu& menuToAddTo);
2041 const bool mScanRecursively;
2042 const bool mShowFileExtensions;
2043 const bool mShowEmptySubmenus;
2044 int mSelectedItemIndex = -1;
2046 WDL_PtrList<WDL_String> mPaths;
2047 WDL_PtrList<WDL_String> mPathLabels;
2048 WDL_PtrList<WDL_String> mFiles;
2049 WDL_PtrList<IPopupMenu::Item> mItems;
2050 WDL_String mExtension;
2055#pragma mark - BASIC CONTROLS
2067 AttachFunc attachFunc =
nullptr, ResizeFunc resizeFunc =
nullptr)
2070 , mDrawFrame(drawFrame)
2072 mIgnoreMouse =
true;
2076 AttachFunc attachFunc =
nullptr, ResizeFunc resizeFunc =
nullptr)
2079 , mDrawFrame(drawFrame)
2081 mIgnoreMouse =
true;
2090 g.
DrawRect(COLOR_LIGHT_GRAY, mRECT, &mBlend);
2093 void SetPattern(
const IPattern& pattern)
2099 IPattern GetPattern()
const {
return mPattern; }
2110 ILambdaControl(
const IRECT& bounds, ILambdaDrawFunction drawFunc,
int animationDuration = DEFAULT_ANIMATION_DURATION,
2111 bool loopAnimation =
false,
bool startImmediately =
false,
int paramIdx = kNoParameter,
bool ignoreMouse =
false)
2113 , mDrawFunc(drawFunc)
2114 , mLoopAnimation(loopAnimation)
2115 , mAnimationDuration(animationDuration)
2117 if (startImmediately)
2120 mIgnoreMouse = ignoreMouse;
2121 mDblAsSingleClick =
true;
2127 mDrawFunc(
this, g, mRECT);
2130 virtual void OnEndAnimation() override
2132 if (mLoopAnimation && mAnimationDuration)
2135 IControl::OnEndAnimation();
2142 mMouseInfo.x = x; mMouseInfo.y = y; mMouseInfo.ms = mod;
2160 mMouseInfo.ms = mod;
2168 ILambdaDrawFunction mDrawFunc =
nullptr;
2169 bool mLoopAnimation;
2170 int mAnimationDuration;
2211 , mUseLayer(useLayer)
2231 g.
DrawSVG(mSVG, mRECT, &mBlend);
2234 void SetSVG(
const ISVG& svg)
2249 ITextControl(
const IRECT& bounds,
const char* str =
"",
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR,
bool setBoundsBasedOnStr =
false);
2257 virtual void SetStr(
const char* str);
2261 virtual void SetStrFmt(
int maxlen,
const char* fmt, ...);
2267 const char*
GetStr()
const {
return mStr.Get(); }
2275 bool mSetBoundsBasedOnStr =
false;
2285 mIgnoreMouse =
false;
2311 g.
FillRect(mBGColor, mRECT, &mBlend);
2321 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);
2338 IColor mOriginalColor, mMOColor, mCLColor;
2339 bool mClicked =
false;
2346 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);
2348 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);
2351 void SetDirty(
bool push,
int valIdx = 0)
override;
2353 WDL_String mOffText;
2367 ICaptionControl(
const IRECT& bounds,
int paramIdx,
const IText& text = DEFAULT_TEXT,
const IColor& BGColor = DEFAULT_BGCOLOR,
bool showParamLabel =
true);
2372 bool mShowParamLabel;
2373 IColor mTriangleColor = COLOR_BLACK;
2374 IColor mTriangleMouseOverColor = COLOR_WHITE;
2375 IRECT mTriangleRect;
2390 IRECT mCentreLabelBounds;
2391 WDL_String mTLHCStr;
2392 WDL_String mWidthStr;
2393 WDL_String mHeightStr;
2394 IText mTLGCText = DEFAULT_TEXT.WithAlign(EAlign::Near);
2395 IText mWidthText = DEFAULT_TEXT;
2396 IText mHeightText = DEFAULT_TEXT.WithAngle(270.f);
2397 static constexpr float mInset = 10.f;
2400END_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
void StepValueFromUserInput(int valIdx, int nSteps)
Helper for OnAccessibleAction().
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.
void InitAccessibleNode(IAccessibleNode &node, EAccessibleRole role, int valIdx=0)
Helper for GetAccessibleNodes().
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.
EAccessibleRole GetAccessibleRole() const
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.
const char * GetAccessibleLabel() const
virtual bool OnAccessibleAction(EAccessibleAction action, int nodeIdx=0, double value=1.)
Perform an action requested by assistive technology or keyboard navigation.
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.
void SetNonNormalizedValueFromUserInput(int valIdx, double value)
Helper for OnAccessibleAction().
virtual void SetValueToDefault(int valIdx=kNoValIdx)
Set one or all of the control's values to the default value of the associated parameter.
IControl * SetAccessibleRole(EAccessibleRole role)
Set the role that the control reports to assistive technology.
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.
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.
IControl * SetAccessibleLabel(const char *str)
Set the label that the control reports to assistive technology.
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.
virtual void GetAccessibleNodes(IAccessibleNodeList &nodes)
Describe the control for assistive technology (e.g.
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 GetAccessibleNodes(IAccessibleNodeList &nodes) override
Describe the control for assistive technology (e.g.
bool OnAccessibleAction(EAccessibleAction action, int nodeIdx=0, double value=1.) override
Perform an action requested by assistive technology or keyboard navigation.
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 GetAccessibleNodes(IAccessibleNodeList &nodes) override
Describe the control for assistive technology (e.g.
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)
void GetAccessibleNodes(IAccessibleNodeList &nodes) override
Describe the control for assistive technology (e.g.
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 ...
std::vector< IAccessibleNode > IAccessibleNodeList
A list of IAccessibleNode.
void DefaultClickActionFunc(IControl *pCaller)
A click action function that triggers the default animation function for DEFAULT_ANIMATION_DURATION.
EAccessibleAction
An action that can be performed on a control via assistive technology or keyboard navigation.
std::unique_ptr< ILayer > ILayerPtr
ILayerPtr is a managed pointer for transferring the ownership of layers.
EAccessibleRole
The semantic role of a control (or part of a control), reported to assistive technology such as scree...
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 describe a control (or a part of a control) to assistive technology.
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.