PDA

View Full Version : Couple of questions


RRokkenAudio
11-08-2009, 12:56 PM
I have to run to work, so i'll post this real quick:

Does anyone have any idea on how to make radio buttons? Or is there a function for the radio buttons?

How do I display a value, say above a knob I want to display the frequency?

~Rob.

RRokkenAudio
11-08-2009, 01:01 PM
hmm actually, I see this:

// A set of buttons that maps to a single selection. Bitmap has 2 states, off and on.
class IRadioButtonsControl : public IControl
{
public:

IRadioButtonsControl(IPlugBase* pPlug, IRECT* pR, int paramIdx, int nButtons, IBitmap* pBitmap,
EDirection direction = kVertical);
~IRadioButtonsControl() {}

void OnMouseDown(int x, int y, IMouseMod* pMod);
bool Draw(IGraphics* pGraphics);

protected:
WDL_TypedBuf<IRECT> mRECTs;
IBitmap mBitmap;
};


// Output text to the screen.
class ITextControl : public IControl
{
public:

ITextControl(IPlugBase* pPlug, IRECT* pR, IText* pText, const char* str = "")
: IControl(pPlug, pR), mText(*pText)
{
mStr.Set(str);
}
~ITextControl() {}

void SetTextFromPlug(char* str);
void ClearTextFromPlug() { SetTextFromPlug(""); }

bool Draw(IGraphics* pGraphics);

protected:
IText mText;
WDL_String mStr;
};



not really sure how to use it though.. ??

~Rob

Tale
11-08-2009, 03:57 PM
IBitmap bitmap = pGraphics->LoadIBitmap(MY_RADIO_ID, MY_RADIO_FN, 2); // 2 bitmaps: Off and On
int nButtons = 3; // Number of radio buttons
pGraphics->AttachControl(new IRadioButtonsControl(this, &IRECT(x, y, x + bitmap.W, y + nButtons * 0.5*bitmap.H), paramIdx, nButtons, &bitmap, kVertical));

This will display 3 off/on buttons below one another. If you switch one of the buttons, the other two are automatically switched off. (Duh, it's a radio button.) :-p


pGraphics->AttachControl(new ICaptionControl(this, &IRECT(x1, y1, x2, y2), paramIdx, &IText(&COLOR_BLACK), true));

This will display a parameter's value. However, I'm not sure I'm doing this correctly, because when I just tested this the caption didn't always redraw itself.

Jeffos
11-08-2009, 04:33 PM
This will display a parameter's value. However, I'm not sure I'm doing this correctly, because when I just tested this the caption didn't always redraw itself.

hey Tale! I faced the same issue, this thread may help: http://forum.cockos.com/showthread.php?t=33893

RRokkenAudio
11-08-2009, 09:58 PM
Why are there x1, y1, x2, y2 ?? instead of just x1, y1 ?? and what is paramIdx ??


error C2065: 'paramIdx' : undeclared identifier


Here is the knob i'm trying to have a readout for :

pGraphics->AttachControl(new IKnobRotaterControl(this, kHPCuttoff1_x, kHPCuttoff1_y, kHPCuttoff1, &bitmap));

~Rob.

Jeffos
11-09-2009, 02:06 AM
Rob, paramIdx should be replaced with one of -your- EParams enum. About x2, y2, I was first surprised too but it's a native iplug constrainst that finally gives more flexibility..

RRokkenAudio
11-09-2009, 06:14 AM
Thank you, the readout is in, but doesn't move. But I will try other suggestions in that other post. Thank you!

EDIT: Yep, its a redraw issue, cause once I reload the gui the value is changed. Will work on this later.

~Rob.

RRokkenAudio
11-09-2009, 07:57 AM
There has got to be an easier way to redraw the screen no??

~Rob.

Tale
11-09-2009, 09:18 AM
hey Tale! I faced the same issue, this thread may help: http://forum.cockos.com/showthread.php?t=33893
Thanks for pointing me to that thread, I will look into it.

RRokkenAudio
11-10-2009, 01:56 AM
ok, I'm having a problem with getting the radio button working. It has to deal with resource.h, I believe:

#define BG_ID 100
#define KNOB_ID 101
#define MY_RADIO_ID 102

I get an assertion error and the plug will not load when I set the ID to 102. If I set it to 100, I get 3 buttons lol, but they have the bg as their image, same if I do 101, but I have knobs as the images lol. BUT, the plug will load.

Assertion error using 102 as ID... any thoughts?


EDIT:

Opened myproject.rc and added : MY_RADIO_ID PNG MY_RADIO_FN

Worked fine :)


~Rob.

RRokkenAudio
11-10-2009, 02:59 AM
Actually, now that I have 3 buttons, I hooked up a caption and see that button 1 outputs zero, button 2 outputs 1, and button 3 does nothing

I really need 0,1,2

??

~Rob.

Tale
11-10-2009, 05:15 AM
Perhaps you've inited your param with a range of 0..1 instead of 0..2? Your param init should look something like:

int default = 0, min = 0, max = 3;
GetParam(paramIdx)->InitInt("Radio", default, min, max);

Or when using Enum instead of Int:

int default = 0, nOptions = 3;
GetParam(paramIdx)->InitEnum("Radio", default, nOptions);

RRokkenAudio
11-10-2009, 05:17 AM
Wow, Tale, you know your stuff.. It's so hard figuring this out uhhhhh....

~Rob

Thanks for your help..

Tale
11-10-2009, 05:36 AM
You're very welcome.

At first I had a hard time figuring out things too. But now that I'm acquainted with the IPlug coding style, it all makes sense to me.

junioreq
11-12-2009, 01:51 AM
ok, is there any reason i cant have 2 sets of radio buttons ? I cant seem to get my second set to switch at all...??

~Rob.

Tale
11-12-2009, 04:12 AM
I've just tried, but two (and three) sets work just fine here.

junioreq
11-13-2009, 03:14 AM
Turns out, I wasn't changing the x value on the second x arg lol

~Rob.