diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 88911058bd47a0eeee71fccc8836d594810ea16d..a1f8a3b07006c187be69c38c8625a39ec57402f2 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -5414,8 +5414,10 @@ static void canvas_paste_xyoffset(t_canvas *x) static void canvas_paste_atmouse(t_canvas *x) { t_selection *sel; + //fprintf(stderr,"paste_atmouse\n"); /* use safe values for x1 and y1 which are essentially the same as xyoffset */ int x1 = x->gl_editor->e_xwas+10, y1 = x->gl_editor->e_ywas+10, init = 0; + t_float sx = 0.0, sy = 0.0; t_glist *g; t_text *t; @@ -5429,13 +5431,19 @@ static void canvas_paste_atmouse(t_canvas *x) // it explicitly here once again to prevent that from being a problem gobj_select((t_gobj *)g, x, 1); } - t = (t_text *)g; - if (!init) { - x1 = t->te_xpix; - y1 = t->te_ypix; - init = 1; - } else if ( t->te_xpix < x1 ) { - x1 = t->te_xpix; + if (pd_class(&((t_gobj *)g)->g_pd) == scalar_class) { + scalar_getbasexy((t_scalar *)g, &sx, &sy); + x1 = (int)sx; + y1 = (int)sy; + } else { + t = (t_text *)g; + if (!init) { + x1 = t->te_xpix; + y1 = t->te_ypix; + init = 1; + } else if ( t->te_xpix < x1 ) { + x1 = t->te_xpix; + } } } /* redraw objects */ @@ -5455,7 +5463,7 @@ static void canvas_dopaste(t_canvas *x, t_binbuf *b) do_not_redraw += 1; int was_dnr = do_not_redraw; - t_gobj *newgobj, *last, *g2; + t_gobj *newgobj, *last, *g2, *first; int dspstate = canvas_suspend_dsp(), nbox, count; int canvas_empty = 0; int offset = 1; @@ -5466,6 +5474,7 @@ static void canvas_dopaste(t_canvas *x, t_binbuf *b) //autopatching variables int connectme, xpix, ypix, indx, nobj; + t_float sx = 0.0, sy = 0.0; connectme = 0; canvas_editmode(x, 1.); @@ -5531,11 +5540,19 @@ static void canvas_dopaste(t_canvas *x, t_binbuf *b) //fprintf(stderr,"dopaste autopatching? %d==%d %d\n", count, nbox, connectme); do_not_redraw -= 1; + // TODO: Ico: because figuring out exact position/size for a scalar is not simple to assess + // and besides, I am not even sure if we can have a scalar with an inlet, + // we currently ignore scalar autopatching + if (connectme == 1 && pd_class(&(x->gl_editor->e_selection->sel_what)->g_pd) == scalar_class) { + connectme = 0; + } + //if we are pasting only one object autoposition it below our selection if (count == nbox+1 && connectme == 1) { + canvas_connect(x, indx, 0, nobj, 0); - //is this universally safe? I think so + //is this universally safe? Not for scalars t_text *z = (t_text *)x->gl_editor->e_selection->sel_what; //fprintf(stderr,"%d %d %d %d\n", z->te_xpix, z->te_ypix, xpix, ypix); diff --git a/pd/src/g_template.c b/pd/src/g_template.c index a90e736d0f18b7abab5d836ea1f5ff0d5a0d794e..70446f764a03a65b125198604a3f5ddab0f6e6bf 100644 --- a/pd/src/g_template.c +++ b/pd/src/g_template.c @@ -1119,7 +1119,7 @@ static void curve_select(t_gobj *z, t_glist *glist, t_word *data, t_template *template, t_float basex, t_float basey, int state) { - fprintf(stderr,"curve_select %d\n", state); + //fprintf(stderr,"curve_select %d\n", state); /* fill in later */ } @@ -1655,12 +1655,12 @@ static void plot_getrect(t_gobj *z, t_glist *glist, t_float xpix1, xpix2, ypix, wpix; t_fielddesc *xfielddesc, *yfielddesc, *wfielddesc; /* if we're the only plot in the glist claim the whole thing */ - if (glist->gl_list && !glist->gl_list->g_next) + /*if (glist->gl_list && !glist->gl_list->g_next) { *xp1 = *yp1 = -0x7fffffff; *xp2 = *yp2 = 0x7fffffff; return; - } + }*/ if (!plot_readownertemplate(x, data, template, &elemtemplatesym, &array, &linewidth, &xloc, &xinc, &yloc, &style, &vis, &scalarvis, &xfielddesc, &yfielddesc, &wfielddesc) && @@ -1751,7 +1751,7 @@ static void plot_select(t_gobj *z, t_glist *glist, t_word *data, t_template *template, t_float basex, t_float basey, int state) { - fprintf(stderr,"plot_select %d\n", state); + //fprintf(stderr,"plot_select %d\n", state); /* not yet */ } @@ -2259,7 +2259,7 @@ static void drawnumber_select(t_gobj *z, t_glist *glist, t_word *data, t_template *template, t_float basex, t_float basey, int state) { - fprintf(stderr,"drawnumber_select %d", state); + //fprintf(stderr,"drawnumber_select %d", state); /* fill in later */ } @@ -2625,7 +2625,7 @@ static void drawsymbol_select(t_gobj *z, t_glist *glist, t_word *data, t_template *template, t_float basex, t_float basey, int state) { - fprintf(stderr,"drawsymbol_select %d", state); + //fprintf(stderr,"drawsymbol_select %d", state); /* fill in later */ } @@ -3006,7 +3006,7 @@ static void drawimage_select(t_gobj *z, t_glist *glist, t_word *data, t_template *template, t_float basex, t_float basey, int state) { - fprintf(stderr,"drawimage_select %d", state); + //fprintf(stderr,"drawimage_select %d", state); /* fill in later */ } @@ -3014,7 +3014,7 @@ static void drawimage_activate(t_gobj *z, t_glist *glist, t_word *data, t_template *template, t_float basex, t_float basey, int state) { - post("drawimage_activate %d", state); + //post("drawimage_activate %d", state); } static void drawimage_vis(t_gobj *z, t_glist *glist, t_scalar *sc,