VSTGUI, I'm failing to understand CDrawContext *pContext

DSP, Plugin and Host development discussion.
RELATED
PRODUCTS

Post

uhh, something here I didn't quite understand very likely, but what is that clip supposed to do? I can't seem to expand the mouse area with it, only limit.

Post

what you do is, you read in the mouse delta and then clip the cursor back into position. you have to set the clip rect, then use getmousepos(), if the mouse has changed from the zero position, integrate it. if it hasnt, go into idle again.

so, say you've got a control in the window and it has window coordinates..

i do not know the functions in vst gui, you'll have to figure it out. my own gui code implements all of this much better than vstgui did when i used it years ago.. so this is psuedo code.

rect window = ?;
//rect in screen coordinates for the control you want to clip the mouse into. you'll have to build this yourself in vstgui, my gui code only requires that i add the window offset in order to transform the control coordinates into screen coordinates..

window.left = (window.left+window.right) / 2;
window.top = (window.top+window.bottom) / 2;
window.right = window.left+1;
window.bottom = window.top+1;

//this centers the mouse into the control window
ClipCursor(&window);
ClipCursor(0);

now, go through your loop. get the mouse position. if the mouse position is not equal to window.left/top, then calculate the deltas you need based upon the new coordinates. then recall:

ClipCursor(&window);
ClipCursor(0);

that way you're getting mouse deltas and resetting the cursor position every time.
if ther mouse cursor is still in the center/clipped position, run your idle function before passing through the loop again.

you can write a function like:

setmouseposition(x, y)
{
rect window = getwindowrect;
rect clip = rect(x + window.left, y + window.top, x+1 + window.left, y+1 + window.top);
ClipCursor(&clip);
ClipCursor(0);
}

Post

aaah! clever. it was the setmouseposition I had not thought of. cheers.

so yeah, basically clip creates an arbitrary sized area for the mouse to move in, and we temporarily set the cursor position to the middle of it.

and no, VSTGUI has none of this (AFAIK) so this has to be redone in OSX. I'm guessing (well hoping) it won't be too different to winuser.h

Post Reply

Return to “DSP and Plugin Development”