diff --git a/src/g_array.c b/src/g_array.c index 2c28c355540cd350872a4a548835a2c72e919a0e..bafe8ac07f02017ebea19fab2cdb6ca04c744a5c 100644 --- a/src/g_array.c +++ b/src/g_array.c @@ -350,6 +350,7 @@ t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *templateargsym, void canvas_menuarray(t_glist *canvas) { t_glist *x = (t_glist *)canvas; + pd_vmess(&x->gl_pd, gensym("editmode"), "i", 1); char cmdbuf[200]; sprintf(cmdbuf, "pdtk_array_dialog %%s array%d 100 3 1 .x%lx\n", gcount+1, (long unsigned int)canvas); gfxstub_new(&x->gl_pd, x, cmdbuf); @@ -652,7 +653,6 @@ static t_float array_motion_xperpix; static t_float array_motion_yperpix; static int array_motion_lastx; static int array_motion_fatten; -static t_garray* array_garray; /* LATER protect against the template changing or the scalar disappearing probably by attaching a gpointer here ... */ @@ -662,7 +662,9 @@ static void array_motion(void *z, t_floatarg dx, t_floatarg dy) array_motion_xcumulative += dx * array_motion_xperpix; array_motion_ycumulative += dy * array_motion_yperpix; - t_glist *graph = array_garray->x_glist; + // used to set up boundaries and update sends accordingly + t_glist *graph = NULL; + if (array_garray != NULL) graph = array_garray->x_glist; if (array_motion_xfield) { @@ -712,13 +714,15 @@ static void array_motion(void *z, t_floatarg dx, t_floatarg dy) (t_word *)(((char *)array_motion_wp) + array_motion_elemsize * array_motion_lastx), 1); - if (graph->gl_y1 > graph->gl_y2) { - if (newy > graph->gl_y1) newy = graph->gl_y1; - if (newy < graph->gl_y2) newy = graph->gl_y2; - } - else { - if (newy < graph->gl_y1) newy = graph->gl_y1; - if (newy > graph->gl_y2) newy = graph->gl_y2; + if (graph) { + if (graph->gl_y1 > graph->gl_y2) { + if (newy > graph->gl_y1) newy = graph->gl_y1; + if (newy < graph->gl_y2) newy = graph->gl_y2; + } + else { + if (newy < graph->gl_y1) newy = graph->gl_y1; + if (newy > graph->gl_y2) newy = graph->gl_y2; + } } //fprintf(stderr, "y = %f\n", newy); t_float ydiff = newy - oldy; @@ -747,7 +751,7 @@ static void array_motion(void *z, t_floatarg dx, t_floatarg dy) array_redraw(array_motion_array, array_motion_glist); /* send a bang to the associated send to reflect the change via mouse click/drag */ - if (array_garray->x_send->s_thing) pd_bang(array_garray->x_send->s_thing); + if (graph && array_garray->x_send->s_thing) pd_bang(array_garray->x_send->s_thing); } int scalar_doclick(t_word *data, t_template *template, t_scalar *sc, diff --git a/src/g_canvas.c b/src/g_canvas.c index 7f99df9670c21ed31f289f2e6596924b6dbaacc5..2f032a12d6ef37c4983669f6072f170bfd3dbfeb 100644 --- a/src/g_canvas.c +++ b/src/g_canvas.c @@ -593,6 +593,7 @@ t_glist *glist_addglist(t_glist *g, t_symbol *sym, /* call glist_addglist from a Pd message */ void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv) { + pd_vmess(&g->gl_pd, gensym("editmode"), "i", 1); t_symbol *sym = atom_getsymbolarg(0, argc, argv); /* if we wish to put a graph where the mouse is we need to replace bogus name */ if (!strcmp(sym->s_name, "NULL")) sym = &s_; diff --git a/src/g_canvas.h b/src/g_canvas.h index f2c970315ed65505a16d5f0be186f127fc84e31e..d73c6ac8fee1f892a3e96576b314b8750183a6f3 100644 --- a/src/g_canvas.h +++ b/src/g_canvas.h @@ -150,6 +150,9 @@ typedef struct _arrayvis t_garray *av_garray; /* owning structure */ } t_arrayvis; +t_garray* array_garray; /* used for sending bangs when + array is changed via gui */ + /* the t_tick structure describes where to draw x and y "ticks" for a glist */ typedef struct _tick /* where to put ticks on x or y axes */ diff --git a/src/g_editor.c b/src/g_editor.c index d72d8b991efd7b5b847c83d873e4f98c72f6ab9f..be6654a883720d903afc1ee9bd031f4e00204347 100644 --- a/src/g_editor.c +++ b/src/g_editor.c @@ -1776,6 +1776,12 @@ static int canvas_upx, canvas_upy; void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, int mod, int doit) { + /* here we make global array_garray pointer defined in g_canvas.h + point back to nothing--we use this pointer to pass information + to array_motion so that we can update corresponding send when + the array has been changed */ + array_garray = NULL; + t_gobj *y; int shiftmod, runmode, altmod, doublemod = 0, rightclick; int x1=0, y1=0, x2=0, y2=0, clickreturned = 0; diff --git a/src/m_pd.h b/src/m_pd.h index cbd01f40c0a792dd706e097ca3bb9c455e565f21..76edfdf6145cd094816992b81cafabd6b53f5a55 100644 --- a/src/m_pd.h +++ b/src/m_pd.h @@ -11,7 +11,7 @@ extern "C" { #define PD_MAJOR_VERSION 0 #define PD_MINOR_VERSION 42 #define PD_BUGFIX_VERSION 5 -#define PD_TEST_VERSION "extended-l2ork-20110416" +#define PD_TEST_VERSION "extended-l2ork-20110418" /* old name for "MSW" flag -- we have to take it for the sake of many old "nmakefiles" for externs, which will define NT and not MSW */