From a371f77034669e1618c5f6e14b397b8c6ee9fd01 Mon Sep 17 00:00:00 2001 From: Ivica Ico Bukvic <ico@vt.edu> Date: Tue, 9 Sep 2014 22:26:23 -0400 Subject: [PATCH] *fixed offset regression with the K12 module --- pd/src/g_editor.c | 87 +++++++++++++++++++++++++---------------------- pd/src/g_text.c | 2 +- 2 files changed, 47 insertions(+), 42 deletions(-) diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index e744630bf..067062f74 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -3702,49 +3702,52 @@ void canvas_drawconnection(t_canvas *x, int lx1, int ly1, int lx2, int ly2, void canvas_updateconnection(t_canvas *x, int lx1, int ly1, int lx2, int ly2, t_int tag) { - int ymax = 0; - int halfx = (lx2 - lx1)/2; - int halfy = (ly2 - ly1)/2; - //int yoff = (abs(halfx)+abs(halfy))/2; - int yoff = abs(halfy); - //if (yoff < 2) yoff = 2; - if (halfy >= 0) - { - //second object is below the first - if (abs(halfx) <=10) + if (glist_isvisible(x) && glist_istoplevel(x)) + { + int ymax = 0; + int halfx = (lx2 - lx1)/2; + int halfy = (ly2 - ly1)/2; + //int yoff = (abs(halfx)+abs(halfy))/2; + int yoff = abs(halfy); + //if (yoff < 2) yoff = 2; + if (halfy >= 0) + { + //second object is below the first + if (abs(halfx) <=10) + { + ymax = abs(halfy * pow((halfx/10.0),2)); + if (ymax > 10) ymax = 10; + } + else ymax = 10; + } + else { - ymax = abs(halfy * pow((halfx/10.0),2)); - if (ymax > 10) ymax = 10; + //second object is above the first + ymax = 20; + } + //fprintf(stderr,"pow%f halfx%d yoff%d ymax%d\n", + // pow((halfx/10.0),2), halfx, yoff, ymax); + if (yoff > ymax) yoff = ymax; + if (tag) + { + //sys_vgui(".x%lx.c coords l%lx %d %d %d %d\n", + // x, tag, lx1, ly1, lx2, ly2); + //bezier curves FTW + sys_vgui(".x%lx.c coords l%lx " + "\"M %d %d Q %d %d %d %d Q %d %d %d %d\"\n", + x, tag, lx1, ly1, + lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy, + lx2, ly2 - yoff, lx2, ly2); + } + else + { + //sys_vgui(".x%lx.c coords x %d %d %d %d\n", x, lx1, ly1, lx2, ly2); + //bezier curves FTW + sys_vgui(".x%lx.c coords x \"M %d %d Q %d %d %d %d Q %d %d %d %d\"\n", + x, lx1, ly1, + lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy, + lx2, ly2 - yoff, lx2, ly2); } - else ymax = 10; - } - else - { - //second object is above the first - ymax = 20; - } - //fprintf(stderr,"pow%f halfx%d yoff%d ymax%d\n", - // pow((halfx/10.0),2), halfx, yoff, ymax); - if (yoff > ymax) yoff = ymax; - if (tag) - { - //sys_vgui(".x%lx.c coords l%lx %d %d %d %d\n", - // x, tag, lx1, ly1, lx2, ly2); - //bezier curves FTW - sys_vgui(".x%lx.c coords l%lx " - "\"M %d %d Q %d %d %d %d Q %d %d %d %d\"\n", - x, tag, lx1, ly1, - lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy, - lx2, ly2 - yoff, lx2, ly2); - } - else - { - //sys_vgui(".x%lx.c coords x %d %d %d %d\n", x, lx1, ly1, lx2, ly2); - //bezier curves FTW - sys_vgui(".x%lx.c coords x \"M %d %d Q %d %d %d %d Q %d %d %d %d\"\n", - x, lx1, ly1, - lx1, ly1 + yoff, lx1 + halfx, ly1 + halfy, - lx2, ly2 - yoff, lx2, ly2); } } @@ -4991,6 +4994,8 @@ void canvas_motion(t_canvas *x, t_floatarg xpos, t_floatarg ypos, glist_setlastxymod(x, xpos, ypos, mod); if (x->gl_editor->e_onmotion == MA_MOVE) { + //fprintf(stderr,"%g %g %d %d\n", xpos - x->gl_editor->e_xwas, + // ypos - x->gl_editor->e_ywas, x->gl_editor->e_xwas, x->gl_editor->e_ywas); canvas_displaceselection(x, xpos - x->gl_editor->e_xwas, ypos - x->gl_editor->e_ywas); x->gl_editor->e_xwas = xpos; diff --git a/pd/src/g_text.c b/pd/src/g_text.c index d222cfb6c..7a85776dd 100644 --- a/pd/src/g_text.c +++ b/pd/src/g_text.c @@ -395,11 +395,11 @@ void canvas_obj_abstraction_from_menu(t_glist *gl, t_symbol *s, } else if (connectme == 0) { + glist_setlastxy(glist_getcanvas(gl), xpix, ypix); canvas_startmotion(glist_getcanvas(gl)); } canvas_undo_add(glist_getcanvas(gl), 9, "create", (void *)canvas_undo_set_create(glist_getcanvas(gl))); - glist_setlastxy(glist_getcanvas(gl), xpix, ypix); } /* make an object box for an object that's already there. */ -- GitLab