Commit ec428c62 authored by Ivica Bukvic's avatar Ivica Bukvic
Browse files

*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
parent 67169a70
...@@ -120,7 +120,7 @@ ...@@ -120,7 +120,7 @@
#define SCALE_VSLD_MINHEIGHT 2 #define SCALE_VSLD_MINHEIGHT 2
#define SCALE_VU_MINWIDTH 8 #define SCALE_VU_MINWIDTH 8
#define SCALE_VU_MINHEIGHT 80 #define SCALE_VU_MINHEIGHT 80
#define SCALE_GOP_MINWIDTH 18 #define SCALE_GOP_MINWIDTH 12
#define SCALE_GOP_MINHEIGHT 12 #define SCALE_GOP_MINHEIGHT 12
#define SCALEHANDLE_WIDTH 5 #define SCALEHANDLE_WIDTH 5
......
...@@ -750,6 +750,7 @@ void canvas_draw_gop_resize_hooks(t_canvas* x) ...@@ -750,6 +750,7 @@ void canvas_draw_gop_resize_hooks(t_canvas* x)
void canvas_drawredrect(t_canvas *x, int doit) void canvas_drawredrect(t_canvas *x, int doit)
{ {
if (doit){ if (doit){
//fprintf(stderr,"GOP %d %d\n", x->gl_pixwidth, x->gl_pixheight);
sys_vgui(".x%lx.c create line\ sys_vgui(".x%lx.c create line\
%d %d %d %d %d %d %d %d %d %d -fill #ff8080 -tags GOP\n", %d %d %d %d %d %d %d %d %d %d -fill #ff8080 -tags GOP\n",
glist_getcanvas(x), glist_getcanvas(x),
......
...@@ -4345,6 +4345,9 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av) ...@@ -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, void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
t_floatarg fmod) t_floatarg fmod)
{ {
...@@ -4418,9 +4421,26 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, ...@@ -4418,9 +4421,26 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos,
} }
else if (ob && ob->ob_pd == canvas_class) 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); gobj_vis(y1, x, 0);
((t_canvas *)ob)->gl_pixwidth += xpos - x->gl_editor->e_xnew; ((t_canvas *)ob)->gl_pixwidth += xpos - x->gl_editor->e_xnew;
((t_canvas *)ob)->gl_pixheight += ypos - x->gl_editor->e_ynew; ((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_xnew = xpos;
x->gl_editor->e_ynew = ypos; x->gl_editor->e_ynew = ypos;
canvas_fixlinesfor(x, ob); canvas_fixlinesfor(x, ob);
......
...@@ -1024,16 +1024,16 @@ void graph_checkgop_rect(t_gobj *z, t_glist *glist, ...@@ -1024,16 +1024,16 @@ void graph_checkgop_rect(t_gobj *z, t_glist *glist,
*xp2 = tw + *xp1; *xp2 = tw + *xp1;
if (th + *yp1 > *yp2) if (th + *yp1 > *yp2)
*yp2 = th + *yp1; *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" -- /* get the rectangle, enlarged to contain all the "contents" --
......
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