20using namespace igraphics;
22#pragma mark - VECTOR CONTROLS
24const IColor IVKeyboardControl::DEFAULT_BK_COLOR =
IColor(255, 70, 70, 70);
25const IColor IVKeyboardControl::DEFAULT_WK_COLOR =
IColor(255, 240, 240, 240);
26const IColor IVKeyboardControl::DEFAULT_PK_COLOR =
IColor(60, 0, 0, 0);
27const IColor IVKeyboardControl::DEFAULT_FR_COLOR = COLOR_BLACK;
28const IColor IVKeyboardControl::DEFAULT_HK_COLOR = COLOR_ORANGE;
30IVLabelControl::IVLabelControl(
const IRECT& bounds,
const char* label,
const IVStyle& style)
34 mText = style.valueText;
35 AttachIControl(
this, label);
47 g.
DrawText(mStyle.valueText, mStr.Get(), mRECT, &mBlend);
58 mText = style.valueText;
88IVSwitchControl::IVSwitchControl(
const IRECT& bounds,
int paramIdx,
const char* label,
const IVStyle& style,
bool valueInButton)
93 mText = style.valueText;
96 mText.mVAlign = mStyle.valueText.mVAlign = EVAlign::Middle;
99IVSwitchControl::IVSwitchControl(
const IRECT& bounds, IActionFunction aF,
const char* label,
const IVStyle& style,
int numStates,
bool valueInButton)
104 mText = style.valueText;
107 mText.mVAlign = mStyle.valueText.mVAlign = EVAlign::Middle;
141 return mWidgetBounds.
Contains(x, y);
154 if(!mLabelStr.GetLength())
155 mLabelStr.Set(pParam->
GetName());
159IVToggleControl::IVToggleControl(
const IRECT& bounds,
int paramIdx,
const char* label,
const IVStyle& style,
const char* offText,
const char* onText)
167IVToggleControl::IVToggleControl(
const IRECT& bounds, IActionFunction aF,
const char* label,
const IVStyle& style,
const char* offText,
const char* onText,
bool initialState)
186 g.
DrawText(mStyle.valueText, mOnText.Get(), mValueBounds, &mBlend);
188 g.
DrawText(mStyle.valueText, mOffText.Get(), mValueBounds, &mBlend);
194, mDirection(direction)
203 mValueBounds = mHandleBounds;
206 pCaller->OnEndAnimation();
210 DEFAULT_ANIMATION_DURATION);
215:
IVSwitchControl(bounds, nullptr, label, style, numStates, valueInButton)
216, mDirection(direction)
227 mValueBounds = mHandleBounds;
230 pCaller->OnEndAnimation();
235 DEFAULT_ANIMATION_DURATION);
241void IVSlideSwitchControl::UpdateRects()
243 mHandleBounds = mStartRect = mWidgetBounds.
SubRect(mDirection, mNumStates, GetSelectedIdx());
244 mEndRect = mWidgetBounds.
SubRect(mDirection, mNumStates, (GetSelectedIdx() + 1) % mNumStates);
247 mValueBounds = mHandleBounds;
256void IVSlideSwitchControl::OnEndAnimation()
260 IControl::OnEndAnimation();
275 DrawTrack(g, mWidgetBounds);
276 DrawHandle(g, mHandleBounds);
279void IVSlideSwitchControl::DrawTrack(
IGraphics& g,
const IRECT& filledArea)
285void IVSlideSwitchControl::DrawHandle(
IGraphics& g,
const IRECT& filledArea)
301, mDirection(direction)
304 mText = style.valueText;
305 mText.mAlign = mStyle.valueText.mAlign = EAlign::Center;
306 mText.mVAlign = mStyle.valueText.mVAlign = EVAlign::Middle;
309 for (
auto& option : options)
311 mTabLabels.Add(
new WDL_String(option));
318, mDirection(direction)
321 mText = style.valueText;
322 mText.mAlign = mStyle.valueText.mAlign = EAlign::Center;
323 mText.mVAlign = mStyle.valueText.mVAlign = EVAlign::Middle;
326 for (
auto& option : options)
328 mTabLabels.Add(
new WDL_String(option));
338 if(pParam && mTabLabels.GetSize() == 0)
340 for (
int i = 0; i < mNumStates; i++)
342 mTabLabels.Add(
new WDL_String(
GetParam()->GetDisplayText(i)));
345 if(!mLabelStr.GetLength())
346 mLabelStr.Set(pParam->
GetName());
357void IVTabSwitchControl::DrawButton(
IGraphics& g,
const IRECT& r,
bool pressed,
bool mouseOver, ETabSegment segment,
bool disabled)
361 case EVShape::EndsRounded:
362 if(mDirection == EDirection::Horizontal)
363 DrawPressableRectangle(g, r, pressed, mouseOver, disabled, segment == ETabSegment::Start, segment == ETabSegment::End,
false,
false);
365 DrawPressableRectangle(g, r, pressed, mouseOver,
false, disabled, segment == ETabSegment::Start,
false, segment == ETabSegment::End);
367 case EVShape::AllRounded:
368 if(mDirection == EDirection::Horizontal)
379void IVTabSwitchControl::DrawButtonText(
IGraphics& g,
const IRECT& r,
bool pressed,
bool mouseOver, ETabSegment segment,
bool disabled,
const char* textStr)
381 if (CStringHasContents(textStr))
383 g.
DrawText(mStyle.valueText, textStr, r, &mBlend);
389 int selected = GetSelectedIdx();
390 ETabSegment segment = ETabSegment::Start;
392 for (
int i = 0; i < mNumStates; i++)
394 IRECT r = mButtons.Get()[i];
397 segment = ETabSegment::Mid;
399 if (i == mNumStates-1)
400 segment = ETabSegment::End;
402 const bool isSelected = i == selected;
403 const bool isMouseOver = mMouseOverButton == i;
404 const bool isDisabled =
IsDisabled() || GetStateDisabled(i);
406 DrawButton(g, r, isSelected, isMouseOver, segment, isDisabled);
408 if (mTabLabels.Get(i))
410 DrawButtonText(g, r, isSelected, isMouseOver, segment, isDisabled, mTabLabels.Get(i)->Get());
417 for (
int i = 0; i < mNumStates; i++)
419 if (mButtons.Get()[i].Contains(x, y))
435 SetValue(((
double) index * (1./(
double) (mNumStates-1))));
455 for (
int i = 0; i < mNumStates; i++)
457 mButtons.Add(mWidgetBounds.
SubRect(mDirection, mNumStates, i));
465 return mTabLabels.Get(GetSelectedIdx())->Get();
470, mButtonSize(buttonSize)
472 mButtonAreaWidth = buttonSize * 3.f;
473 mText.mAlign = mStyle.valueText.mAlign = EAlign::Near;
474 mText.mVAlign = mStyle.valueText.mVAlign = EVAlign::Middle;
479, mButtonSize(buttonSize)
481 mButtonAreaWidth = buttonSize * 3.f;
482 mText.mAlign = mStyle.valueText.mAlign = EAlign::Near;
483 mText.mVAlign = mStyle.valueText.mVAlign = EVAlign::Middle;
488 int hit = GetSelectedIdx();
490 for (
int i = 0; i < mNumStates; i++)
492 IRECT r = mButtons.Get()[i];
496 if (mTabLabels.Get(i))
499 g.
DrawText(mStyle.valueText.WithFGColor(i == hit ?
GetColor(kON) :
GetColor(kX1)), mTabLabels.Get(i)->Get(), r, &mBlend);
506 if (mOnlyButtonsRespondToMouse)
508 for (
int i = 0; i < mNumStates; i++)
510 if (mButtons.Get()[i].GetFromLeft(mButtonAreaWidth).Contains(x, y))
526 mText = style.valueText;
527 mDisablePrompt =
false;
534 mButtonControl->SetValueStr(str.Get());
549 mButtonControl->
SetStyle(style.WithValueText(style.valueText.WithVAlign(EVAlign::Middle)));
557 mButtonControl->SetValueStr(str.Get());
564 mButtonControl->SetValueStr(pSelectedMenu->GetChosenItem()->GetText());
578 mButtonControl->SetValueStr(val.Get());
582IVKnobControl::IVKnobControl(
const IRECT& bounds,
int paramIdx,
const char* label,
const IVStyle& style,
bool valueIsEditable,
bool valueInWidget,
float a1,
float a2,
float aAnchor, EDirection direction,
double gearing,
float trackSize)
587, mAnchorAngle(aAnchor)
590 mText = style.valueText;
591 mHideCursorOnDrag = mStyle.hideCursor;
592 mShape = EVShape::Ellipse;
593 mTrackSize = trackSize;
597IVKnobControl::IVKnobControl(
const IRECT& bounds, IActionFunction aF,
const char* label,
const IVStyle& style,
bool valueIsEditable,
bool valueInWidget,
float a1,
float a2,
float aAnchor, EDirection direction,
double gearing,
float trackSize)
602, mAnchorAngle(aAnchor)
605 mText = style.valueText;
606 mHideCursorOnDrag = mStyle.hideCursor;
607 mShape = EVShape::Ellipse;
608 mTrackSize = trackSize;
625 if (mWidgetBounds.
W() > mWidgetBounds.
H())
633float IVKnobControl::GetRadius()
const
637 if (mWidgetBounds.
W() > mWidgetBounds.
H())
638 widgetRadius = (mWidgetBounds.
H()/2.f);
640 widgetRadius = (mWidgetBounds.
W()/2.f);
642 widgetRadius -= (mTrackSize/2.f);
647IRECT IVKnobControl::GetTrackBounds()
const
654 float widgetRadius = GetRadius();
655 const float cx = mWidgetBounds.
MW(), cy = mWidgetBounds.
MH();
656 IRECT knobHandleBounds = mWidgetBounds.
GetCentredInside((widgetRadius - mTrackToHandleDistance) * 2.f );
657 const float angle = mAngle1 + (
static_cast<float>(
GetValue()) * (mAngle2 - mAngle1));
658 DrawIndicatorTrack(g, angle, cx, cy, widgetRadius);
659 DrawHandle(g, knobHandleBounds);
660 DrawPointer(g, angle, cx, cy, knobHandleBounds.
W() / 2.f);
668void IVKnobControl::DrawIndicatorTrack(
IGraphics& g,
float angle,
float cx,
float cy,
float radius)
670 if (mTrackSize > 0.f)
672 g.
DrawArc(
GetColor(kX1), cx, cy, radius, angle >= mAnchorAngle ? mAnchorAngle : mAnchorAngle - (mAnchorAngle - angle), angle >= mAnchorAngle ? angle : mAnchorAngle, &mBlend, mTrackSize);
676void IVKnobControl::DrawPointer(
IGraphics& g,
float angle,
float cx,
float cy,
float radius)
678 g.
DrawRadialLine(
GetColor(kFR), cx, cy, angle, mInnerPointerFrac * radius, mOuterPointerFrac * radius, &mBlend, mPointerThickness);
683 if(mStyle.showValue && mValueBounds.
Contains(x, y))
712 if(mStyle.showValue && !mDisablePrompt)
713 mValueMouseOver = mValueBounds.
Contains(x,y);
734 return mWidgetBounds.
Contains(x, y);
755 if(!mLabelStr.GetLength())
756 mLabelStr.Set(pParam->
GetName());
760IVSliderControl::IVSliderControl(
const IRECT& bounds,
int paramIdx,
const char* label,
const IVStyle& style,
bool valueIsEditable, EDirection dir,
double gearing,
float handleSize,
float trackSize,
bool handleInsideTrack,
float handleXOffset,
float handleYOffset)
763, mHandleInsideTrack(handleInsideTrack)
764, mHandleXOffset(handleXOffset)
765, mHandleYOffset(handleYOffset)
768 mText = style.valueText;
769 mHideCursorOnDrag = style.hideCursor;
770 mShape = EVShape::Ellipse;
771 mTrackSize = trackSize;
775IVSliderControl::IVSliderControl(
const IRECT& bounds, IActionFunction aF,
const char* label,
const IVStyle& style,
bool valueIsEditable, EDirection dir,
double gearing,
float handleSize,
float trackSize,
bool handleInsideTrack,
float handleXOffset,
float handleYOffset)
778, mHandleInsideTrack(handleInsideTrack)
779, mHandleXOffset(handleXOffset)
780, mHandleYOffset(handleYOffset)
783 mText = style.valueText;
784 mHideCursorOnDrag = style.hideCursor;
785 mShape = EVShape::Ellipse;
786 mTrackSize = trackSize;
798void IVSliderControl::DrawTrack(
IGraphics& g,
const IRECT& filledArea)
800 const float extra = mHandleInsideTrack ? mHandleSize : 0.f;
801 const IRECT adjustedTrackBounds = mDirection == EDirection::Vertical ? mTrackBounds.
GetVPadded(extra) : mTrackBounds.
GetHPadded(extra);
802 const IRECT adjustedFillBounds = mDirection == EDirection::Vertical ? filledArea.
GetVPadded(extra) : filledArea.
GetHPadded(extra);
817 DrawTrack(g, filledTrack);
821 const float offset = (mStyle.drawShadows && mShape != EVShape::Ellipse ) ? mStyle.shadowOffset * 0.5f : 0.f;
823 if(mDirection == EDirection::Vertical)
825 cx = filledTrack.
MW() + offset;
831 cy = filledTrack.
MH() + offset;
834 if(mHandleSize > 0.f)
836 DrawHandle(g, {cx+mHandleXOffset-mHandleSize, cy+mHandleYOffset-mHandleSize, cx+mHandleXOffset+mHandleSize, cy+mHandleYOffset+mHandleSize});
840void IVSliderControl::DrawHandle(
IGraphics& g,
const IRECT& bounds)
847 if(mStyle.showValue && mValueBounds.
Contains(x, y))
874 if(mStyle.showValue && !mDisablePrompt)
875 mValueMouseOver = mValueBounds.
Contains(x,y);
885 if(mDirection == EDirection::Vertical)
903 return mWidgetBounds.
Contains(x, y);
922 if(!mLabelStr.GetLength())
923 mLabelStr.Set(pParam->
GetName());
929IVRangeSliderControl::IVRangeSliderControl(
const IRECT& bounds,
const std::initializer_list<int>& params,
const char* label,
const IVStyle& style, EDirection dir,
bool onlyHandle,
float handleSize,
float trackSize)
931, mHandleSize(handleSize)
933 mTrackSize = trackSize;
944void IVRangeSliderControl::MakeTrackRects(
const IRECT& bounds)
946 for (
int ch = 0; ch <
NVals(); ch++)
948 if(mDirection == EDirection::Vertical)
955void IVRangeSliderControl::DrawTrack(
IGraphics& g,
const IRECT& r,
int chIdx)
957 bool thisTrack = mMouseOverHandle == chIdx;
960 if(mDirection == EDirection::Horizontal)
961 angle = chIdx % 2 ? 180.f : 0.f;
963 angle = chIdx % 2 ? 270.f : 90.f;
968IRECT IVRangeSliderControl::GetHandleBounds(
int trackIdx)
970 IRECT filledTrack = mTrackBounds.Get()[trackIdx].FracRect(mDirection, (
float)
GetValue(trackIdx));
972 const float offset = (mStyle.drawShadows && mShape != EVShape::Ellipse ) ? mStyle.shadowOffset * 0.5f : 0.f;
973 if(mDirection == EDirection::Vertical)
975 cx = filledTrack.
MW() + offset;
979 return IRECT(cx+mTrackSize, cy-mHandleSize, cx+(2.f*mHandleSize)+mTrackSize, cy+mHandleSize);
981 return IRECT(cx-(2.f*mHandleSize), cy-mHandleSize, cx, cy+mHandleSize);
986 cy = filledTrack.
MH() + offset;
989 return IRECT(cx-mHandleSize, cy-(2.f*mHandleSize), cx+mHandleSize, cy);
991 return IRECT(cx-mHandleSize, cy+mTrackSize, cx+mHandleSize, cy+(2.f*mHandleSize)+mTrackSize);
997 IRECT r = mTrackBounds.Get()[0];
999 DrawTrackBackground(g, r, 0);
1001 for(
int i=0;i<
NVals()-1;i++)
1003 IRECT filled1 = mTrackBounds.Get()[i].FracRect(mDirection, (
float)
GetValue(i));
1004 IRECT filled2 = mTrackBounds.Get()[i+1].FracRect(mDirection, (
float)
GetValue(i+1));
1006 if(mDirection == EDirection::Vertical)
1007 g.
FillRect(
GetColor(kX1),
IRECT(filled1.L, filled1.T < filled2.T ? filled1.T : filled2.T, filled1.R, filled1.T > filled2.T ? filled1.T : filled2.T), &mBlend);
1009 g.
FillRect(
GetColor(kX1),
IRECT(filled1.R < filled2.R ? filled1.R : filled2.R, filled1.T, filled1.R > filled2.R ? filled1.R : filled2.R, filled1.B), &mBlend);
1012 if(mStyle.drawFrame && mDrawTrackFrame)
1023 for(
int i=0;i<
NVals();i++)
1025 bounds = GetHandleBounds(i);
1033 mMouseOverHandle = hitHandle;
1041 mMouseIsDown =
true;
1047 if(mMouseOverHandle == -1)
1050 auto minClip = mMouseOverHandle == 0 ? 0. :
GetValue(mMouseOverHandle-1);
1051 auto maxClip = mMouseOverHandle ==
NVals()-1 ? 1. :
GetValue(mMouseOverHandle+1);
1052 SnapToMouse(x, y, mDirection, mWidgetBounds, mMouseOverHandle, minClip, maxClip);
1056IVXYPadControl::IVXYPadControl(
const IRECT& bounds,
const std::initializer_list<int>& params,
const char* label,
const IVStyle& style,
float handleRadius,
bool trackClipsHandle,
bool drawCross)
1059, mHandleRadius(handleRadius)
1060, mTrackClipsHandle(trackClipsHandle)
1061, mDrawCross(drawCross)
1063 mShape = EVShape::Ellipse;
1072 if(mStyle.drawFrame)
1082 const IRECT trackBounds = mWidgetBounds.
GetPadded(mTrackClipsHandle ? 0 : -mHandleRadius);
1084 const float xpos =
static_cast<float>(
GetValue(0)) * trackBounds.
W();
1085 const float ypos =
static_cast<float>(
GetValue(1)) * trackBounds.
H();
1086 const IRECT handleBounds =
IRECT(trackBounds.L + xpos-mHandleRadius, trackBounds.B - ypos-mHandleRadius, trackBounds.L + xpos+mHandleRadius, trackBounds.B -ypos+mHandleRadius);
1088 DrawHandle(g, trackBounds, handleBounds);
1091void IVXYPadControl::DrawHandle(
IGraphics& g,
const IRECT& trackBounds,
const IRECT& handleBounds)
1093 if (mTrackClipsHandle)
1099void IVXYPadControl::DrawTrack(
IGraphics& g)
1111 if (mStyle.hideCursor)
1119 if (mStyle.hideCursor)
1129 float xn = (x - mRECT.L) / mRECT.
W();
1130 float yn = 1.f - ((y - mRECT.T) / mRECT.
H());
1147, mUseLayer(useLayer)
1149 mPoints.resize(numPoints);
1153 for(
auto plot : plots)
1164 float hdiv = mWidgetBounds.
W() /
static_cast<float>(mHorizontalDivisions);
1165 float vdiv = mWidgetBounds.
H() /
static_cast<float>(mVerticalDivisions + 2);
1169 auto drawFunc = [&](){
1172 for (
int p=0; p<mPlots.size(); p++)
1174 for (
int i=0; i<mPoints.size(); i++)
1176 auto v = mPlots[p].func((
static_cast<float>(i)/
static_cast<float>(mPoints.size() - 1)));
1177 v = (v - mMin) / (mMax-mMin);
1178 mPoints[i] =
static_cast<float>(v);
1181 g.
DrawData(mPlots[p].color, plotsRECT, mPoints.data(),
static_cast<int>(mPoints.size()),
nullptr, &mBlend, mTrackSize);
1184 if (mStyle.drawFrame)
1211 mPlots.push_back({color, func});
1214 mLayer->Invalidate();
1221, mLabelOffset(labelOffset)
1224 mIgnoreMouse =
true;
1230, mGroupName(groupName)
1237 mIgnoreMouse =
true;
1242 if(mGroupName.GetLength())
1260 const float ft = mStyle.frameThickness;
1261 const float hft = ft/2.f;
1267 auto labelR = mLabelBounds.
Empty() ? mRECT.
MW() : mLabelBounds.R;
1268 auto labelL = mLabelBounds.
Empty() ? mRECT.
MW() : mLabelBounds.L;
1270 for(
int i=0; i < nPaths; i++)
1272 const float offset = i == 0 ? 0.f : mStyle.shadowOffset;
1275 g.
PathArc(b.R - cr - hft - offset, b.T + cr + hft - offset, cr, 0.f, 90.f);
1276 g.
PathArc(b.R - cr - hft - offset, b.B - cr - hft - offset, cr, 90.f, 180.f);
1277 g.
PathArc(b.L + cr + hft - offset, b.B - cr - hft - offset, cr, 180.f, 270.f);
1278 g.
PathArc(b.L + cr + hft - offset, b.T + cr + hft - offset, cr, 270.f, 360.f);
1287 mLabelBounds.
HPad(mLabelPadding);
1288 mWidgetBounds.
Offset(0, -(mLabelBounds.
H()/2.f) - (mStyle.frameThickness/2.f), 0, 0);
1290 mLabelBounds.
Translate(mRECT.L - mLabelBounds.L + mStyle.frameThickness + mLabelOffset + cr, 0.f);
1296 mGroupName.Set(groupName);
1300 float halfLabelHeight = mLabelBounds.
H()/2.f;
1302 mRECT = unionRect.
GetPadded(padL, padT, padR, padB);
1307IVColorSwatchControl::IVColorSwatchControl(
const IRECT& bounds,
const char* label, ColorChosenFunc func,
const IVStyle& style, ECellLayout layout,
1308 const std::initializer_list<EVColor>& colorIDs,
const std::initializer_list<const char*>& labelsForIDs)
1311, mColorChosenFunc(func)
1313, mColorIdForCells(colorIDs)
1315 assert(colorIDs.size() == labelsForIDs.size());
1318 mCellRects.Resize(
static_cast<int>(mColorIdForCells.size()));
1319 mText.mAlign = mStyle.valueText.mAlign = EAlign::Far;
1321 for (
int i=0;i<colorIDs.size();i++)
1323 mLabels.Add(
new WDL_String(labelsForIDs.begin()[i]));
1335 for (
int i=0; i< mColorIdForCells.size(); i++)
1337 WDL_String* pStr = mLabels.Get(i);
1338 IRECT r = mCellRects.Get()[i];
1341 g.
DrawRect(i == mCellOver ? COLOR_GRAY : COLOR_DARK_GRAY, buttonBounds.
GetPadded(0.5f), &mBlend);
1343 if(pStr->GetLength())
1355 if(mLayout == ECellLayout::kGrid)
1360 else if (mLayout == ECellLayout::kHorizontal)
1363 columns =
static_cast<int>(mColorIdForCells.size());
1365 else if (mLayout == ECellLayout::kVertical)
1367 rows =
static_cast<int>(mColorIdForCells.size());
1371 for (
int i=0; i< mColorIdForCells.size(); i++)
1381 for (
int i=0; i<mColorIdForCells.size(); i++)
1383 if(mCellRects.Get()[i].Contains(x, y))
1405 for (
int i=0; i<mColorIdForCells.size(); i++)
1407 if(mCellRects.Get()[i].Contains(x, y))
1414 if(cellClicked > -1)
1416 EVColor vColorClicked = mColorIdForCells[cellClicked];
1420 if(mColorChosenFunc)
1421 mColorChosenFunc(cellClicked, result);
1426#pragma mark - SVG CONTROLS
1441, mColorReplacement(colorReplacement)
1447 IColor* pOnColorFill =
nullptr;
1448 IColor* pOffColorFill =
nullptr;
1449 IColor* pOnColorStroke =
nullptr;
1450 IColor* pOffColorStroke =
nullptr;
1452 switch (mColorReplacement) {
1454 case EColorReplacement::None:
1456 case EColorReplacement::Fill:
1457 pOnColorFill =
mMouseIsOver ? &mColors[3] : &mColors[1];
1458 pOffColorFill =
mMouseIsOver ? &mColors[2] : &mColors[0];
1460 case EColorReplacement::Stroke:
1461 pOnColorStroke =
mMouseIsOver ? &mColors[3] : &mColors[1];
1462 pOffColorStroke =
mMouseIsOver ? &mColors[2] : &mColors[0];
1467 g.
DrawSVG(mOnSVG, mRECT, &mBlend, pOnColorStroke, pOnColorFill);
1469 g.
DrawSVG(mOffSVG, mRECT, &mBlend, pOffColorStroke, pOffColorFill);
1491, mColorReplacement(colorReplacement)
1500, mColorReplacement(colorReplacement)
1506 IColor* pOnColorFill =
nullptr;
1507 IColor* pOffColorFill =
nullptr;
1508 IColor* pOnColorStroke =
nullptr;
1509 IColor* pOffColorStroke =
nullptr;
1511 switch (mColorReplacement) {
1512 case EColorReplacement::None:
1514 case EColorReplacement::Fill:
1515 pOnColorFill =
mMouseIsOver ? &mColors[3] : &mColors[1];
1516 pOffColorFill =
mMouseIsOver ? &mColors[2] : &mColors[0];
1518 case EColorReplacement::Stroke:
1519 pOnColorStroke =
mMouseIsOver ? &mColors[3] : &mColors[1];
1520 pOffColorStroke =
mMouseIsOver ? &mColors[2] : &mColors[0];
1525 g.
DrawSVG(mOnSVG, mRECT, &mBlend, pOnColorStroke, pOnColorFill);
1527 g.
DrawSVG(mOffSVG, mRECT, &mBlend, pOffColorStroke, pOffColorFill);
1530ISVGKnobControl::ISVGKnobControl(
const IRECT& bounds,
const ISVG& svg,
int paramIdx)
1541void ISVGKnobControl::SetSVG(
ISVG& svg)
1555 g.
DrawSVG(mSVGs[GetSelectedIdx()], mRECT, &mBlend);
1560, mHandleSVG(handleSVG)
1561, mTrackSVG(trackSVG)
1567 g.
DrawSVG(mTrackSVG, mTrackSVGBounds, &mBlend);
1573 auto trackAspectRatio = mTrackSVG.
W() / mTrackSVG.
H();
1574 auto handleAspectRatio = mHandleSVG.
W() / mHandleSVG.
H();
1575 auto handleOverTrackHeight = mHandleSVG.
H() / mTrackSVG.
H();
1577 IRECT handleBoundsAtMidPoint;
1579 if (mDirection == EDirection::Vertical)
1583 handleBoundsAtMidPoint = mRECT.
GetCentredInside(mRECT.
H() * handleAspectRatio * handleOverTrackHeight, mRECT.
H() * handleOverTrackHeight);
1584 mHandleBoundsAtMax = { handleBoundsAtMidPoint.L, mTrackSVGBounds.T, handleBoundsAtMidPoint.R, mTrackSVGBounds.T + handleBoundsAtMidPoint.
H() };
1585 mTrackBounds = mTrackSVGBounds.
GetPadded(0, -handleBoundsAtMidPoint.
H(), 0, 0);
1590 auto handleHeight = mTrackSVGBounds.
H() * handleOverTrackHeight;
1591 handleBoundsAtMidPoint = mRECT.
GetCentredInside(handleHeight * handleAspectRatio, handleHeight);
1592 auto halfHeight = handleBoundsAtMidPoint.
H() / 2.f;
1593 mHandleBoundsAtMax = { mTrackSVGBounds.R - handleBoundsAtMidPoint.
W(), mTrackSVGBounds.
MH() - halfHeight, mTrackSVGBounds.R, mTrackSVGBounds.
MH() + halfHeight };
1594 mTrackBounds = mTrackSVGBounds.
GetPadded(-handleBoundsAtMidPoint.
W(), 0, 0, 0);
1600IRECT ISVGSliderControl::GetHandleBounds(
double value)
const
1605 IRECT r = mHandleBoundsAtMax;
1607 if (mDirection == EDirection::Vertical)
1609 float offs = (1.f - (float) value) * mTrackBounds.
H();
1615 float offs = (1.f - (float) value) * mTrackBounds.
W();
1623#pragma mark - BITMAP CONTROLS
1625IBButtonControl::IBButtonControl(
float x,
float y,
const IBitmap& bitmap, IActionFunction aF)
1629 AttachIControl(
this);
1632IBButtonControl::IBButtonControl(
const IRECT& bounds,
const IBitmap& bitmap, IActionFunction aF)
1636 AttachIControl(
this);
1655 if (mBitmap.
N() > 1)
1666IBSliderControl::IBSliderControl(
float x,
float y,
float trackLength,
const IBitmap& handleBitmap,
const IBitmap& trackBitmap,
int paramIdx, EDirection dir,
double gearing)
1668 dir == EDirection::Vertical ? handleBitmap.W() : trackLength,
1669 dir == EDirection::Vertical ? trackLength : handleBitmap.H()),
1670 paramIdx, dir, gearing,
1671 float(dir == EDirection::Vertical ? handleBitmap.H() : handleBitmap.W()))
1673, mTrackBitmap(trackBitmap)
1678IBSliderControl::IBSliderControl(
const IRECT& bounds,
const IBitmap& handleBitmap,
const IBitmap& trackBitmap,
int paramIdx, EDirection dir,
double gearing)
1679:
ISliderControlBase(bounds, paramIdx, dir, gearing, float(dir == EDirection::Vertical ? handleBitmap.H() : handleBitmap.W()))
1681, mTrackBitmap(trackBitmap)
1691 g.
DrawBitmap(mBitmap, GetHandleBounds(), 1, &mBlend);
1694IRECT IBSliderControl::GetHandleBounds(
double value)
const
1699 IRECT r(mTrackBounds.L, mTrackBounds.T, mBitmap);
1701 if (mDirection == EDirection::Vertical)
1702 r.
Translate(0.f, (1.f -
static_cast<float>(value)) * (mTrackBounds.
H() -
static_cast<float>(mBitmap.
H())));
1704 r.
Translate(
static_cast<float>(value) * (mTrackBounds.
W() -
static_cast<float>(mBitmap.
W())), 0.f);
1711 if (mDirection == EDirection::Vertical)
1717 const float halfWidth =
static_cast<float>(mBitmap.
W()) / 2.f;
1727 const float halfHeight =
static_cast<float>(mBitmap.
H()) / 2.f;
1737 const double angle = -130.0 +
GetValue() * 260.0;
1741IBTextControl::IBTextControl(
const IRECT& bounds,
const IBitmap& bitmap,
const IText& text,
const char* str,
int charWidth,
int charHeight,
int charOffset,
bool multiLine,
bool vCenter, EBlend blend)
1744, mCharWidth(charWidth)
1745, mCharHeight(charHeight)
1746, mCharOffset(charOffset)
1747, mMultiLine(multiLine)
1755 g.
DrawBitmapedText(mBitmap, mRECT, mText, &mBlend, mStr.Get(), mVCentre, mMultiLine, mCharWidth, mCharHeight, mCharOffset);
1766 pos = stream.
Get(&d, pos);
1768 if (mResponse == EResponse::Log)
1770 auto lowPointAbs = std::fabs(mLowRangeDB);
1771 auto rangeDB = std::fabs(mHighRangeDB - mLowRangeDB);
1772 for (
auto c = d.chanOffset; c < (d.chanOffset + d.nChans); c++)
1774 auto avg = d.vals[c].second;
1776 auto linearPos = (ampValue + lowPointAbs)/rangeDB;
1782 for (
auto c = d.chanOffset; c < (d.chanOffset + d.nChans); c++)
1784 auto avg = d.vals[c].second;
A collection of IControls for common UI widgets, such as knobs, sliders, switches.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnMsgFromDelegate(int msgTag, int dataSize, const void *pData) override
Implement to receive messages sent to the control, see IEditorDelegate:SendControlMsgFromDelegate()
void OnResize() override
Called when IControl is constructed or resized using SetRect().
void Draw(IGraphics &g) override
Draw the control to the graphics context.
IBSwitchControl(float x, float y, const IBitmap &bitmap, int paramIdx=kNoParameter)
Constructs a bitmap switch control.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
A base interface to be combined with IControl for bitmap-based controls "IBControls",...
void AttachIControl(IControl *pControl)
Call in the constructor of your IBControl to link the IBitmapBase and IControl.
User-facing bitmap abstraction that you use to manage bitmap data, independant of draw class/platform...
Manages a non-owned block of memory, for receiving arbitrary message byte streams.
int Get(T *pDst, int startPos) const
Get arbitary typed data from the stream.
IContainerBase allows a control to nest sub controls and it clips the drawing of those subcontrols In...
The lowest level base class of an IGraphics control.
const char * GetGroup() const
Get the group that the control belongs to, if any.
bool mMouseIsOver
if mGraphics::mHandleMouseOver = true, this will be true when the mouse is over control.
virtual void OnMouseOver(float x, float y, const IMouseMod &mod)
Implement this method to respond to a mouseover event on this control.
virtual void SetValueFromDelegate(double value, int valIdx=0)
Set the control's value from the delegate This method is called from the class implementing the IEdit...
virtual void OnPopupMenuSelection(IPopupMenu *pSelectedMenu, int valIdx)
Implement this method to handle popup menu selection after IGraphics::CreatePopupMenu/IControlPromptU...
void SetTargetRECT(const IRECT &bounds)
Set the rectangular mouse tracking target area, within the graphics context for this control.
double GetAnimationProgress() const
Get the progress in a control's animation, in the range 0-1.
void PromptUserInput(int valIdx=0)
Call this method in response to a mouse event to create an edit box so the user can enter a value,...
virtual void SnapToMouse(float x, float y, EDirection direction, const IRECT &bounds, int valIdx=-1, double minClip=0., double maxClip=1.)
Set control value based on x, y position within a rectangle.
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.
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...
virtual void SetValue(double value, int valIdx=0)
Set one of the control's values.
double GetValue(int valIdx=0) const
Get the control's value.
void SetTargetAndDrawRECTs(const IRECT &bounds)
Set BOTH the draw rect and the target area, within the graphics context for this control.
virtual int GetValIdxForPos(float x, float y) const
Check to see which of the control's values relates to this x and y coordinate.
IAnimationFunction GetAnimationFunction()
Get the control's animation function, if it exists.
virtual void SetDirty(bool triggerAction=true, int valIdx=kNoValIdx)
Mark the control as dirty, i.e.
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.
The lowest level base class of an IGraphics context.
virtual void DrawRotatedSVG(const ISVG &svg, float destCentreX, float destCentreY, float width, float height, double angle, const IBlend *pBlend=0)
Draw an SVG image to the graphics context with rotation.
virtual void DrawRect(const IColor &color, const IRECT &bounds, const IBlend *pBlend=0, float thickness=1.f)
Draw a rectangle to the graphics context.
void DrawBitmapedText(const IBitmap &bitmap, const IRECT &bounds, IText &text, IBlend *pBlend, const char *str, bool vCenter=true, bool multiline=false, int charWidth=6, int charHeight=12, int charOffset=0)
Draws mono spaced bitmap text.
void DrawText(const IText &text, const char *str, const IRECT &bounds, const IBlend *pBlend=0)
Draw some text to the graphics context in a specific rectangle.
virtual void PathClear()=0
Clear the stack of path drawing commands.
void DrawRadialLine(const IColor &color, float cx, float cy, float angle, float rMin, float rMax, const IBlend *pBlend=0, float thickness=1.f)
Draw a radial line to the graphics context, useful for pointers on dials.
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.
virtual void DrawRotatedBitmap(const IBitmap &bitmap, float destCentreX, float destCentreY, double angle, const IBlend *pBlend=0)
Draw a bitmap (raster) image to the graphics context with rotation.
virtual void PathStroke(const IPattern &pattern, float thickness, const IStrokeOptions &options=IStrokeOptions(), const IBlend *pBlend=0)=0
Stroke the current current path.
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.
virtual bool PromptForColor(IColor &color, const char *str="", IColorPickerHandlerFunc func=nullptr)=0
Create a platform color chooser dialog.
virtual void DrawArc(const IColor &color, float cx, float cy, float r, float a1, float a2, const IBlend *pBlend=0, float thickness=1.f)
Draw an arc to the graphics context.
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 DrawData(const IColor &color, const IRECT &bounds, float *normYPoints, int nPoints, float *normXPoints=nullptr, const IBlend *pBlend=0, float thickness=1.f, const IColor *pFillColor=nullptr)
Draw a line between a collection of normalized points.
virtual void DrawGrid(const IColor &color, const IRECT &bounds, float gridSizeH, float gridSizeV, const IBlend *pBlend=0, float thickness=1.f)
Draw a grid to the graphics context.
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.
virtual void PathMoveTo(float x, float y)=0
Move the current point in the current path.
virtual void PathArc(float cx, float cy, float r, float a1, float a2, EWinding winding=EWinding::CW)=0
Add an arc to the current path.
virtual void HideMouseCursor(bool hide=true, bool lock=true)=0
Call to hide/show the mouse cursor.
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 ForControlInGroup(const char *group, IControlFunction func)
For all standard controls in the main control stack that are linked to a group, execute a function.
virtual void PathLineTo(float x, float y)=0
Add a line to the current path from the current point to the specified location.
void StartLayer(IControl *pOwner, const IRECT &r, bool cacheable=false)
Create an IGraphics layer.
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.
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.
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 OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
void GetDisplay(WDL_String &display, bool withDisplayText=true) const
Get the current textual display for the current parameter value.
const char * GetName() const
Returns the parameter's name.
void GetDisplayWithLabel(WDL_String &display, bool withDisplayText=true) const
Fills the WDL_String the value of the parameter along with the label, e.g.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnResize() override
Called when IControl is constructed or resized using SetRect().
ISVGSliderControl(const IRECT &bounds, const ISVG &handleSvg, const ISVG &trackSVG, int paramIdx=kNoParameter, EDirection dir=EDirection::Vertical, double gearing=DEFAULT_GEARING)
Constructs an ISVGSliderControl.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
ISVGSwitchControl(const IRECT &bounds, const std::initializer_list< ISVG > &svgs, int paramIdx=kNoParameter, IActionFunction aF=nullptr)
Constructs a SVG switch control.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
ISVGToggleControl(const IRECT &bounds, IActionFunction aF, const ISVG &offImage, const ISVG &onImage)
Constructs an SVG button control, with an action function.
ISender is a utility class which can be used to defer data from the realtime audio processing and sen...
A base class for slider/fader 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 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 OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
A basic control to display some text.
void OnMouseOut() override
Implement this method to respond to a mouseout 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.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
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 DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
IVGroupControl(const IRECT &bounds, const char *label="", float labelOffset=10.f, const IVStyle &style=DEFAULT_STYLE, IContainerBase::AttachFunc attachFunc=nullptr, IContainerBase::ResizeFunc resizeFunc=nullptr)
Construct the group control.
void SetBoundsBasedOnGroup(const char *groupName, float padL, float padT, float padR, float padB)
Set the bounds of the group control based on the area occupied by the controls in a particular group.
void OnResize() override
Called when IControl is constructed or resized using SetRect().
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
bool IsHit(float x, float y) const override
Hit test the control.
void OnResize() override
Called when IControl is constructed or resized using SetRect().
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
void OnMouseDblClick(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse double click event on this control.
void 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() override
Get the area for which mouse deltas will be used to calculate the amount dragging changes the 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 SetDirty(bool push, int valIdx=kNoValIdx) override
Mark the control as dirty, i.e.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
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 AddPlotFunc(const IColor &color, const IPlotFunc &func)
add a new function to the plot
IVPlotControl(const IRECT &bounds, const std::initializer_list< Plot > &funcs, int numPoints, const char *label="", const IVStyle &style=DEFAULT_STYLE, float min=-1., float max=1., bool useLayer=false)
Constructs an IVPlotControl.
std::function< double(double)> IPlotFunc
IVPlotControl passes values between 0 and 1 to this object, that are the plot normalized x values.
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover 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 Draw(IGraphics &g) override
Draw the control to the graphics context.
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
IVSlideSwitchControl(const IRECT &bounds, int paramIdx=kNoParameter, const char *label="", const IVStyle &style=DEFAULT_STYLE, bool valueInButton=false, EDirection direction=EDirection::Horizontal)
Construct a new IVSlideSwitchControl, with a parameter.
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
void SetDirty(bool push, int valIdx=kNoValIdx) override
Mark the control as dirty, i.e.
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 OnResize() override
Called when IControl is constructed or resized using SetRect().
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
void SetDirty(bool push, int valIdx=kNoValIdx) override
Mark the control as dirty, i.e.
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
void OnMouseDblClick(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse double click event on this control.
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
bool IsHit(float x, float y) const override
Hit test the control.
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
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...
bool IsHit(float x, float y) const override
Hit test the control.
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
void SetDirty(bool push, int valIdx=kNoValIdx) override
Mark the control as dirty, i.e.
void OnResize() override
Called when IControl is constructed or resized using SetRect().
void Draw(IGraphics &g) override
Draw the control to the graphics context.
A vector "tab" multi switch control.
void OnResize() override
Called when IControl is constructed or resized using SetRect().
virtual bool IsHit(float x, float y) const override
Hit test the control.
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
virtual void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
IVTabSwitchControl(const IRECT &bounds, int paramIdx=kNoParameter, const std::vector< const char * > &options={}, const char *label="", const IVStyle &style=DEFAULT_STYLE, EVShape shape=EVShape::Rectangle, EDirection direction=EDirection::Horizontal)
Constructs a vector tab switch control, linked to a parameter.
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnMouseOver(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouseover event on this control.
virtual int GetButtonForPoint(float x, float y) const
void OnInit() override
Called just prior to when the control is attached, after its delegate and graphics member variable se...
const char * GetSelectedLabelStr() const
returns the label string on the selected tab
void DrawValue(IGraphics &g, bool mouseOver) override
Draw the IVControl value text.
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
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 DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
virtual void DrawBackground(IGraphics &g, const IRECT &r) override
Draw the IVControl background (usually transparent)
void OnMouseDown(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse down event on this control.
void DrawWidget(IGraphics &g) override
Draw the IVControl main widget (override)
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 OnResize() override
Called when IControl is constructed or resized using SetRect().
void Draw(IGraphics &g) override
Draw the control to the graphics context.
void OnMouseUp(float x, float y, const IMouseMod &mod) override
Implement this method to respond to a mouse up event on this control.
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.
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 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.
const IColor & GetColor(EVColor color) const
Get value of a specific EVColor in the IVControl.
void SplashClickActionFunc(IControl *pCaller)
The splash click action function is used by IVControls to start SplashAnimationFunc.
BEGIN_IPLUG_NAMESPACE T Clip(T x, T lo, T hi)
Clips the value x between lo and hi.
static double AmpToDB(double amp)
Used to manage color data, independent of draw class/platform.
Used to manage mouse modifiers i.e.
Used to manage a rectangular area, independent of draw class/platform.
IRECT GetFromRight(float amount) const
Get a subrect of this IRECT bounded in X by 'amount' and the right edge.
IRECT GetCentredInside(const IRECT &sr) const
Get a rectangle the size of sr but with the same center point as this rectangle.
IRECT GetTranslated(float x, float y) const
Get a translated copy of this rectangle.
void 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 GetGridCell(int row, int col, int nRows, int nColumns) const
Get a subrect (by row, column) of this IRECT which is a cell in a grid of size (nRows * nColumns)
IRECT GetVPadded(float padding) const
Get a copy of this IRECT padded in the Y-axis N.B.
IRECT FracRect(EDirection layoutDir, float frac, bool fromTopOrRight=false) const
Get a new rectangle which is a fraction of this rectangle.
static IRECT LinearInterpolateBetween(const IRECT &start, const IRECT &dest, float progress)
Get a rectangle that is a linear interpolation between start and dest
IRECT FracRectHorizontal(float frac, bool rhs=false) const
Returns a new IRECT with a width that is multiplied by frac.
void HPad(float padding)
Pad this IRECT in the X-axis N.B.
void Constrain(float &x, float &y) const
Ensure the point (x,y) is inside this IRECT.
IRECT GetFromLeft(float amount) const
Get a subrect of this IRECT bounded in X by the left edge and 'amount'.
void Translate(float x, float y)
Translate this rectangle.
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 GetHPadded(float padding) const
Get a copy of this IRECT padded in the X-axis 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.
ISenderData is used to represent a typed data packet, that may contain values for multiple channels.
IText is used to manage font and text/text entry style for a piece of text on the UI,...
A struct encapsulating a set of properties used to configure IVControls.