View Full Version : Radio Button Problems
junioreq
11-21-2009, 09:16 AM
Here is the code I have for the radio buttons:
pGraphics->AttachControl(new IRadioButtonsControl(this, &IRECT(192, 96, 192 + 96 ,96 + nButtons * 0.5*35), kband1freq, nButtons, &bitmap, kHorizontal));
pGraphics->AttachControl(new IRadioButtonsControl(this, &IRECT(192, 120, 192 + 120, 120 + nButtons * 0.5*35), rband1slope, nButtons, &bitmap, kHorizontal));
And here's what I get?
http://dl.dropbox.com/u/1933049/1084sarah.PNG
They should be the same, but the bottom ones are spread out.
Another question. Say i wanted to use a different button for each button - I'd like to print the low shelf, high shelf etc on the actual buttons.
How would I do that? Is it even possible to use different buttons for the radio buttons? ex 3 different buttons instead of 3 of the same.
~Rob.
schwa
11-21-2009, 09:44 AM
On the bottom one the 192+120 should be 192+96 (it's the width of the control).
junioreq
11-21-2009, 09:55 AM
Thank you schwa! I must have gotten the arguments mixed with another control.
http://dl.dropbox.com/u/1933049/1084schwafix.PNG
I'd really like to print the labels on the buttons like the first top row are 50hz, 110hz and 220hz. Don't think there's any way to print them on the image and use 3 diff images.
Maybe I can just do some text overlay as a hack.
But thank you!
~Rob.
RRokkenAudio
12-13-2009, 06:15 PM
Just one thing i'd like to add here, is there a way that we can use 3 different images for each on this?
Say i want to print the values of the switch on the switch, cant do that now cause it just uses 1 png strip... 50hz, 100, 200 would be nice to be printed on the knobs..
~Rob.
RRokkenAudio
02-01-2010, 09:27 PM
Well, I tried this :
if(hpswitch == 1){
mix1 = HPFilter1.filter(*in1);
mix2 = HPFilter2.filter(*in2);
GetGUI()->SetControlFromPlug(lpbutton, 0);
// GetGUI()->SetControlFromPlug(bpbutton, 0);
}
if(lpswitch == 1){
mix1 = LPFilter1.filter(*in1);
mix2 = LPFilter2.filter(*in2);
// GetGUI()->SetControlFromPlug(bpbutton, 0);
GetGUI()->SetControlFromPlug(hpbutton, 0);
}
Because i want to have 3 different images. It doesn't work, Clicking on lpswitch does turn off the HP switch, but going back and clicking the HP switch, it just keeps like being stuck off, can't seeem to press it and get it to push in again :(
~Rob.
The problem with that code is that you are always setting HP off when LP in on, so when you press HP it will just get turned straight off again. If you want to to work you'll have to keep track of the previous states of the buttons and only turn HP off when LP changes from 0 to 1.
But... it is pretty nasty doing this gui stuff in the process call. It would be better to make a new control class derived from IRadioButtonsControl, which would take an array of bitmaps (one for each button) and store it in a member variable. Then copy the Draw method from IRadioButtonsControl into your new class and modify it a little to print the right bitmap for each button.
Or, you could use regular switches like you are now and my Subject/Observer code to pop up the other switches when a switch changed.
RRokkenAudio
02-07-2010, 03:02 PM
Looks like i would make an array out of pbitmap?
IRadioButtonsControl::IRadioButtonsControl(IPlugBa se* pPlug, IRECT* pR, int paramIdx, int nButtons,
IBitmap* pBitmap, EDirection direction)
: IControl(pPlug, pR, paramIdx), mBitmap(*pBitmap)
{
mRECTs.Resize(nButtons);
int x = mRECT.L, y = mRECT.T, h = int((double) pBitmap->H / (double) pBitmap->N);
if (direction == kHorizontal) {
int dX = int((double) (pR->W() - nButtons * pBitmap->W) / (double) (nButtons - 1));
for (int i = 0; i < nButtons; ++i) {
mRECTs.Get()[i] = IRECT(x, y, x + pBitmap->W, y + h);
x += pBitmap->W + dX;
}
}
else {
int dY = int((double) (pR->H() - nButtons * h) / (double) (nButtons - 1));
for (int i = 0; i < nButtons; ++i) {
mRECTs.Get()[i] = IRECT(x, y, x + pBitmap->W, y + h);
y += h + dY;
}
}
}
Looks like i would just change pBitmap to pBitmap[nButtons -1] Is this the right area to be working in?
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.