Redrawing whole patch?

    Jul 03 2010 | 4:31 pm
    after having decreased the jbox height either with jbox_set_rect or jbox_set_rect_for_view, the "missing" part of the object (i.e. the "old deleted" portion) is not redrawn. (Sure: this makes sense, since jbox_redraw makes it redraw only the object's graphical box).
    Is there a way, then, to have Max redraw also the "old" "deleted" part of my object?
    Thanks, Daniele Ghisi

    • Jul 04 2010 | 6:06 am
      hum that's odd. changing the size is done in multiple objects without causing this sort of problem. Could you post an example or send it privately if you want?
    • Jul 04 2010 | 6:35 am
      ;max refresh
    • Jul 04 2010 | 7:43 am
      well no "; max refresh" shouldn't be required at all. the patcherview knows when to redraw the context of the obejcts.
    • Jul 04 2010 | 9:00 am
      i just meant as a workaround in cases where the "should" doenst work.
      had to use it in certain situations with bpatcher and lcd on classic mac.
      in max v460 i have never needed it.
    • Jul 04 2010 | 10:00 am
      The minimal code should be quite simple. The only thing that changes with respect to the uisimp5 example is the fact that I have to performe it in the paint method! So, in the paint method I do something like:
      g = (t_jgraphics*) patcherview_get_jgraphics(view); jbox_get_rect_for_view(&x->j_box.b_ob, view, &rect); if (x->add_staff) { rect.height += x->add_staff * 14 * CONST_STEP_Y * x->zoom_y; jbox_set_rect_for_view(&x->j_box.b_ob, view, &rect); x->add_staff = 0; }
      If x->add_staff is negative, rect.height is decreased, and I have the odd behaviour of paint. (even when x->add_staff is positive, the behaviour is odd as well).
      ; max refresh works fine in the patcher (is there a way to do that in the code?), still I guess I'm doing something wrong in the code...
      Thanks, Daniele
    • Jul 04 2010 | 10:35 am
      What seems strange is to change the size of the object within the paint method. You shouldn't really do that there. But if you have to you might need to call jbox_redraw() after. I bet thought that this could be done in the oksize method, or somewhere else in the code, in reaction to a message or something like that which would then call jbox_redraw. Does it makes sense?
    • Jul 04 2010 | 11:42 am
      Yes, definitely. It can be done somewhere else. Actually, since the change of dimension is linked with the change of an attribute, the best way would be to do that inside the attribute setter. But I eventually managed to do that in the paint() method, since in the attribute setter I had no t_object *patcherview to deal with, so I didn't know how to get-set rect for view. Is there a way to get the *patcherview inside such a setter?
      (btw, I've never come across the oksize method in the examples... is it somehow automatically called? with which syntax?)
      thanks again
    • Jul 04 2010 | 12:43 pm
      You don't really need to get the patcherview, you can get the query the patching/presentation size using:
      jbox_get_presentation_size((t_object *)pointertoyourobject, &a_t_rect) jbox_get_patching_size((t_object *)pointertoyourobject, &a_t_rect)
      then you've the equivalent setter:
      jbox_set_presentation_size((t_object *)pointertoyourobject, &a_t_size) jbox_set_patching_size((t_object *)pointertoyourobject, &a_t_size)
      The oksize method is called when you resize the object (manually or with the method above. The method is called with a t_rect * as argument.
      long yourobject_oksize(t_yourobject *x, t_rect *nr)
      	if (nr->width < x->minwidth)
      		nr->width = x->minwidth)
      	if (nr->height < x->minheight)
      		nr->height= x->minheight;
      	return 0;
    • Jul 04 2010 | 12:56 pm
      Coool! Now everything works fine. Thanks, Emmanuel!