From ec428c62738d5ae725f995bfdfc42f1627becdfe Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Tue, 20 Aug 2013 15:14:48 -0400 Subject: [PATCH] *added check for minimal size when resizing GOP objects *fixed axes get inverted when going beyond the allowed range *fixed min size based on nlets when text shown --- pd/src/g_all_guis.h | 2 +- pd/src/g_canvas.c | 1 + pd/src/g_editor.c | 20 ++++++++++++++++++++ pd/src/g_graph.c | 18 +++++++++--------- 4 files changed, 31 insertions(+), 10 deletions(-) diff --git a/pd/src/g_all_guis.h b/pd/src/g_all_guis.h index 67baa07a4..5f0fc7f93 100644 --- a/pd/src/g_all_guis.h +++ b/pd/src/g_all_guis.h @@ -120,7 +120,7 @@ #define SCALE_VSLD_MINHEIGHT 2 #define SCALE_VU_MINWIDTH 8 #define SCALE_VU_MINHEIGHT 80 -#define SCALE_GOP_MINWIDTH 18 +#define SCALE_GOP_MINWIDTH 12 #define SCALE_GOP_MINHEIGHT 12 #define SCALEHANDLE_WIDTH 5 diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index d86b4bba6..505190331 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -750,6 +750,7 @@ void canvas_draw_gop_resize_hooks(t_canvas* x) void canvas_drawredrect(t_canvas *x, int doit) { if (doit){ + //fprintf(stderr,"GOP %d %d\n", x->gl_pixwidth, x->gl_pixheight); sys_vgui(".x%lx.c create line\ %d %d %d %d %d %d %d %d %d %d -fill #ff8080 -tags GOP\n", glist_getcanvas(x), diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index ce3d0ab94..e6585c3a1 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -4345,6 +4345,9 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av) } } +extern void graph_checkgop_rect(t_gobj *z, t_glist *glist, + int *xp1, int *yp1, int *xp2, int *yp2); + void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, t_floatarg fmod) { @@ -4418,9 +4421,26 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, } else if (ob && ob->ob_pd == canvas_class) { + int tmpx1 = 0, tmpy1 = 0, tmpx2 = 0, tmpy2 = 0; + int tmp_x_final = 0, tmp_y_final = 0; gobj_vis(y1, x, 0); ((t_canvas *)ob)->gl_pixwidth += xpos - x->gl_editor->e_xnew; ((t_canvas *)ob)->gl_pixheight += ypos - x->gl_editor->e_ynew; + graph_checkgop_rect((t_gobj *)ob, x, &tmpx1, &tmpy1, &tmpx2, &tmpy2); + tmpx1 = ob->te_xpix; + tmpy1 = ob->te_ypix; + //fprintf(stderr,"%d %d %d %d\n", tmpx1, tmpy1, tmpx2, tmpy2); + if (!((t_canvas *)ob)->gl_hidetext) { + tmp_x_final = tmpx2 - tmpx1; + tmp_y_final = tmpy2 - tmpy1; + } else { + tmp_x_final = tmpx2; + tmp_y_final = tmpy2; + } + if (tmp_x_final > ((t_canvas *)ob)->gl_pixwidth) + ((t_canvas *)ob)->gl_pixwidth = tmp_x_final; + if (tmp_y_final > ((t_canvas *)ob)->gl_pixheight) + ((t_canvas *)ob)->gl_pixheight = tmp_y_final; x->gl_editor->e_xnew = xpos; x->gl_editor->e_ynew = ypos; canvas_fixlinesfor(x, ob); diff --git a/pd/src/g_graph.c b/pd/src/g_graph.c index 4134ce413..997d08c3d 100644 --- a/pd/src/g_graph.c +++ b/pd/src/g_graph.c @@ -1024,16 +1024,16 @@ void graph_checkgop_rect(t_gobj *z, t_glist *glist, *xp2 = tw + *xp1; if (th + *yp1 > *yp2) *yp2 = th + *yp1; - } else { - // failsafe where we cannot have a gop that is smaller than 1x1 pixels - // when the text is hidden - int in = obj_ninlets(pd_checkobject(&z->g_pd)) * IOWIDTH; - int out = obj_noutlets(pd_checkobject(&z->g_pd)) * IOWIDTH; - int minhsize = (in >= out ? in : out); - int minvsize = ((in > 0 ? 1 : 0) + (out > 0 ? 1 : 0)) * 2 + 6; - if (*xp2 < *xp1+minhsize) *xp2 = *xp1+minhsize; - if (*yp2 < *yp1+minvsize) *yp2 = *yp1+minvsize; } + // failsafe where we cannot have a gop that is smaller than 1x1 pixels + // regardless whether the text is hidden + int in = obj_ninlets(pd_checkobject(&z->g_pd)) * IOWIDTH; + int out = obj_noutlets(pd_checkobject(&z->g_pd)) * IOWIDTH; + int minhsize = (in >= out ? in : out) + SCALE_GOP_MINWIDTH; + int minvsize = ((in > 0 ? 1 : 0) + (out > 0 ? 1 : 0)) * 2 + SCALE_GOP_MINHEIGHT; + if (*xp2 < *xp1+minhsize) *xp2 = *xp1+minhsize; + if (*yp2 < *yp1+minvsize) *yp2 = *yp1+minvsize; + } /* get the rectangle, enlarged to contain all the "contents" -- -- GitLab