Commit b136292c authored by Jonathan Wilkes's avatar Jonathan Wilkes
Browse files

first shot at fixing the bug about resizing my_canvas vis size instead of the hotspot size

parent e4801210
......@@ -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);
......
......@@ -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) {
......
......@@ -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-1,sy-1);
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);
......
......@@ -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))
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment