[PD-dev] how to know if a GUI object is visible in a GOP?

Alexandre Torres Porres porres at gmail.com
Sat Jun 27 02:35:40 CEST 2020


Hi folks, I opened an issue about this on github, but since there was no
answer I'm hoping to get some attention and a possible answer here on the
dev list.

In Pd, if you have graphical objects in a GOP subpatch that are out of the
visible range, it's possible they get drawn, and I opened the issue to
mention that [vradio], for instance, does that (here it is:
https://github.com/pure-data/pure-data/issues/1053 ). I also mentioned n
there how graphs inside a GOP subpatch can also do that. But I also have
this issue with some GUI externals I take care of.

So, is there a way for an object to know if it is visible in the parent
pacth so we do not tell it to get drawn?

What I've now just stumbled upon is our code for cyclone/scope~ -
unlike [vradio], if the object is out of bounds in a GOP and I tell it to
change dimensions, it won't get drawn, but trigger a tcl/tk error instead.
Note that no error happens if the subpatch is opened or if it is inside
bounds (or both of course). Anyway, this line is what triggers the error =>
https://github.com/porres/pd-cyclone/blob/cyclone_0.5-1/cyclone_objects/binaries/audio/scope.c#L495

The error gives me hope there's a way to check if it is possible to do it,
and then not tell it to do it if it's not possible...

I used the "(glist_isvisible())" function to check if it's visible. It
doesn't work as a check because the object is in a GOP, so it'll say it is
visible, even though the object itself is actually out of bounds. Now, in
the case of scope~, it tries to delete the GUI by referring to the subpatch
canvas, and I assume it doesn't work because that window isn't
active/opened.

So if I change the lines below

sys_vgui(".x%lx.c delete all%lx\n", x->x_cv, x);
scope_draw(x, x->x_cv);

To refer to the parent canvas (and not "x->x_cv"), I don't get an error,
but I get the object getting redrawn  in the parent patch outside the
graph, just like the issue I reported with [vradio].

Again, when bumping into this, I thought, since the object knows it can't
delete and redraw (that is, since it gives an error), there could be a way
to check it.

What do you say?

Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-dev/attachments/20200626/ed3a6bb6/attachment.html>


More information about the Pd-dev mailing list