Here's some code for a switch that has extra states in between the notmal ones that are used when the mouse is down, like this:
(that switch is based on one from
here rearranged to fit the order iplug needs, the modified knobman files are
here)
Seems to work...
Code:
void ISwitch2Control::OnMouseUp(int x, int y)
{
mMouseDown=0;
SetDirty();
}
void ISwitch2Control::OnMouseDown(int x, int y, IMouseMod* pMod)
{
mMouseDown=1;
if (pMod->R) {
PromptUserInput();
}
else if (mBitmap.N > 2) {
mValue += 2.0 / (double) (mBitmap.N - 2);
}
else {
mValue += 1.0;
}
if (mValue > 1.001) {
mValue = 0.0;
}
SetDirty();
}
bool ISwitch2Control::Draw(IGraphics* pGraphics)
{
int i = 1;
if (mBitmap.N > 2) {
i = 1 + mMouseDown + int(0.5 + mValue * (mBitmap.N - 2));
i = BOUNDED(i, 1, mBitmap.N);
}
return pGraphics->DrawBitmap(&mBitmap, &mRECT, i, &mBlend);
}
Code:
class ISwitch2Control : public ISwitchControl
{
public:
ISwitch2Control(IPlugBase* pPlug, int x, int y, int paramIdx, IBitmap* pBitmap,
IChannelBlend::EBlendMethod blendMethod = IChannelBlend::kBlendNone)
: ISwitchControl(pPlug,x,y,paramIdx,pBitmap,blendMethod),mMouseDown(0) {
mDblAsSingleClick=true; }
~ISwitch2Control() {}
void OnMouseDown(int x, int y, IMouseMod* pMod);
void OnMouseUp(int x, int y);
virtual bool Draw(IGraphics* pGraphics);
protected:
int mMouseDown;
};