Commit 2b1cb8d6 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*fixed consistency check failed: glist_findrtext when enabling gop and...

*fixed consistency check failed: glist_findrtext when enabling gop and dragging its size around with other text objects on the canvas
*refined checking of gop size due to its text not being hidden, including after saving it to file (from Untitled to something longer, for instance)
parent db6867fc
......@@ -1965,6 +1965,50 @@ extern void canvas_canvas_setundo(t_canvas *x);
extern void graph_checkgop_rect(t_gobj *z, t_glist *glist,
int *xp1, int *yp1, int *xp2, int *yp2);
/* we use the following function after saving to file
gop-enabled canvas with hidetext disabled to check
whether the requested size fits the newfound canvas
name (as reflected in its new filename)
LATER: use this for __clickhook below and possibly
other places as well */
void canvasgop_checksize(t_canvas *x)
if (x->gl_isgraph)
int x1=0, y1=0, x2=0, y2=0;
int dirty=0;
if (x->gl_owner)
gobj_getrect((t_gobj*)x, x->gl_owner,
&x1, &y1, &x2, &y2);
graph_checkgop_rect((t_gobj*)x, x, &x1, &y1, &x2, &y2);
if (x2-x1 > x->gl_pixwidth)
x->gl_pixwidth = x2-x1;
dirty = 1;
if (y2-y1 > x->gl_pixheight)
x->gl_pixheight = y2-y1;
dirty = 1;
if (dirty)
post("Adjusting canvas graph-on-parent area to accomodate its name. If you want to have a smaller graph-on-parent window, please hide graph text.");
canvas_dirty(x, 1);
canvas_fixlinesfor(x, (t_text *)x);
void canvasgop__clickhook(t_scalehandle *sh, int newstate)
t_canvas *x = (t_canvas *)(sh->h_master);
......@@ -136,10 +136,6 @@ int canvas_hasarray(t_canvas *x)
/* JMZ: emit a closebang message */
void canvas_closebang(t_canvas *x);
/* variant of the glist_findrtext found in g_rtext.c
that does not throw a consistency check */
extern t_rtext *glist_tryfindrtext(t_glist *gl, t_text *who);
/* delete an object from a glist and free it */
void glist_delete(t_glist *x, t_gobj *y)
......@@ -149,7 +145,7 @@ void glist_delete(t_glist *x, t_gobj *y)
//fprintf(stderr,"glist_delete YES\n");
t_gobj *g;
t_object *ob;
t_template *tmpl;
t_template *tmpl = NULL;
t_gotfn chkdsp = zgetfn(&y->g_pd, gensym("dsp"));
t_canvas *canvas = glist_getcanvas(x);
int drawcommand = class_isdrawcommand(y->g_pd);
......@@ -251,7 +247,7 @@ void glist_delete(t_glist *x, t_gobj *y)
if (chkdsp) canvas_update_dsp();
if (drawcommand)
if (tmpl && !(canvas_isgroup(canvas) && canvas->gl_unloading))
if (tmpl != NULL && !(canvas_isgroup(canvas) && canvas->gl_unloading))
canvas_redrawallfortemplate(tmpl, 1);
......@@ -798,6 +794,8 @@ int text_ypix(t_text *x, t_glist *glist)
x->te_ypix / (glist->gl_screeny2 - glist->gl_screeny1)));
extern void canvas_updateconnection(t_canvas *x, int lx1, int ly1, int lx2, int ly2, t_int tag);
/* redraw all the items in a glist. We construe this to mean
redrawing in its own window and on parent, as needed in each case.
This is too conservative -- for instance, when you draw an "open"
......@@ -1225,7 +1223,8 @@ static void graph_getrect(t_gobj *z, t_glist *glist,
//fprintf(stderr,"%d %d %d %d\n", x1, y1, x2, y2);
// check if the text is not hidden and if so use that as the
// limit of the gop's size
// limit of the gop's size (we check for hidden flag inside
// the function we point to)
graph_checkgop_rect(z, glist, &x1, &y1, &x2, &y2);
/* fix visibility of edge items for garrays */
......@@ -745,6 +745,7 @@ static void canvas_savetemplatesto(t_canvas *x, t_binbuf *b, int wholething)
void canvas_reload(t_symbol *name, t_symbol *dir, t_gobj *except);
extern void canvasgop_checksize(t_canvas *x);
/* save a "root" canvas to a file; cf. canvas_saveto() which saves the
body (and which is called recursively.) */
......@@ -765,6 +766,8 @@ static void canvas_savetofile(t_canvas *x, t_symbol *filename, t_symbol *dir)
post("saved to: %s/%s", dir->s_name, filename->s_name);
canvas_dirty(x, 0);
if (x->gl_isgraph)
canvas_reload(filename, dir, &x->gl_gobj);
......@@ -1287,12 +1287,16 @@ static void gatom_properties(t_gobj *z, t_glist *owner)
/* -------------------- widget behavior for text objects ------------ */
/* variant of the glist_findrtext found in g_rtext.c
that does not throw a consistency check */
extern t_rtext *glist_tryfindrtext(t_glist *gl, t_text *who);
static void text_getrect(t_gobj *z, t_glist *glist,
int *xp1, int *yp1, int *xp2, int *yp2)
t_text *x = (t_text *)z;
int width, height, iscomment = (x->te_type == T_TEXT);
int width = 0, height = 0, iscomment = (x->te_type == T_TEXT);
t_float x1, y1, x2, y2;
/* for number boxes, we know width and height a priori, and should
......@@ -1337,11 +1341,14 @@ static void text_getrect(t_gobj *z, t_glist *glist,
built. LATER reconsider when "vis" flag should be on and off? */
else if (glist->gl_editor && glist->gl_editor->e_rtext)
t_rtext *y = glist_findrtext(glist, x);
width = rtext_width(y);
height = rtext_height(y) - (iscomment << 1);
t_rtext *y = glist_tryfindrtext(glist, x);
if (y)
width = rtext_width(y);
height = rtext_height(y) - (iscomment << 1);
//fprintf(stderr,"rtext_width=%d\n", width);
//fprintf(stderr,"rtext width=%d height=%d\n", width, height);
/* now find if we have more inlets or outlets than
what can comfortably fit and adjust accordingly
*messages should be aware of $0?
*g_mycanvas does not resize its select area when the mycanvas size is smaller than the select area
*consistency check failed: glist_findrtext when enabling gop and dragging it around?
*verbosity level for the console
*Draw SECONDARY redrect on gop scalar patchers to reflect the viewport?
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment