From 18b4aafda043bead9abb3292d567b5586fdc6137 Mon Sep 17 00:00:00 2001 From: Jonathan Wilkes <jon.w.wilkes@gmail.com> Date: Sat, 30 Apr 2016 00:01:00 -0400 Subject: [PATCH] got scopehandle clicks working... now need to port scopehandle motion by adding a wrapper in canvas_motion of g_editor.c for Scope~ --- externals/miXed/cyclone/sickle/Scope.c | 13 +++++++++++++ pd/src/g_editor.c | 23 ++++++++++++++++++----- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/externals/miXed/cyclone/sickle/Scope.c b/externals/miXed/cyclone/sickle/Scope.c index 241a32ac9..eba867e90 100644 --- a/externals/miXed/cyclone/sickle/Scope.c +++ b/externals/miXed/cyclone/sickle/Scope.c @@ -1022,6 +1022,14 @@ static void scopehandle__clickhook(t_scopehandle *sh, t_floatarg f, t_floatarg x sh->h_dragon = newstate; } +/* wrapper method for forwarding "scopehandle" data */ +static void scope_click_for_resizing(t_scope *x, t_floatarg f, t_floatarg xxx, + t_floatarg yyy) +{ + t_scopehandle *sh = (t_scopehandle *)x->x_handle; + scopehandle__clickhook(sh, f, xxx, yyy); +} + static void scopehandle__motionhook(t_scopehandle *sh, t_floatarg f1, t_floatarg f2) { @@ -1140,6 +1148,11 @@ void Scope_tilde_setup(void) class_addmethod(scope_class, (t_method)scope_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); + /* Big hack for receiving edit-mode resize anchor clicks from + g_editor.c. */ + class_addmethod(scope_class, (t_method)scope_click_for_resizing, + gensym("_click_for_resizing"), + A_FLOAT, A_FLOAT, A_FLOAT, 0); class_setwidget(scope_class, &scope_widgetbehavior); forky_setsavefn(scope_class, scope_save); scopehandle_class = class_new(gensym("_scopehandle"), 0, 0, diff --git a/pd/src/g_editor.c b/pd/src/g_editor.c index 9163f030c..9abae465e 100644 --- a/pd/src/g_editor.c +++ b/pd/src/g_editor.c @@ -3284,8 +3284,13 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, /* look for an outlet we just clicked onto */ int noutlet; int ninlet; - /* resize? only for "true" text boxes or canvases*/ - if (ob && ob->te_iemgui && xpos >= x2-4 && ypos > y2-6) + /* resize? only for "true" text boxes, canvases, iemguis, + and -- using an awful hack-- for the Scope~ object + by checking for the class name below */ + if (ob && + (ob->te_iemgui + || pd_class(&ob->te_pd)->c_name == gensym("Scope~")) + && xpos >= x2-4 && ypos > y2-6) { if (doit) { @@ -3294,9 +3299,17 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, x->gl_editor->e_ywas = y1; x->gl_editor->e_xnew = xpos; x->gl_editor->e_ynew = ypos; - t_pd *sh = (t_pd *)((t_iemgui *)ob)->x_handle; - pd_vmess(sh, gensym("_click"), "fff", - (t_float)1, (t_float)xpos, (t_float)ypos); + if (ob->te_iemgui) + { + t_pd *sh = (t_pd *)((t_iemgui *)ob)->x_handle; + pd_vmess(sh, gensym("_click"), "fff", + (t_float)1, (t_float)xpos, (t_float)ypos); + } + else + { + pd_vmess((t_pd *)ob, gensym("_click_for_resizing"), + "fff", (t_float)1, (t_float)xpos, (t_float)ypos); + } } else { -- GitLab