diff --git a/pd/nw/pd_canvas.js b/pd/nw/pd_canvas.js index 00f44967d46f5f0f4b9a68cfcfbb977b29c93171..3090f1bc013e5d1d1245c6c06ba1c5712e01af77 100644 --- a/pd/nw/pd_canvas.js +++ b/pd/nw/pd_canvas.js @@ -211,7 +211,9 @@ var canvas_events = (function() { return; } else if (evt.target.classList.contains("clickable_resize_handle")) { // get id ("x123456etcgobj" without the "x" or "gobj") - target_id = "_h" + + target_id = + (evt.target.classList.contains("label_drag_handle") ? + "_l" : "_s") + evt.target.parentNode.id.slice(0,-4).slice(1); last_draggable_x = evt.pageX + svg_view.x; last_draggable_y = evt.pageY + svg_view.y; @@ -532,7 +534,9 @@ var canvas_events = (function() { dy = (evt.pageY + svg_view.y) - last_draggable_y, handle_elem = document.querySelector(".clickable_resize_handle"), - target_id = "_h" + + target_id = + (handle_elem.classList.contains("label_drag_handle") ? + "_l" : "_s") + handle_elem.parentNode.id.slice(0,-4).slice(1), is_canvas_gop_rect = document. getElementsByClassName("gop_drag_handle").length ? @@ -819,6 +823,9 @@ var canvas_events = (function() { // This is a workaround for dragging iemgui labels. Resizing iemguis // currently happens in Pd (canvas_doclick and canvas_motion). (Look // for MA_RESIZE.) + // The exception is my_canvas, which is weird because the visible + // rectangle extends past the bbox that it reports to Pd. + // Unfortunately that means a lot of work to treat it separately. this.none(); document.addEventListener("mousemove", events.iemgui_label_mousemove, false); diff --git a/pd/nw/pdgui.js b/pd/nw/pdgui.js index 636bbce263e2fec91998150bc85941b11c583998..74e30a00128c877d0915be30d9d194b7fe8e4a68 100644 --- a/pd/nw/pdgui.js +++ b/pd/nw/pdgui.js @@ -2447,7 +2447,7 @@ function gui_iemgui_label_font(cid, tag, fontname, fontweight, fontsize) { } // Show or hide little handle for dragging around iemgui labels -function gui_iemgui_label_show_drag_handle(cid, tag, state, x, y) { +function gui_iemgui_label_show_drag_handle(cid, tag, state, x, y, cnv_resize) { var gobj = get_gobj(cid, tag), rect; if (state !== 0) { @@ -2456,14 +2456,17 @@ function gui_iemgui_label_show_drag_handle(cid, tag, state, x, y) { y: y + 3, width: 7, height: 7, - class: (cid === tag) ? "gop_drag_handle" : "label_drag_handle" + class: (cid === tag) ? "gop_drag_handle" : + cnv_resize !== 0 ? "cnv_resize_handle" : "label_drag_handle" }); rect.classList.add("clickable_resize_handle"); gobj.appendChild(rect); } else { if (gobj) { - rect = gobj.getElementsByClassName((cid === tag) ? - "gop_drag_handle" : "label_drag_handle")[0]; + rect = + gobj.getElementsByClassName((cid === tag) ? "gop_drag_handle" : + cnv_resize !== 0 ? "cnv_resize_handle" : + "label_drag_handle")[0]; //rect = get_item(cid, "clickable_resize_handle"); // Need to check for null here... if (rect) { diff --git a/pd/src/g_all_guis.c b/pd/src/g_all_guis.c index 66f63c856f7cb18e707de0927aa40e2a1f27f104..5e30fed6783302a062c991b8128d739b0e7b7899 100644 --- a/pd/src/g_all_guis.c +++ b/pd/src/g_all_guis.c @@ -691,6 +691,8 @@ int maxi(int a, int b) {return a>b?a:b;} float minf(float a, float b) {return a<b?a:b;} float maxf(float a, float b) {return a>b?a:b;} +extern t_class *my_canvas_class; + // in 18 cases only, because canvas does not fit the pattern below. // canvas has no label handle and has a motion handle // but in the case of canvas, the "iemgui" tag is added (it wasn't the case originally) @@ -706,14 +708,12 @@ void scalehandle_draw_select(t_scalehandle *h, int px, int py) { if (!h->h_vis) { sprintf(tagbuf, "x%lx", (long unsigned int)x); - gui_vmess("gui_iemgui_label_show_drag_handle", "xsiii", - canvas, tagbuf, 1, px - sx, py - sy); + gui_vmess("gui_iemgui_label_show_drag_handle", "xsiiii", + canvas, tagbuf, 1, px - sx, py - sy, h->h_scale); h->h_vis = 1; } } -extern t_class *my_canvas_class; - void scalehandle_draw_select2(t_iemgui *x) { t_canvas *canvas=glist_getcanvas(x->x_glist); t_class *c = pd_class((t_pd *)x); @@ -733,7 +733,8 @@ void scalehandle_draw_select2(t_iemgui *x) { } /* we're not drawing the scalehandle for the actual iemgui-- just the one for the label. */ - //scalehandle_draw_select(x->x_handle,sx-1,sy-1); + if (c == my_canvas_class) + scalehandle_draw_select(x->x_handle,sx+8,sy+3); if (x->x_lab != s_empty) scalehandle_draw_select(x->x_lhandle,x->x_ldx,x->x_ldy); } @@ -741,8 +742,8 @@ void scalehandle_draw_select2(t_iemgui *x) { void scalehandle_draw_erase(t_scalehandle *h) { t_canvas *canvas = glist_getcanvas(h->h_glist); if (!h->h_vis) return; - gui_vmess("gui_iemgui_label_show_drag_handle", "xxiii", - h->h_glist, h->h_master, 0, 0, 0); + gui_vmess("gui_iemgui_label_show_drag_handle", "xxiiii", + h->h_glist, h->h_master, 0, 0, 0, h->h_scale); h->h_vis = 0; } @@ -767,7 +768,12 @@ t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale, t_clickha h->h_glist = glist; if (!scale) /* Only bind for labels-- scaling uses pd_vmess in g_editor.c */ { - sprintf(buf, "_h%lx", (t_int)x); + sprintf(buf, "_l%lx", (int)x); + pd_bind((t_pd *)h, h->h_bindsym = gensym(buf)); + } + else if (scale && pd_class((t_pd *)x) == my_canvas_class) + { + sprintf(buf, "_s%lx", (int)x); pd_bind((t_pd *)h, h->h_bindsym = gensym(buf)); } sprintf(h->h_outlinetag, "h%lx", (t_int)h); @@ -783,7 +789,8 @@ t_scalehandle *scalehandle_new(t_object *x, t_glist *glist, int scale, t_clickha } void scalehandle_free(t_scalehandle *h) { - if (!h->h_scale) { /* only binding handles labels, not for scaling guis */ + if (!h->h_scale || pd_class((t_pd *)(h->h_master)) == my_canvas_class) + { /* only binding label handles and my_canvas resize handle */ pd_unbind((t_pd *)h, h->h_bindsym); } pd_free((t_pd *)h); diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 5b3e5a01c91ef22aece1f9c1d43f36a979ba049b..51440e073a6569455370b6c507609286b3c8f49d 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -3306,9 +3306,16 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, int ninlet; /* resize? only for "true" text boxes, canvases, iemguis, and -- using an awful hack-- for the Scope~ object - by checking for the class name below */ + by checking for the class name below. + + One exception-- my_canvas. It has a weirdo interface + where the visual dimensions usually (i.e., by default) + extends well past the bounds of the bbox. For that reason + we have a virtual waterfall of conditionals flowing all + the way to the GUI just handle resizing a stupid rectangle. + */ if (ob && - (ob->te_iemgui + (ob->te_iemgui && pd_class((t_pd *)ob) != my_canvas_class || pd_class(&ob->te_pd)->c_name == gensym("Scope~")) && xpos >= x2-4 && ypos > y2-6) { diff --git a/pd/src/g_mycanvas.c b/pd/src/g_mycanvas.c index e7eafdb8dae2d23554d27f6700fb6a204d71038e..3be396a28cbbae3399726b6ef1f921b02e27fbe3 100644 --- a/pd/src/g_mycanvas.c +++ b/pd/src/g_mycanvas.c @@ -83,8 +83,8 @@ static void my_canvas__motionhook(t_scalehandle *sh, t_floatarg mouse_x, t_float sh->h_dragy = dy; scalehandle_drag_scale(sh); - x->x_gui.x_w += dx; - x->x_gui.x_h += dy; + x->x_vis_w += dx; + x->x_vis_h += dy; if (glist_isvisible(x->x_gui.x_glist)) { diff --git a/pd/src/g_scalar.c b/pd/src/g_scalar.c index 1cc3bff76b7c4401576b83cc180cd3f7ef9c55d3..fa4764c2a838a0b0f4e0c7a58af9562f7b330afd 100644 --- a/pd/src/g_scalar.c +++ b/pd/src/g_scalar.c @@ -1014,7 +1014,8 @@ static void scalar_vis(t_gobj *z, t_glist *owner, int vis) sprintf(tagbuf, "scalar%lx", (long unsigned int)x->sc_vec); gui_vmess("gui_scalar_erase", "xs", glist_getcanvas(owner), tagbuf); - pd_unbind(&x->sc_gobj.g_pd, gensym(buf)); + if (gensym(buf)->s_thing) + pd_unbind(&x->sc_gobj.g_pd, gensym(buf)); } sys_unqueuegui(x);