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);
192IVSlideSwitchControl::IVSlideSwitchControl(
const IRECT& bounds,
int paramIdx,
const char* label,
const IVStyle& style,
bool valueInButton, EDirection direction)
194, mDirection(direction)
203 mValueBounds = mHandleBounds;
206 pCaller->OnEndAnimation();
210 DEFAULT_ANIMATION_DURATION);
214IVSlideSwitchControl::IVSlideSwitchControl(
const IRECT& bounds, IActionFunction aF,
const char* label,
const IVStyle& style,
bool valueInButton, EDirection direction,
int numStates,
int initialState)
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);
660 DrawPointer(g, angle, cx, cy, knobHandleBounds.
W() / 2.f);
663void IVKnobControl::DrawIndicatorTrack(
IGraphics& g,
float angle,
float cx,
float cy,
float radius)
665 if (mTrackSize > 0.f)
667 g.
DrawArc(
GetColor(kX1), cx, cy, radius, angle >= mAnchorAngle ? mAnchorAngle : mAnchorAngle - (mAnchorAngle - angle), angle >= mAnchorAngle ? angle : mAnchorAngle, &mBlend, mTrackSize);
671void IVKnobControl::DrawPointer(
IGraphics& g,
float angle,
float cx,
float cy,
float radius)
673 g.
DrawRadialLine(
GetColor(kFR), cx, cy, angle, mInnerPointerFrac * radius, mOuterPointerFrac * radius, &mBlend, mPointerThickness);
678 if(mStyle.showValue && mValueBounds.
Contains(x, y))
707 if(mStyle.showValue && !mDisablePrompt)
708 mValueMouseOver = mValueBounds.
Contains(x,y);
729 return mWidgetBounds.
Contains(x, y);
750 if(!mLabelStr.GetLength())
751 mLabelStr.Set(pParam->
GetName());
755IVSliderControl::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)
758, mHandleInsideTrack(handleInsideTrack)
759, mHandleXOffset(handleXOffset)
760, mHandleYOffset(handleYOffset)
763 mText = style.valueText;
764 mHideCursorOnDrag = style.hideCursor;
765 mShape = EVShape::Ellipse;
766 mTrackSize = trackSize;
770IVSliderControl::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)
773, mHandleInsideTrack(handleInsideTrack)
774, mHandleXOffset(handleXOffset)
775, mHandleYOffset(handleYOffset)
778 mText = style.valueText;
779 mHideCursorOnDrag = style.hideCursor;
780 mShape = EVShape::Ellipse;
781 mTrackSize = trackSize;
793void IVSliderControl::DrawTrack(
IGraphics& g,
const IRECT& filledArea)
795 const float extra = mHandleInsideTrack ? mHandleSize : 0.f;
796 const IRECT adjustedTrackBounds = mDirection == EDirection::Vertical ? mTrackBounds.
GetVPadded(extra) : mTrackBounds.
GetHPadded(extra);
797 const IRECT adjustedFillBounds = mDirection == EDirection::Vertical ? filledArea.
GetVPadded(extra) : filledArea.
GetHPadded(extra);
812 DrawTrack(g, filledTrack);
816 const float offset = (mStyle.drawShadows && mShape != EVShape::Ellipse ) ? mStyle.shadowOffset * 0.5f : 0.f;
818 if(mDirection == EDirection::Vertical)
820 cx = filledTrack.
MW() + offset;
826 cy = filledTrack.
MH() + offset;
829 if(mHandleSize > 0.f)
831 DrawHandle(g, {cx+mHandleXOffset-mHandleSize, cy+mHandleYOffset-mHandleSize, cx+mHandleXOffset+mHandleSize, cy+mHandleYOffset+mHandleSize});
835void IVSliderControl::DrawHandle(
IGraphics& g,
const IRECT& bounds)
842 if(mStyle.showValue && mValueBounds.
Contains(x, y))
869 if(mStyle.showValue && !mDisablePrompt)
870 mValueMouseOver = mValueBounds.
Contains(x,y);
880 if(mDirection == EDirection::Vertical)
898 return mWidgetBounds.
Contains(x, y);
917 if(!mLabelStr.GetLength())
918 mLabelStr.Set(pParam->
GetName());
924IVRangeSliderControl::IVRangeSliderControl(
const IRECT& bounds,
const std::initializer_list<int>& params,
const char* label,
const IVStyle& style, EDirection dir,
bool onlyHandle,
float handleSize,
float trackSize)
926, mHandleSize(handleSize)
928 mTrackSize = trackSize;
939void IVRangeSliderControl::MakeTrackRects(
const IRECT& bounds)
941 for (
int ch = 0; ch <
NVals(); ch++)
943 if(mDirection == EDirection::Vertical)
950void IVRangeSliderControl::DrawTrack(
IGraphics& g,
const IRECT& r,
int chIdx)
952 bool thisTrack = mMouseOverHandle == chIdx;
955 if(mDirection == EDirection::Horizontal)
956 angle = chIdx % 2 ? 180.f : 0.f;
958 angle = chIdx % 2 ? 270.f : 90.f;
963IRECT IVRangeSliderControl::GetHandleBounds(
int trackIdx)
965 IRECT filledTrack = mTrackBounds.Get()[trackIdx].FracRect(mDirection, (
float)
GetValue(trackIdx));
967 const float offset = (mStyle.drawShadows && mShape != EVShape::Ellipse ) ? mStyle.shadowOffset * 0.5f : 0.f;
968 if(mDirection == EDirection::Vertical)
970 cx = filledTrack.
MW() + offset;
974 return IRECT(cx+mTrackSize, cy-mHandleSize, cx+(2.f*mHandleSize)+mTrackSize, cy+mHandleSize);
976 return IRECT(cx-(2.f*mHandleSize), cy-mHandleSize, cx, cy+mHandleSize);
981 cy = filledTrack.
MH() + offset;
984 return IRECT(cx-mHandleSize, cy-(2.f*mHandleSize), cx+mHandleSize, cy);
986 return IRECT(cx-mHandleSize, cy+mTrackSize, cx+mHandleSize, cy+(2.f*mHandleSize)+mTrackSize);
992 IRECT r = mTrackBounds.Get()[0];
994 DrawTrackBackground(g, r, 0);
996 for(
int i=0;i<
NVals()-1;i++)
998 IRECT filled1 = mTrackBounds.Get()[i].FracRect(mDirection, (
float)
GetValue(i));
999 IRECT filled2 = mTrackBounds.Get()[i+1].FracRect(mDirection, (
float)
GetValue(i+1));
1001 if(mDirection == EDirection::Vertical)
1002 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);
1004 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);
1007 if(mStyle.drawFrame && mDrawTrackFrame)
1018 for(
int i=0;i<
NVals();i++)
1020 bounds = GetHandleBounds(i);
1028 mMouseOverHandle = hitHandle;
1036 mMouseIsDown =
true;
1042 if(mMouseOverHandle == -1)
1045 auto minClip = mMouseOverHandle == 0 ? 0. :
GetValue(mMouseOverHandle-1);
1046 auto maxClip = mMouseOverHandle ==
NVals()-1 ? 1. :
GetValue(mMouseOverHandle+1);
1047 SnapToMouse(x, y, mDirection, mWidgetBounds, mMouseOverHandle, minClip, maxClip);
1051IVXYPadControl::IVXYPadControl(
const IRECT& bounds,
const std::initializer_list<int>& params,
const char* label,
const IVStyle& style,
float handleRadius,
bool trackClipsHandle,
bool drawCross)
1054, mHandleRadius(handleRadius)
1055, mTrackClipsHandle(trackClipsHandle)
1056, mDrawCross(drawCross)
1058 mShape = EVShape::Ellipse;
1067 if(mStyle.drawFrame)
1077 const IRECT trackBounds = mWidgetBounds.
GetPadded(mTrackClipsHandle ? 0 : -mHandleRadius);
1079 const float xpos =
static_cast<float>(
GetValue(0)) * trackBounds.
W();
1080 const float ypos =
static_cast<float>(
GetValue(1)) * trackBounds.
H();
1081 const IRECT handleBounds =
IRECT(trackBounds.L + xpos-mHandleRadius, trackBounds.B - ypos-mHandleRadius, trackBounds.L + xpos+mHandleRadius, trackBounds.B -ypos+mHandleRadius);
1083 DrawHandle(g, trackBounds, handleBounds);
1086void IVXYPadControl::DrawHandle(
IGraphics& g,
const IRECT& trackBounds,
const IRECT& handleBounds)
1088 if (mTrackClipsHandle)
1094void IVXYPadControl::DrawTrack(
IGraphics& g)
1106 if (mStyle.hideCursor)
1114 if (mStyle.hideCursor)
1124 float xn = (x - mRECT.L) / mRECT.
W();
1125 float yn = 1.f - ((y - mRECT.T) / mRECT.
H());
1142, mUseLayer(useLayer)
1144 mPoints.resize(numPoints);
1148 for(
auto plot : plots)
1159 float hdiv = mWidgetBounds.
W() /
static_cast<float>(mHorizontalDivisions);
1160 float vdiv = mWidgetBounds.
H() /
static_cast<float>(mVerticalDivisions + 2);
1164 auto drawFunc = [&](){
1167 for (
int p=0; p<mPlots.size(); p++)
1169 for (
int i=0; i<mPoints.size(); i++)
1171 auto v = mPlots[p].func((
static_cast<float>(i)/
static_cast<float>(mPoints.size() - 1)));
1172 v = (v - mMin) / (mMax-mMin);
1173 mPoints[i] =
static_cast<float>(v);
1176 g.
DrawData(mPlots[p].color, plotsRECT, mPoints.data(),
static_cast<int>(mPoints.size()),
nullptr, &mBlend, mTrackSize);
1179 if (mStyle.drawFrame)
1206 mPlots.push_back({color, func});
1209 mLayer->Invalidate();
1216, mLabelOffset(labelOffset)
1219 mIgnoreMouse =
true;
1225, mGroupName(groupName)
1232 mIgnoreMouse =
true;
1237 if(mGroupName.GetLength())
1255 const float ft = mStyle.frameThickness;
1256 const float hft = ft/2.f;
1262 auto labelR = mLabelBounds.
Empty() ? mRECT.
MW() : mLabelBounds.R;
1263 auto labelL = mLabelBounds.
Empty() ? mRECT.
MW() : mLabelBounds.L;
1265 for(
int i=0; i < nPaths; i++)
1267 const float offset = i == 0 ? 0.f : mStyle.shadowOffset;
1270 g.
PathArc(b.R - cr - hft - offset, b.T + cr + hft - offset, cr, 0.f, 90.f);
1271 g.
PathArc(b.R - cr - hft - offset, b.B - cr - hft - offset, cr, 90.f, 180.f);
1272 g.
PathArc(b.L + cr + hft - offset, b.B - cr - hft - offset, cr, 180.f, 270.f);
1273 g.
PathArc(b.L + cr + hft - offset, b.T + cr + hft - offset, cr, 270.f, 360.f);
1282 mLabelBounds.
HPad(mLabelPadding);
1283 mWidgetBounds.
Offset(0, -(mLabelBounds.
H()/2.f) - (mStyle.frameThickness/2.f), 0, 0);
1285 mLabelBounds.
Translate(mRECT.L - mLabelBounds.L + mStyle.frameThickness + mLabelOffset + cr, 0.f);
1291 mGroupName.Set(groupName);
1295 float halfLabelHeight = mLabelBounds.
H()/2.f;
1297 mRECT = unionRect.
GetPadded(padL, padT, padR, padB);
1302IVColorSwatchControl::IVColorSwatchControl(
const IRECT& bounds,
const char* label, ColorChosenFunc func,
const IVStyle& style, ECellLayout layout,
1303 const std::initializer_list<EVColor>& colorIDs,
const std::initializer_list<const char*>& labelsForIDs)
1306, mColorChosenFunc(func)
1308, mColorIdForCells(colorIDs)
1310 assert(colorIDs.size() == labelsForIDs.size());
1313 mCellRects.Resize(
static_cast<int>(mColorIdForCells.size()));
1314 mText.mAlign = mStyle.valueText.mAlign = EAlign::Far;
1316 for (
int i=0;i<colorIDs.size();i++)
1318 mLabels.Add(
new WDL_String(labelsForIDs.begin()[i]));
1330 for (
int i=0; i< mColorIdForCells.size(); i++)
1332 WDL_String* pStr = mLabels.Get(i);
1333 IRECT r = mCellRects.Get()[i];
1336 g.
DrawRect(i == mCellOver ? COLOR_GRAY : COLOR_DARK_GRAY, buttonBounds.
GetPadded(0.5f), &mBlend);
1338 if(pStr->GetLength())
1350 if(mLayout == ECellLayout::kGrid)
1355 else if (mLayout == ECellLayout::kHorizontal)
1358 columns =
static_cast<int>(mColorIdForCells.size());
1360 else if (mLayout == ECellLayout::kVertical)
1362 rows =
static_cast<int>(mColorIdForCells.size());
1366 for (
int i=0; i< mColorIdForCells.size(); i++)
1376 for (
int i=0; i<mColorIdForCells.size(); i++)
1378 if(mCellRects.Get()[i].Contains(x, y))
1400 for (
int i=0; i<mColorIdForCells.size(); i++)
1402 if(mCellRects.Get()[i].Contains(x, y))
1409 if(cellClicked > -1)
1411 EVColor vColorClicked = mColorIdForCells[cellClicked];
1415 if(mColorChosenFunc)
1416 mColorChosenFunc(cellClicked, result);
1421#pragma mark - SVG CONTROLS
1436, mColorReplacement(colorReplacement)
1442 IColor* pOnColorFill =
nullptr;
1443 IColor* pOffColorFill =
nullptr;
1444 IColor* pOnColorStroke =
nullptr;
1445 IColor* pOffColorStroke =
nullptr;
1447 switch (mColorReplacement) {
1449 case EColorReplacement::None:
1451 case EColorReplacement::Fill:
1452 pOnColorFill =
mMouseIsOver ? &mColors[3] : &mColors[1];
1453 pOffColorFill =
mMouseIsOver ? &mColors[2] : &mColors[0];
1455 case EColorReplacement::Stroke:
1456 pOnColorStroke =
mMouseIsOver ? &mColors[3] : &mColors[1];
1457 pOffColorStroke =
mMouseIsOver ? &mColors[2] : &mColors[0];
1462 g.
DrawSVG(mOnSVG, mRECT, &mBlend, pOnColorStroke, pOnColorFill);
1464 g.
DrawSVG(mOffSVG, mRECT, &mBlend, pOffColorStroke, pOffColorFill);
1486, mColorReplacement(colorReplacement)
1495, mColorReplacement(colorReplacement)
1501 IColor* pOnColorFill =
nullptr;
1502 IColor* pOffColorFill =
nullptr;
1503 IColor* pOnColorStroke =
nullptr;
1504 IColor* pOffColorStroke =
nullptr;
1506 switch (mColorReplacement) {
1507 case EColorReplacement::None:
1509 case EColorReplacement::Fill:
1510 pOnColorFill =
mMouseIsOver ? &mColors[3] : &mColors[1];
1511 pOffColorFill =
mMouseIsOver ? &mColors[2] : &mColors[0];
1513 case EColorReplacement::Stroke:
1514 pOnColorStroke =
mMouseIsOver ? &mColors[3] : &mColors[1];
1515 pOffColorStroke =
mMouseIsOver ? &mColors[2] : &mColors[0];
1520 g.
DrawSVG(mOnSVG, mRECT, &mBlend, pOnColorStroke, pOnColorFill);
1522 g.
DrawSVG(mOffSVG, mRECT, &mBlend, pOffColorStroke, pOffColorFill);
1525ISVGKnobControl::ISVGKnobControl(
const IRECT& bounds,
const ISVG& svg,
int paramIdx)
1536void ISVGKnobControl::SetSVG(
ISVG& svg)
1550 g.
DrawSVG(mSVGs[GetSelectedIdx()], mRECT, &mBlend);
1555, mHandleSVG(handleSVG)
1556, mTrackSVG(trackSVG)
1562 g.
DrawSVG(mTrackSVG, mTrackSVGBounds, &mBlend);
1568 auto trackAspectRatio = mTrackSVG.
W() / mTrackSVG.
H();
1569 auto handleAspectRatio = mHandleSVG.
W() / mHandleSVG.
H();
1570 auto handleOverTrackHeight = mHandleSVG.
H() / mTrackSVG.
H();
1572 IRECT handleBoundsAtMidPoint;
1574 if (mDirection == EDirection::Vertical)
1578 handleBoundsAtMidPoint = mRECT.
GetCentredInside(mRECT.
H() * handleAspectRatio * handleOverTrackHeight, mRECT.
H() * handleOverTrackHeight);
1579 mHandleBoundsAtMax = { handleBoundsAtMidPoint.L, mTrackSVGBounds.T, handleBoundsAtMidPoint.R, mTrackSVGBounds.T + handleBoundsAtMidPoint.
H() };
1580 mTrackBounds = mTrackSVGBounds.
GetPadded(0, -handleBoundsAtMidPoint.
H(), 0, 0);
1585 auto handleHeight = mTrackSVGBounds.
H() * handleOverTrackHeight;
1586 handleBoundsAtMidPoint = mRECT.
GetCentredInside(handleHeight * handleAspectRatio, handleHeight);
1587 auto halfHeight = handleBoundsAtMidPoint.
H() / 2.f;
1588 mHandleBoundsAtMax = { mTrackSVGBounds.R - handleBoundsAtMidPoint.
W(), mTrackSVGBounds.
MH() - halfHeight, mTrackSVGBounds.R, mTrackSVGBounds.
MH() + halfHeight };
1589 mTrackBounds = mTrackSVGBounds.
GetPadded(-handleBoundsAtMidPoint.
W(), 0, 0, 0);
1595IRECT ISVGSliderControl::GetHandleBounds(
double value)
const
1600 IRECT r = mHandleBoundsAtMax;
1602 if (mDirection == EDirection::Vertical)
1604 float offs = (1.f - (float) value) * mTrackBounds.
H();
1610 float offs = (1.f - (float) value) * mTrackBounds.
W();
1618#pragma mark - BITMAP CONTROLS
1620IBButtonControl::IBButtonControl(
float x,
float y,
const IBitmap& bitmap, IActionFunction aF)
1624 AttachIControl(
this);
1627IBButtonControl::IBButtonControl(
const IRECT& bounds,
const IBitmap& bitmap, IActionFunction aF)
1631 AttachIControl(
this);
1650 if (mBitmap.
N() > 1)
1661IBSliderControl::IBSliderControl(
float x,
float y,
float trackLength,
const IBitmap& handleBitmap,
const IBitmap& trackBitmap,
int paramIdx, EDirection dir,
double gearing)
1663 dir == EDirection::Vertical ? handleBitmap.W() : trackLength,
1664 dir == EDirection::Vertical ? trackLength : handleBitmap.H()),
1665 paramIdx, dir, gearing,
1666 float(dir == EDirection::Vertical ? handleBitmap.H() : handleBitmap.W()))
1668, mTrackBitmap(trackBitmap)
1673IBSliderControl::IBSliderControl(
const IRECT& bounds,
const IBitmap& handleBitmap,
const IBitmap& trackBitmap,
int paramIdx, EDirection dir,
double gearing)
1674:
ISliderControlBase(bounds, paramIdx, dir, gearing, float(dir == EDirection::Vertical ? handleBitmap.H() : handleBitmap.W()))
1676, mTrackBitmap(trackBitmap)
1686 g.
DrawBitmap(mBitmap, GetHandleBounds(), 1, &mBlend);
1689IRECT IBSliderControl::GetHandleBounds(
double value)
const
1694 IRECT r(mTrackBounds.L, mTrackBounds.T, mBitmap);
1696 if (mDirection == EDirection::Vertical)
1697 r.
Translate(0.f, (1.f -
static_cast<float>(value)) * (mTrackBounds.
H() -
static_cast<float>(mBitmap.
H())));
1699 r.
Translate(
static_cast<float>(value) * (mTrackBounds.
W() -
static_cast<float>(mBitmap.
W())), 0.f);
1706 if (mDirection == EDirection::Vertical)
1712 const float halfWidth =
static_cast<float>(mBitmap.
W()) / 2.f;
1722 const float halfHeight =
static_cast<float>(mBitmap.
H()) / 2.f;
1732 const double angle = -130.0 +
GetValue() * 260.0;
1736IBTextControl::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)
1739, mCharWidth(charWidth)
1740, mCharHeight(charHeight)
1741, mCharOffset(charOffset)
1742, mMultiLine(multiLine)
1750 g.
DrawBitmapedText(mBitmap, mRECT, mText, &mBlend, mStr.Get(), mVCentre, mMultiLine, mCharWidth, mCharHeight, mCharOffset);
1761 pos = stream.
Get(&d, pos);
1763 if (mResponse == EResponse::Log)
1765 auto lowPointAbs = std::fabs(mLowRangeDB);
1766 auto rangeDB = std::fabs(mHighRangeDB - mLowRangeDB);
1767 for (
auto c = d.chanOffset; c < (d.chanOffset + d.nChans); c++)
1769 auto avg = d.vals[c].second;
1771 auto linearPos = (ampValue + lowPointAbs)/rangeDB;
1777 for (
auto c = d.chanOffset; c < (d.chanOffset + d.nChans); c++)
1779 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)
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.