put back IPlugMouseTestControls.h
[wdl/wdl-ol.git] / IPlugExamples / MoreExamples / IPlugMouseTest / IPlugMouseTestControls.h
blob165b0188795c81fa15693b6f04c1ed85ca224ab3
1 class IXYPad : public IControl
3 public:
4 IXYPad(IPlugBase *pPlug, IRECT pR, int handleRadius, int paramA, int paramB)
5 : IControl(pPlug, pR)
6 , mHandleRadius(handleRadius)
7 , mHandleColor(COLOR_WHITE)
9 AddAuxParam(paramA);
10 AddAuxParam(paramB);
13 bool Draw(IGraphics* pGraphics)
15 double xpos = GetAuxParam(0)->mValue * mRECT.W();
16 double ypos = GetAuxParam(1)->mValue * mRECT.H();
18 pGraphics->DrawLine(&mHandleColor, xpos+mRECT.L, mRECT.T, xpos+mRECT.L, mRECT.B, 0, false);
19 pGraphics->DrawLine(&mHandleColor, mRECT.L, ypos+mRECT.T, mRECT.R, ypos+mRECT.T, 0, false);
20 pGraphics->FillCircle(&mHandleColor, xpos+mRECT.L, ypos+mRECT.T, mHandleRadius, 0, true);
22 return true;
25 // void OnMouseOver(int x, int y, IMouseMod* pMod)
26 // {
27 // return SnapToMouse(x, y);
28 // }
29 //
30 void OnMouseDown(int x, int y, IMouseMod* pMod)
32 mHandleColor = COLOR_BLACK;
33 return SnapToMouse(x, y);
36 void OnMouseUp(int x, int y, IMouseMod* pMod)
38 mHandleColor = COLOR_WHITE;
41 void OnMouseDrag(int x, int y, int dX, int dY, IMouseMod* pMod)
43 return SnapToMouse(x, y);
46 void SnapToMouse(int x, int y)
48 GetAuxParam(0)->mValue = BOUNDED((double)x / (double)mRECT.W(), 0, 1);
49 GetAuxParam(1)->mValue = BOUNDED((double)y / (double)mRECT.H(), 0, 1);
51 SetDirty();
54 void SetDirty(bool pushParamToPlug = true)
56 mDirty = true;
58 if (pushParamToPlug && mPlug)
60 SetAllAuxParamsFromGUI();
63 private:
64 int mHandleRadius;
65 IColor mHandleColor;