View Full Version : Horizontal faders
onqel
09-19-2010, 02:01 AM
Hi guys
I'm having trouble again.. haha
Does anyone have a control to make those faders follow mouse?
I cheated and used a IKnobMultiControl to at least get something usable .. the faders are a strip of bitmaps like a regular knob, but it should respond like a fader where you can click at a point on the line and the fader snaps to it immediately..
Here's how it responds right now:
http://dl.dropbox.com/u/1369729/plugins/808.gif
You can do horizontal faders with the regular IPlug fader, but it sounds like you want it to be multi-bitmap too... I implemented one of these, it's in my git repo (see the sticky thread), works horizonal, vertical and can be reversed:
// A multibitmap fader. The bitmap cycles through states as the mouse drags, and snaps to clicks.
// The handleLen is the length in pixels of the handle of the fader.
// By default the handle is expected to move from one extreme of the bitmap to the other. If it
// does not, then use SetTargetArea() and set the area to exactly the area swept out by the fader
// (eg for vertical: from its bottom in the lowest position to its top in the highest position)
class IFaderMultiControl : public IControl
{
public:
IFaderMultiControl(IPlugBase* pPlug, int x, int y, int handleLen, int paramIdx, IBitmap* pBitmap,
EDirection direction = kVertical);
~IFaderMultiControl() {}
virtual void OnMouseDown(int x, int y, IMouseMod* pMod);
virtual void OnMouseDrag(int x, int y, int dX, int dY, IMouseMod* pMod);
virtual bool Draw(IGraphics* pGraphics);
// reverse means high value at bottom or left
void SetReverse( bool r ) { mReverse = r; }
protected:
void SnapToMouse(int x, int y);
int mHandleLen;
IBitmap mBitmap;
EDirection mDirection;
bool mReverse;
int mOffset;
};
onqel
09-19-2010, 02:54 PM
I will check it out, thanks!
onqel
09-19-2010, 03:49 PM
Yeah this was so much better!
It still doesn't snap exactly to mouse, and I set handlelen to 1 .. :P
I guess I can live with that ;)
Thanks !
If you send me the bitmap you are using I'll try and figure out why It's not exact.
onqel
09-20-2010, 07:50 AM
If you send me the bitmap you are using I'll try and figure out why It's not exact.
http://dl.dropbox.com/u/1369729/Headerknob.png
Frames:60, width:75, height:12 ..
It's originally 30 frames, but I increased it to see if it helped..
This is the last nitpick (I hope) before I can release this (freeware) plugin.. (Maxon OD808 emulation)
I haven't got time to try anything right now, but looking at your png I think the problem is that my control assumes that the frames will be perfectly linear between the first and the last and your png isn't. I think if you remove the first 9 (or so) frames and the last 10 frames it should work a lot better.
onqel
09-20-2010, 02:29 PM
Thanks cc_, it worked!!
and thanks for sharing your work/code :D
onqel
09-27-2010, 08:07 AM
Is someone wants to try this one, the finished plugin can be downloaded at www.theserinaexperiment.net/forum/viewtopic.php?f=8&t=36
Just downloaded and tried it, and it sounds very good. :cool: Thank you very much for sharing!
olilarkin
09-29-2010, 02:13 AM
any chance of a Mac version? I'd be happy to compile it if you don't have a mac
oli
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.