Someone shoot me if it's already in there, but I couldn't find a bitmap strip style knob control in IPlug (wdl_20090118). So I knocked one up by adding the following to IControl.h:
Code:
// A bitmap strip knob - Andrew J, 8-Mar-2009
class IKnobBitmapStripControl : public IKnobControl
{
public:
IKnobBitmapStripControl(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBitmap,
double minAngle = -0.75 * PI, double maxAngle = 0.75 * PI,
EDirection direction = kVertical, double gearing = DEFAULT_GEARING)
: IKnobControl(pPlug, &IRECT(x, y, pBitmap), paramIdx, direction, gearing),
mBitmap(*pBitmap), mMinAngle(minAngle), mMaxAngle(maxAngle) {}
~IKnobBitmapStripControl() {}
bool Draw(IGraphics* pGraphics);
private:
IBitmap mBitmap;
double mMinAngle, mMaxAngle;
};
And to IControl.cpp:
Code:
// A bitmap strip knob - Andrew J, 8-Mar-2009
// Assumes that bitmap strip goes from top to bottom, starts at South and goes clockwise 360deg
bool IKnobBitmapStripControl::Draw(IGraphics* pGraphics)
{
int i = 1;
if (mBitmap.N > 1) {
double angle = mMinAngle + mValue * (mMaxAngle - mMinAngle);
i = 1 + int(0.5 + (double) ((mBitmap.N - 1)/2 * (1 + angle/PI)));
i = BOUNDED(i, 1, mBitmap.N);
}
return pGraphics->DrawBitmap(&mBitmap, &mRECT, i, &mBlend);
}
Not thoroughly tested, but seems to work fine for me...
-Andrew