|
03-24-2018, 01:04 PM
|
#1
|
Human being with feelings
Join Date: Jan 2018
Posts: 2
|
How to use ISwitchPopUpControl?
ISwitchPopUpControl seems to take the same arguments as the regular ISwitchControl, but when I change the switch controls to pop up switch controls in my code, they do nothing when I click on them. Does anyone know how to use them correctly?
|
|
|
03-25-2018, 01:46 AM
|
#2
|
Human being with feelings
Join Date: Apr 2014
Posts: 84
|
It calls PromptUserInput() in OnMouseDown(), you might want to investigate what happens down there and why the textbox is not visible.
Btw, if you need something like a dropdown list for a param, you can use IDropDownList from the upcoming IPlug2, you just have to edit it to match the old IPlug:
https://github.com/olilarkin/wdl-ol/...nListControl.h
|
|
|
03-25-2018, 12:11 PM
|
#3
|
Human being with feelings
Join Date: Jan 2017
Posts: 11
|
An example of ISwitchPopUpControl
Hi,
The way to use this control is with an enumerated parameter.
Here is an example.....
1) place a bitmap image with the number of frames that correspond to the number of choices you wish to be in your menu. In this example, I am using five. I have attached the example png file below.
2) In yourproject.rc add
3) In resource.h
// Unique IDs for each image resource.
#define KNOB_ID 101
#define SWITCH_ID 102
Quote:
// Image resource locations for this plug.
#define KNOB_FN "resources/img/knob.png"
#define SWITCH_FN "resources/img/fiveposwitch.png"
|
4) In yourproject.h add an integer member variable
Quote:
private:
double mGain;
int mSwitchVal;
|
5) In yourproject.cpp
Quote:
.....
enum EParams
{
kGain = 0,
kSwitch,
kNumParams
};
enum ELayout
{
kWidth = GUI_WIDTH,
kHeight = GUI_HEIGHT,
kGainX = 100,
kGainY = 100,
kKnobFrames = 60,
kSwitchFrames = 5
};
Menu_Switch::Menu_Switch(IPlugInstanceInfo instanceInfo)
: IPLUG_CTOR(kNumParams, kNumPrograms, instanceInfo), mGain(1.), mSwitchVal(0)
{
TRACE;
//arguments are: name, defaultVal, minVal, maxVal, step, label
GetParam(kGain)->InitDouble("Gain", 50., 0., 100.0, 0.01, "%");
GetParam(kGain)->SetShape(2.);
GetParam(kSwitch)->InitEnum("MenuSwitch", 0, 5);
GetParam(kSwitch)->SetDisplayText(0, "1");
GetParam(kSwitch)->SetDisplayText(1, "2");
GetParam(kSwitch)->SetDisplayText(2, "3");
GetParam(kSwitch)->SetDisplayText(3, "4");
GetParam(kSwitch)->SetDisplayText(4, "5");
IGraphics* pGraphics = MakeGraphics(this, kWidth, kHeight);
pGraphics->AttachPanelBackground(&COLOR_RED);
IBitmap knob = pGraphics->LoadIBitmap(KNOB_ID, KNOB_FN, kKnobFrames);
IBitmap menuswitch = pGraphics->LoadIBitmap(SWITCH_ID, SWITCH_FN, kSwitchFrames);
pGraphics->AttachControl(new IKnobMultiControl(this, kGainX, kGainY, kGain, &knob));
pGraphics->AttachControl(new ISwitchPopUpControl(this, kGainX + 50, kGainY, kSwitch, &menuswitch));
AttachGraphics(pGraphics);
//MakePreset("preset 1", ... );
MakeDefaultPreset((char *) "-", kNumPrograms);
}
....
|
6) In OnParamChange...
Quote:
void Menu_Switch::OnParamChange(int paramIdx)
{
IMutexLock lock(this);
switch (paramIdx)
{
case kGain:
mGain = GetParam(kGain)->Value() / 100.;
break;
case kSwitch:
mSwitchVal = GetParam(kSwitch)->Value();
// Do something with mSwitchVal
break;
default:
break;
}
}
|
Here is the png file
fiveposwitch.png
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 08:21 PM.
|