diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js index 7c7aa77e269d05a183a6993c5fd04b036975a877..265b8a399ff41b80c072f912311a11a4efbfce06 100644 --- a/pd/nw/pd_canvas.js +++ b/pd/nw/pd_canvas.js @@ -630,6 +630,10 @@ var canvas_events = (function() { gui.Window.get().on("blur", function() { nw_window_blur_callback(name); }); + gui.Window.get().on("move", function(x, y) { + var w = gui.Window.get(); + pdgui.pdsend(name, "setbounds", x, y, x + w.width, y + w.height); + }); // set minimum window size gui.Window.get().setMinimumSize(150, 100); diff --git a/pd/src/g_canvas.c b/pd/src/g_canvas.c index 1eaade0089ebec06a3a12b68786e45fbc82474ca..83f872af0005f6e72c2fb1c894a85710f51dc84c 100644 --- a/pd/src/g_canvas.c +++ b/pd/src/g_canvas.c @@ -51,7 +51,7 @@ t_canvas *canvas_whichfind; /* last canvas we did a find in */ static void canvas_start_dsp(void); static void canvas_stop_dsp(void); static void canvas_drawlines(t_canvas *x); -void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2); +void canvas_dosetbounds(t_canvas *x, int x1, int y1, int x2, int y2); void canvas_reflecttitle(t_canvas *x); static void canvas_addtolist(t_canvas *x); static void canvas_takeofflist(t_canvas *x); @@ -423,7 +423,7 @@ t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv) x->gl_y1 = 0; x->gl_x2 = 1; x->gl_y2 = 1; - canvas_setbounds(x, xloc, yloc, xloc + width, yloc + height); + canvas_dosetbounds(x, xloc, yloc, xloc + width, yloc + height); x->gl_owner = owner; x->gl_isclone = 0; x->gl_name = (*s->s_name ? s : @@ -609,9 +609,8 @@ int glist_isgraph(t_glist *x) return (x->gl_isgraph|(x->gl_hidetext<<1)); } - /* This is sent from the GUI to inform a toplevel that its window has been - moved or resized. */ -void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2) +/* bounds-setting for patch/subpatch windows */ +void canvas_dosetbounds(t_canvas *x, int x1, int y1, int x2, int y2) { //fprintf(stderr,"canvas_setbounds %d %d %d %d\n", x1, y1, x2, y2); @@ -643,6 +642,14 @@ void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2) } } + /* public method to set the bounds for a patch/subpatch window from the + GUI. */ +static void canvas_setbounds(t_canvas *x, t_float left, t_float top, + t_float right, t_float bottom) +{ + canvas_dosetbounds(x, (int)left, (int)top, (int)right, (int)bottom); +} + t_symbol *canvas_makebindsym(t_symbol *s) { char buf[MAXPDSTRING]; @@ -1247,7 +1254,7 @@ static void canvas_relocate(t_canvas *x, t_symbol *canvasgeom, /* for some reason this is initially called with cw=ch=1 so we just suppress that here. */ if (cw > 5 && ch > 5) - canvas_setbounds(x, txpix, typix, + canvas_dosetbounds(x, txpix, typix, txpix + cw, typix + ch); /* readjust garrays (if any) */ t_gobj *g; @@ -2499,6 +2506,8 @@ void g_canvas_setup(void) A_DEFFLOAT, A_NULL); class_addmethod(canvas_class, (t_method)canvas_loadbang, gensym("loadbang"), A_NULL); + class_addmethod(canvas_class, (t_method)canvas_setbounds, + gensym("setbounds"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL); class_addmethod(canvas_class, (t_method)canvas_relocate, gensym("relocate"), A_SYMBOL, A_SYMBOL, A_NULL); class_addmethod(canvas_class, (t_method)canvas_vis, diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index e117ccfc7c50f1c4cc35e5bb81c729d3027f63d2..436e113fe6085b65c6d390d7308f32ba92290d41 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -68,7 +68,6 @@ static int screeny2; static int copiedfont; static void canvas_dofont(t_canvas *x, t_floatarg font, t_floatarg xresize, t_floatarg yresize); -extern void canvas_setbounds(t_canvas *x, int x1, int y1, int x2, int y2); int canvas_apply_restore_original_position(t_canvas *x, int orig_pos); extern void canvas_draw_gop_resize_hooks(t_canvas *x); static void canvas_font(t_canvas *x, t_floatarg font, t_floatarg oldfont, @@ -6237,8 +6236,6 @@ static void canvas_dopaste(t_canvas *x, t_binbuf *b) x->gl_screenx2 = screenx1 + screenx2; x->gl_screeny1 = screeny1; x->gl_screeny2 = screeny1 + screeny2; - //canvas_setbounds(x, screenx1, screeny1, - // screenx1+screenx2, screeny1+screeny2); gui_vmess("gui_canvas_change_geometry", "xiiii", x, (int)(x->gl_screenx2 - x->gl_screenx1),