[PD] c.wavesel~ Was: [filterview~]. Was: Wavesel~ external preview available as deken-type distribution. (Fred Jan Kraan)

Fred Jan Kraan fjkraan at xs4all.nl
Sun Jul 12 12:08:14 CEST 2015


Hi Pierre,

> Hi,
>> Currently I invalidate a layer and start by
>> greating a new one. Is this the correct way, or are they reusable in a way?
> 
> Yes, in fact when you create a layer for the 1st time, the function
> allocates a layer. If the layer already exists but has been invalidated
>  the function returns the old pointer with empty paths. Otherwise, the
> function returns NULL. If you have a "circle_layer" and a
> "rectangle_layer" and you want to change the color or the size of the
> "circle_layer", you have to invalidate the "circle_layer" then when you
> call ebox_draw, you have to redraw the "circle_layer" but you don't have
> to redraw the "rectangle_layer".

In th emean time, I found the problem with superimposed waveforms is
elsewhere, not the object code. With minimize and restore only the
latest waveform is rendered*. So I expect it is in the Tk or g_canvas
code, as the non-cicm version of wavesel~ has the similar problem (not
properly updating the screen, fixed with minimize and restore the
window). It might be the platform: Xubuntu 14.04 with Tk 8.5.
> 
>> The paint function is called at startup from the framework (via
>> eclass_guiinit?).
> 
> No, eclass_guiinit initializes the class for GUI behavior (the paint
> function can't be called because there isn't any object allocated).
> 
>> The redraw function is called when the waveform is changed (manual at
>> the moment).
> 
> Yes, when you want to change a layer, you have to invalidate this layer
>  (you don't have to invalidate all the layers if some of them don't need
> to be redrawn) and then call ebox_redraw(). 
> 
> There's no "redraw", "invalidate", "state" method so
> eclass_addmethod(c, (method) wavesel_invalidate, "invalidate", A_SYMBOL, 0);
> eclass_addmethod(c, (method) wavesel_state, "state", A_NULL, 0);
> eclass_addmethod(c, (method) wavesel_redraw, "redraw", A_NULL, 0);
> are useless methods.

Not in my object. I try to understand what is happening and why it
doesn't do what I want to, so I cut the proces into small steps and
check the in-between status (this is what state does).

They are useless in the sense that they have no function in a properly
working object. The object isn't there yet, but in the process of
debugging and adding functionality.

> I think you use the c.blackboard as a template but you should prefer to
> use c.bang or something simpler. c.blackboard is a little bit tricky.

Yes, I started with c.blackboard but moved elsewhere. c.bang surely has
a lot more comments!
> 
> Now I'll try to explain everything better :
> When the object is allocated in the patch, the method paint is called :
> 
> static void wavesel_paint(t_wavesel *x, t_object *view)
> {
>     t_rect bg_rect;
>     ebox_get_rect_for_view((t_ebox *)x, &bg_rect);
> 
>     t_elayer *g = ebox_start_layer((t_ebox *)x, bg_layer_name,
> rect->width, rect->height);
>    if (g)
>   {
>       Here you can draw what you want in the "bg_layer_name" layer.
>      Then you finish your layer with 
> 
>   }
>   ebox_paint_layer((t_ebox *)x, bg_layer_name, 0.f, 0.f);
> }
> 

This is more or less what is happening, and it works. Apart from the
update issue described above.

Currently the waveform is drawn and the layer state is EGRAPHICS_CLOSE
as expected. But after minimize and restore it is EGRAPHICS_TODRAW
again! I cannot see how the paint function causes this.

I will change the platform and see what happens.


Greetings,

Fred Jan

*) Somewhere in the code cleanup, the waveform restore doesn't happen
anymore.



More information about the Pd-list mailing list