PDA

View Full Version : Hide the mouse onmousdown?


junioreq
11-10-2010, 02:10 PM
http://stash.reaper.fm/oldsb/435961/Wavescntrl.gif

Trying to make this control, is there a way to hide the mouse on both mac and pc?

~Rob.

sstillwell
11-10-2010, 09:58 PM
Hahahaha...what is it with you and Waves? :)

I don't know, but I'll tinker and see what I come up with.

Scott

junioreq
11-10-2010, 10:19 PM
heh, I don't know, I just like those cool little controls. I think its just one step above what I usually see. ok, its really cause i suck at dsp, and I got nothing else to do but make controls hahaha..

~Rob.

sstillwell
11-10-2010, 10:29 PM
Okay, easy enough. For Windows, you would use the Windows API function ShowCursor(bool ShowMe), with true to make it visible, and false to hide it. I'll leave finding the appropriate Mac function as an exercise for you. :)

First, add a protected member variable to the IControl class:

bool mHideMouseCursor;

Then, add an initialization to the IControl constructor method:


IControl(IPlugBase* pPlug, IRECT* pR, int paramIdx = -1, IChannelBlend blendMethod = IChannelBlend::kBlendNone)
: mPlug(pPlug), mRECT(*pR), mTargetRECT(*pR), mParamIdx(paramIdx), mValue(0.0), mDefaultValue(-1.0),
mBlend(blendMethod), mDirty(true), mHide(false), mGrayed(false), mDisablePrompt(false), mDblAsSingleClick(false),
mClampLo(0.0), mClampHi(1.0), mHideMouseCursor(false) {}


Add a couple of methods to the class definition:

void HideMouseCursor(bool hideMe) { mHideMouseCursor = hideMe; };
const bool GetMouseState() { return mHideMouseCursor; };

Make OnMouseUp() non-virtual so that a default behavior is inherited (remember to call the base class' method if you override and still use the mouse show/hide functionality...)

void OnMouseUp(int x, int y, IMouseMod* pMod) { if (mHideMouseCursor) ShowCursor(true); }


And modify OnMouseDown() to do the other half of the voodoo...

if (pMod->R) {
PromptUserInput();
}
if (mHideMouseCursor)
ShowCursor(false);


Then, during the initialization of your plugin, when you create your control, you'd make sure to use one of your new methods to tell it to hide the cursor when used (the default behavior is to NOT hide the mouse, since we don't want to break shit).

IControl* pLfLevel = new IKnobMultiControl(this, kLfLevel_X, kLfLevel_Y, kLfLevel, &knob);
pLfLevel->HideMouseCursor(true);
pGraphics->AttachControl(pLfLevel);


Voila...it works.

There's probably something else I'm missing, but that does the trick. If one of you guys want to make it cross-platform friendly and incorporate that into one of the repositories, that would be great...we can all get the use of it, then.

Scott

*EDIT* ShowCursor and its Mac equivalent should probably be extracted out to a method in IGraphics/IGraphicsWin/IGraphicsMac, and then called through a mPlug->GetGUI()->HideMouseCursor(bool) function or something similar. Putting the platform-dependent stuff in IControl is bad form, really.

I was in a hurry.

So sue me.

:)

junioreq
11-11-2010, 12:19 PM
Thanks Scott! much appreciated, gonna play with this today....

~Rob.