I'm experiencing a problem with resizing and showing/hiding controls, I've poked around enough that I think it could be a bug with WDL-Youlean, but we'll see...
Basically, I have a control that I want to show when another button is pressed. At first I had the following code in the constructor and in OnParamChange, which was all good:
Code:
bitmap = pGraphics->LoadPointerToBitmap(IBUTTON_TEST_ID, IBUTTON_TEST_FN, 1);
mTestControl = pGraphics->AttachControl(pTestControl = new ISwitchControl(this, 50, 10, kTestControl, bitmap));
pTestControl->Hide(true);
hideFlag = true;
bitmap = pGraphics->LoadPointerToBitmap(IBUTTON_SHOW_ID, IBUTTON_SHOW_FN, 2);
mShowSwitch = pGraphics->AttachControl(pShowSwitch = new ISwitchControl(this, 10, 10, kShowSwitch, bitmap));
case kShowSwitch:
if (GetParam(kShowSwitch)->Value() == true) {
pTestControl->Hide(false);
}
else {
pTestControl->Hide(true);
}
However, trying to put that into a plugin with a resizable window is causing problems. If I have clicked the button to show the control, every time I resize the GUI, the newly shown control will disappear again when I release the mouse button. I’ve included the if(hideFlag) check in all the view modes. It seems like it’s being redrawn elsewhere? Interestingly, if I comment out pTestControl->Hide(true) and hideFlag = true, the problem happens in reverse, where the control will be unhidden after releasing the mouse button.
Code:
bitmap = pGraphics->LoadPointerToBitmap(IBUTTON_TEST_ID, IBUTTON_TEST_FN, 1);
mTestControl = pGraphics->AttachControl(pTestControl = new ISwitchControl(this, 50, 10, kTestControl, bitmap));
pTestControl->Hide(true);
hideFlag = true;
bitmap = pGraphics->LoadPointerToBitmap(IBUTTON_SHOW_ID, IBUTTON_SHOW_FN, 2);
mShowSwitch = pGraphics->AttachControl(pShowSwitch = new ISwitchControl(this, 10, 10, kShowSwitch, bitmap));
case kShowSwitch:
if (GetParam(kShowSwitch)->Value() == true) {
hideFlag = false;
pTestControl->Hide(false);
}
else {
hideFlag = true;
pTestControl->Hide(true);
}
if (viewMode == defaultView)
{
GetGUIResize()->MoveControlHorizontally(*knobIndex, windowWidth - 200);
GetGUIResize()->MoveControlHorizontally(*helloIPlugIndex, windowWidth - 220);
GetGUIResize()->MoveControlHorizontally(*miniViewIndex, windowWidth - 220);
GetGUIResize()->MoveControlHorizontally(*defaultViewIndex, windowWidth - 220);
GetGUIResize()->MoveControlHorizontally(*hugeViewIndex, windowWidth - 220);
GetGUIResize()->MoveControlHorizontally(*handleSelectorIndex, windowWidth - 220);
if (hideFlag == true)
pTestControl->Hide(true);
else
pTestControl->Hide(false);
}