I’ve a question about drawing.
Is it necessary to draw() (thus, redraw) every time the function is called?
I mean: I’m thinking to place some kind of “isDirty” flag on step() (for some reasons) only when somethings to draw is changed, and than check within draw() if that flag is true; and only in that case, redraw.
Can I do it? or for some reason (i.e. switch os windows, overlap with other software, and so on) its necessary to always draw content?
You do need to draw every time. That’s why most of the widgets in vcv use the transparent frame buffer ( forget the name). Like the svg widget draws every time, but only rasterizes the svg when it’s dirty.
Widget::draw() method only draws every N frames (through an early return for example), it will only appear every N frames. If you wish to cache the appearance of your widget, subclass
FramebufferWidget and set
dirty = true when you want to redraw.
See how the screws are implemented for what’s probably the simplest example of using a framebuffer
Ok I think I’ve got it, using
Thanks, as usual
@Vortico: is it legit to add more widgets to a single fb?
I would use fb to process data (let say object x and y, from a ring buffer from audio module), and when its ready/processed, draw the two different child widgets (one for x, one for y):
addChild(pFB = new MyFramebuffer(pModule));
pFB->addChild(new Plot1(pModule, Vec(260, 15), Vec(10, 170)));
pFB->addChild(new Plot2(pModule, Vec(260, 85), Vec(10, 225)));
I’ve tried and it works, not sure if that’s legit for the concept.