VST and Mouse
-
- KVRian
- Topic Starter
- 922 posts since 26 Mar, 2003 from Guildford, England
I've been writing a control for a VST plugin, but I'm having a bit of trouble trying to figure out the best way of capturing mouse events.
The VST gui library 'calls' functions when there are things like a mouse click or a mouse wheel event, but not when there is a mouse move event.
What I need to do is figure out when the mouse is hovering over a particular region of the screen (e.g. a handle on an envelope), avoiding using platform specific messages / functions.
I've wondered if you might be able to do this in the 'idle()' function, and check the mouse position at each call, figure out if it has changed, and then call some function to elucidate which control/area the mouse is over.
The problem is that I can't figure out what the most efficient way of doing this is? Some sort of tree hierachy / clustering?
One other (possibly related) thing I want to avoid is trapping the gui in some 'do loop' when doing an edit - like the standard vstgui knob does. I don't think it looks too good when the entire gui gets stalled just because you are editing a parameter. In FL Studio, the entire GUI in the rest of the app stops updating when this happens.
The VST gui library 'calls' functions when there are things like a mouse click or a mouse wheel event, but not when there is a mouse move event.
What I need to do is figure out when the mouse is hovering over a particular region of the screen (e.g. a handle on an envelope), avoiding using platform specific messages / functions.
I've wondered if you might be able to do this in the 'idle()' function, and check the mouse position at each call, figure out if it has changed, and then call some function to elucidate which control/area the mouse is over.
The problem is that I can't figure out what the most efficient way of doing this is? Some sort of tree hierachy / clustering?
One other (possibly related) thing I want to avoid is trapping the gui in some 'do loop' when doing an edit - like the standard vstgui knob does. I don't think it looks too good when the entire gui gets stalled just because you are editing a parameter. In FL Studio, the entire GUI in the rest of the app stops updating when this happens.
-
- KVRian
- Topic Starter
- 922 posts since 26 Mar, 2003 from Guildford, England
-
tony tony chopper tony tony chopper https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=3103
- KVRAF
- 3561 posts since 20 Jun, 2002
anything you do should be based on simple windows messaging (sending/handling messages).
VSTGUI should be banned as it indeed dumbly enters a loop (in the main thread!) when you tweak a knob, preventing the app itself to keep running. This is very bad and, I suspect, Mac-style.
VSTGUI should be banned as it indeed dumbly enters a loop (in the main thread!) when you tweak a knob, preventing the app itself to keep running. This is very bad and, I suspect, Mac-style.
-
- KVRian
- Topic Starter
- 922 posts since 26 Mar, 2003 from Guildford, England
Thanks for the response gol!
I do want to try and make it platform independent though, so was thinking of doing some sort of polling scheme using the idle() function? Or is this fundamentally floored in some way? I'm thinking of writing some classes for Qt for doing VST (or FL plugin) gui's, so could use the signal/slot mechanism (similar effect to _closure pointers in borlands c++).
The main thing I'm not sure on is how to rapidly figure out what control the mouse is hovering over.
Gol, do you know how Robert Conde did it in the WaveTraveller when adjusting the spline? Is each handle a window?
I do want to try and make it platform independent though, so was thinking of doing some sort of polling scheme using the idle() function? Or is this fundamentally floored in some way? I'm thinking of writing some classes for Qt for doing VST (or FL plugin) gui's, so could use the signal/slot mechanism (similar effect to _closure pointers in borlands c++).
The main thing I'm not sure on is how to rapidly figure out what control the mouse is hovering over.
Gol, do you know how Robert Conde did it in the WaveTraveller when adjusting the spline? Is each handle a window?
-
tony tony chopper tony tony chopper https://www.kvraudio.com/forum/memberlist.php?mode=viewprofile&u=3103
- KVRAF
- 3561 posts since 20 Jun, 2002
yes, it suckspolling scheme using the idle() function? Or is this fundamentally floored in some way?
it should work on messages. Windows apps are basically a running message polling loop in themselves (for their main GUI thread).
you just, whenever the mouse is moved, check what's under it. Unless you have 10.000 points you shouldn't care about optimizing thatThe main thing I'm not sure on is how to rapidly figure out what control the mouse is hovering over
-
- KVRian
- Topic Starter
- 922 posts since 26 Mar, 2003 from Guildford, England
I've discovered that Qt has a QMouseEvent class that will give a mouse move event if QWidget::setMouseTracking() has been called, and it is totally platform independent. I'll use that and let it find the controls for me.
Don't know why the vstgui library doesnt have mouse move events. Madness.
Don't know why the vstgui library doesnt have mouse move events. Madness.