|
03-09-2012, 07:31 AM
|
#1
|
Human being with feelings
Join Date: Mar 2012
Location: Switzerland
Posts: 3
|
Best way to set a text from plug
Hey everyone,
First off, thanks a lot for everyone involved in making wdl/Iplug. I really enjoyed using it so far!
Now I have a pretty simple question (I guess), which somehow I cannot figure out by myself:
Say I have a "knob" whose value is set in ProcessDoubleReplacing() via SetControlFromPlug() (not associated with a "real" parameter). What is the best way to also display the numerical value of it on the GUI?
I've tried
Code:
idx = pGraphics->AttachControl(new IBitmapControl(...))
pGraphics->AttachControl(new ICaptionControl(this, &rect, idx, &text));
but this crashed my host. Did I miss something or is there any better way? Maybe via ITextControl and some set-function in the plug?
Thanks a lot in advance!
virt
|
|
|
03-09-2012, 11:01 AM
|
#2
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
Well, I don't know if this is the best way (probably not), but I would make a customized control in which I would override the Draw() method. Then I would simply call DrawIText() to draw the numerical value, i.e.:
Code:
class MyBitmapControl: public IBitmapControl
{
MyBitmapControl(IPlugBase* pPlug, int x, int y, IBitmap* pBitmap):
IBitmapControl(pPlug, x, y, -1, pBitmap) {}
bool Draw(IGraphics* pGraphics)
{
IText font = IText(16, &COLOR_BLACK, NULL, IText::kStyleNormal, IText::kAlignCenter);
IRECT rect = IRECT(mRECT.L, mRECT.B - 16, mRECT.R, mRECT.B);
char str[10];
sprintf(str, "%0.01f", mValue);
return IBitmapControl::Draw(pGraphics) && pGraphics->DrawIText(&font, str, &rect);
}
};
|
|
|
03-12-2012, 01:10 AM
|
#3
|
Human being with feelings
Join Date: Mar 2012
Location: Switzerland
Posts: 3
|
Excellent, thanks!
|
|
|
03-12-2012, 03:54 AM
|
#4
|
Human being with feelings
Join Date: Mar 2012
Location: Switzerland
Posts: 3
|
Hmm, so now of course, the displayed value equals the internal 0-1 mValue. Is there an easy way to get something similar to the
Code:
InitDouble("disp value", 0.0, 0.0, 3.0, 0.1, "");
functionality for my display-only knob value?
I guess that comes down to the question, what would be a good way to use an IParam, without it residing on the base-class's mParams vector, and therefore without the option to access it via some paramIdx?
I realized I would have to rewrite quite a lot of classes in order to hand over a IPlugExample class member variable IParam, right?
|
|
|
03-12-2012, 06:34 AM
|
#5
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
You could use IParam::GetDisplayForHost instead of sprintf, i.e.:
Code:
char str[100];
mPlug->GetParam(mParamIdx)->GetDisplayForHost(mValue, true, str);
|
|
|
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 07:28 PM.
|