COCKOS
CONFEDERATED FORUMS
Cockos : REAPER : NINJAM : Forums
Forum Home : Register : FAQ : Members List : Search :
Old 11-08-2009, 12:56 PM   #1
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default Couple of questions

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 is offline   Reply With Quote
Old 11-08-2009, 01:01 PM   #2
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default

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
RRokkenAudio is offline   Reply With Quote
Old 11-08-2009, 03:57 PM   #3
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Code:
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


Code:
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.
Tale is offline   Reply With Quote
Old 11-08-2009, 04:33 PM   #4
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

Quote:
Originally Posted by Tale View Post
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
Jeffos is offline   Reply With Quote
Old 11-08-2009, 09:58 PM   #5
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default

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.
RRokkenAudio is offline   Reply With Quote
Old 11-09-2009, 02:06 AM   #6
Jeffos
Mortal
 
Jeffos's Avatar
 
Join Date: Dec 2008
Location: France
Posts: 1,969
Default

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..
Jeffos is offline   Reply With Quote
Old 11-09-2009, 06:14 AM   #7
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default

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 is offline   Reply With Quote
Old 11-09-2009, 07:57 AM   #8
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default

There has got to be an easier way to redraw the screen no??

~Rob.
RRokkenAudio is offline   Reply With Quote
Old 11-09-2009, 09:18 AM   #9
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Quote:
Originally Posted by Jeffos View Post
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.
Tale is offline   Reply With Quote
Old 11-10-2009, 01:56 AM   #10
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default

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.

Last edited by RRokkenAudio; 11-10-2009 at 02:18 AM.
RRokkenAudio is offline   Reply With Quote
Old 11-10-2009, 02:59 AM   #11
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default

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.
RRokkenAudio is offline   Reply With Quote
Old 11-10-2009, 05:15 AM   #12
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

Perhaps you've inited your param with a range of 0..1 instead of 0..2? Your param init should look something like:

Code:
int default = 0, min = 0, max = 3;
GetParam(paramIdx)->InitInt("Radio", default, min, max);
Or when using Enum instead of Int:

Code:
int default = 0, nOptions = 3;
GetParam(paramIdx)->InitEnum("Radio", default, nOptions);
Tale is offline   Reply With Quote
Old 11-10-2009, 05:17 AM   #13
RRokkenAudio
Human being with feelings
 
RRokkenAudio's Avatar
 
Join Date: Jun 2009
Location: Buffalo, NY
Posts: 777
Default

Wow, Tale, you know your stuff.. It's so hard figuring this out uhhhhh....

~Rob

Thanks for your help..
RRokkenAudio is offline   Reply With Quote
Old 11-10-2009, 05:36 AM   #14
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

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.
Tale is offline   Reply With Quote
Old 11-12-2009, 01:51 AM   #15
junioreq
Human being with feelings
 
junioreq's Avatar
 
Join Date: Aug 2008
Location: Buffalo NY
Posts: 1,091
Default

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.
junioreq is offline   Reply With Quote
Old 11-12-2009, 04:12 AM   #16
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
Default

I've just tried, but two (and three) sets work just fine here.
Tale is offline   Reply With Quote
Old 11-13-2009, 03:14 AM   #17
junioreq
Human being with feelings
 
junioreq's Avatar
 
Join Date: Aug 2008
Location: Buffalo NY
Posts: 1,091
Default

Turns out, I wasn't changing the x value on the second x arg lol

~Rob.
junioreq is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 08:29 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.