Need some help for a newbie on Vst GUI dev
-
- KVRist
- Topic Starter
- 86 posts since 23 Apr, 2004
Hi !
For the plugin i'm developping i want to add a display for a knob but i want also the display to switch to another unity as i click on it : ex : the bitmap display would display freq cutoff in hz and when i click on it it would switch to a note display....(i want the dispay to be a bitmap display, only)
for that, i chose the MovieButton type and created 127 bitmaps with two display inside (the freq and the note) and i display each bitmap accordingly to the knob value. and as they are movie buttons, clicking on them witch to the other display mode.
the problem i have is a flickering pb because i have to use setDirty() each time a value change (i change each value the MovieButton that is used)
is there another way to do what i need to, or do i have to deal with flickering?
thanks for your answers.
For the plugin i'm developping i want to add a display for a knob but i want also the display to switch to another unity as i click on it : ex : the bitmap display would display freq cutoff in hz and when i click on it it would switch to a note display....(i want the dispay to be a bitmap display, only)
for that, i chose the MovieButton type and created 127 bitmaps with two display inside (the freq and the note) and i display each bitmap accordingly to the knob value. and as they are movie buttons, clicking on them witch to the other display mode.
the problem i have is a flickering pb because i have to use setDirty() each time a value change (i change each value the MovieButton that is used)
is there another way to do what i need to, or do i have to deal with flickering?
thanks for your answers.
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
So does changing the knob change the two sepearate image types between a number of states?
I'd probably write a class that encapsulates two CMovieButtons (or simply CBitmaps if the things don't need to be lists of images). I'd also have a few member functions:
> get the rectangle for mouse click testing
> draw(COffscreenContext* p_oc)
> toggle view (has boleean member variable).
in the draw function, use the member variable to decide which bitmap to draw to the offscreen context.
If you alays draw your entire gui to an offscreencontext and then transfer to the drawconext as a final step, you shouldn't get any flicker.
Remember that you can safely cast a coffscreencontext* to a cdrawcontext* for use with things like CBitmap::draw(CDrawContext* ....);
I'd probably write a class that encapsulates two CMovieButtons (or simply CBitmaps if the things don't need to be lists of images). I'd also have a few member functions:
> get the rectangle for mouse click testing
> draw(COffscreenContext* p_oc)
> toggle view (has boleean member variable).
in the draw function, use the member variable to decide which bitmap to draw to the offscreen context.
If you alays draw your entire gui to an offscreencontext and then transfer to the drawconext as a final step, you shouldn't get any flicker.
Remember that you can safely cast a coffscreencontext* to a cdrawcontext* for use with things like CBitmap::draw(CDrawContext* ....);
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
I ought to mention though that you obviousdly don't have to draw the entire gui every time draw() is called, just the things that need to be updated. Just don't ever erase the image that is already there first or use the drawing functions directly on the CDrawContext.
This technique is called "Double Buffering"
This technique is called "Double Buffering"
-
- KVRist
- Topic Starter
- 86 posts since 23 Apr, 2004
okay, here we go :
i've built 2 classes : one for the knob and one for the display. i have the knob working well but i can't link the display to the knob.
I've tried to use the getParent()->getEditor()->setParameter(index,value) in the 'mouse' function of the 'draw' function of the knob but i have an error : "left of '->setParameter' must point to class/struct"
thanks for any help.
i've built 2 classes : one for the knob and one for the display. i have the knob working well but i can't link the display to the knob.
I've tried to use the getParent()->getEditor()->setParameter(index,value) in the 'mouse' function of the 'draw' function of the knob but i have an error : "left of '->setParameter' must point to class/struct"
thanks for any help.
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
I wouldn't be able to tell you why you are getting that compilation error without seeing the function prototypes and their scope for all of those functions you've mentioned.
Whats the inheritance of these classes? Have you inherited from the vstgui CControl?
if you have, then you can say:
getListener()->valueChanged(p_drawContext, this);
although you could also say:
listener->valueChanged(p_drawContext, this);
But that is only because they didn't make the CControlListener private in the CControl class (which is poor style). The getListener() function should be inlined by the compiler because it is declared inside the class definition in the header, so there is no disadvantage to using that in terms of function calls.
Your GUI editor should inherit CControlListener and implement the virtual function "valueChanged()".
You can then do something like:
Where "theKnob" is your *ahem* knob, and "displayObject" is the display that you want to update.
Whats the inheritance of these classes? Have you inherited from the vstgui CControl?
if you have, then you can say:
getListener()->valueChanged(p_drawContext, this);
although you could also say:
listener->valueChanged(p_drawContext, this);
But that is only because they didn't make the CControlListener private in the CControl class (which is poor style). The getListener() function should be inlined by the compiler because it is declared inside the class definition in the header, so there is no disadvantage to using that in terms of function calls.
Your GUI editor should inherit CControlListener and implement the virtual function "valueChanged()".
You can then do something like:
Code: Select all
GuiEditor::valueChanged (CDrawContext *context, CControl *control)
{
int tag = control->getTag ();
float value = control->getValue();
switch (tag) {
case kTheKnob:
effect->setParameterAutomated (tag, value);
theKnob->update (context);
displayObject->setValue(value);
displayObject->update(context);
break;
}
}
-
- KVRist
- Topic Starter
- 86 posts since 23 Apr, 2004
hi !
My editor class inherit from CControlListener and my knob and display classes from CControl.
I have both SetParameter and ValueChanged functions in the editor code. I have tried to update the disp value and display in the knob case of the ValueChanged function (as you told me), but i don't works (as it should)
i still don't understand why the getParent()->getEditor()->SetParameter(index, value) returns the compile error...
the two ways to solve my pb don't works , no chance ...
My editor class inherit from CControlListener and my knob and display classes from CControl.
I have both SetParameter and ValueChanged functions in the editor code. I have tried to update the disp value and display in the knob case of the ValueChanged function (as you told me), but i don't works (as it should)
i still don't understand why the getParent()->getEditor()->SetParameter(index, value) returns the compile error...
the two ways to solve my pb don't works , no chance ...
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
The reason your code doesn't compile is because getEditor returns a void* (!) It isn't the same function as AEffEditor* AudioEffectX::getEditor()
A void* is not a class/struct/union. You'll need to check it isn't null and cast it to whatever it is supposed to be. Its a bit ugly though and I would seriously advise against going down that road.
What do you mean when you say that using the valuechanged method doesn't work? Does nothing happen at all?
Its difficult to help without seeing any code.
A void* is not a class/struct/union. You'll need to check it isn't null and cast it to whatever it is supposed to be. Its a bit ugly though and I would seriously advise against going down that road.
What do you mean when you say that using the valuechanged method doesn't work? Does nothing happen at all?
Its difficult to help without seeing any code.
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
you could try using:
displayObject->setValue(value); //or whatever updates its value
displayObject->redraw();
displayObject->setValue(value); //or whatever updates its value
displayObject->redraw();
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
-
- KVRist
- Topic Starter
- 86 posts since 23 Apr, 2004
erm, i got one last problem : when i try to automate the parameters, the display don't change accordingly, the knobs don't move.
The sound, it , is okay, it works normally when automated...
The sound, it , is okay, it works normally when automated...
-
- KVRian
- 922 posts since 26 Mar, 2003 from Guildford, England
have you implemented the function:
void AEffGUIEditor::setParameter (long index, float value);
in your derived editor class?
void AEffGUIEditor::setParameter (long index, float value);
in your derived editor class?