Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7154
Modified Files: Tag: impd_0_37 g_canvas.c g_editor.c u_main.tk Log Message: patchcord click detection now moved to Tk
Index: g_editor.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_editor.c,v retrieving revision 1.1.1.4.2.3.2.6 retrieving revision 1.1.1.4.2.3.2.7 diff -C2 -d -r1.1.1.4.2.3.2.6 -r1.1.1.4.2.3.2.7 *** g_editor.c 30 Mar 2004 01:54:09 -0000 1.1.1.4.2.3.2.6 --- g_editor.c 30 Mar 2004 04:57:55 -0000 1.1.1.4.2.3.2.7 *************** *** 30,62 **** /* ---------------- generic widget behavior ------------------------- */
! void gobj_getrect(t_gobj *x, t_glist *glist, int *x1, int *y1, int *x2, int *y2) ! {if (x->g_pd->c_wb && x->g_pd->c_wb->w_getrectfn) ! (*x->g_pd->c_wb->w_getrectfn)(x, glist, x1, y1, x2, y2);}
! void gobj_displace(t_gobj *x, t_glist *glist, int dx, int dy) ! {if (x->g_pd->c_wb && x->g_pd->c_wb->w_displacefn) ! (*x->g_pd->c_wb->w_displacefn)(x, glist, dx, dy);}
! void gobj_select(t_gobj *x, t_glist *glist, int state) ! {if (x->g_pd->c_wb && x->g_pd->c_wb->w_selectfn) ! (*x->g_pd->c_wb->w_selectfn)(x, glist, state);}
! void gobj_activate(t_gobj *x, t_glist *glist, int state) ! {if (x->g_pd->c_wb && x->g_pd->c_wb->w_activatefn) ! (*x->g_pd->c_wb->w_activatefn)(x, glist, state);}
! void gobj_delete(t_gobj *x, t_glist *glist) ! {if (x->g_pd->c_wb && x->g_pd->c_wb->w_deletefn) ! (*x->g_pd->c_wb->w_deletefn)(x, glist);}
! void gobj_vis(t_gobj *x, struct _glist *glist, int flag) ! {if (x->g_pd->c_wb && x->g_pd->c_wb->w_visfn) ! (*x->g_pd->c_wb->w_visfn)(x, glist, flag);}
int gobj_click(t_gobj *x, struct _glist *glist, ! int xpix, int ypix, int shift, int alt, int dbl, int doit) ! {if (x->g_pd->c_wb && x->g_pd->c_wb->w_clickfn) ! return (*x->g_pd->c_wb->w_clickfn)(x, glist, xpix, ypix, shift, alt, dbl, doit); ! else return 0;}
/* ------------------------ managing the selection ----------------- */ --- 30,62 ---- /* ---------------- generic widget behavior ------------------------- */
! void gobj_getrect(t_gobj *x, t_glist *glist, int *x1, int *y1, int *x2, int *y2) { ! struct _widgetbehavior *b = x->g_pd->c_wb; ! if (b && b->w_getrectfn) (*b->w_getrectfn)(x, glist, x1, y1, x2, y2);}
! void gobj_displace(t_gobj *x, t_glist *glist, int dx, int dy) { ! struct _widgetbehavior *b = x->g_pd->c_wb; ! if (b && b->w_displacefn) (*b->w_displacefn)(x, glist, dx, dy);}
! void gobj_select(t_gobj *x, t_glist *glist, int state) { ! struct _widgetbehavior *b = x->g_pd->c_wb; ! if (b && b->w_selectfn) (*b->w_selectfn)(x, glist, state);}
! void gobj_activate(t_gobj *x, t_glist *glist, int state) { ! struct _widgetbehavior *b = x->g_pd->c_wb; ! if (b && b->w_activatefn) (*b->w_activatefn)(x, glist, state);}
! void gobj_delete(t_gobj *x, t_glist *glist) { ! struct _widgetbehavior *b = x->g_pd->c_wb; ! if (b && b->w_deletefn) (*b->w_deletefn)(x, glist);}
! void gobj_vis(t_gobj *x, struct _glist *glist, int flag) { ! struct _widgetbehavior *b = x->g_pd->c_wb; ! if (b && b->w_visfn) (*b->w_visfn)(x, glist, flag);}
int gobj_click(t_gobj *x, struct _glist *glist, ! int xpix, int ypix, int shift, int alt, int dbl, int doit) { ! struct _widgetbehavior *b = x->g_pd->c_wb; ! if (b && b->w_clickfn) return (*b->w_clickfn)(x, glist, xpix, ypix, shift, alt, dbl, doit); ! return 0;}
/* ------------------------ managing the selection ----------------- */ *************** *** 880,901 **** #endif
! /* mouse click */ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, int mod, int doit) { ! t_gobj *y; ! int shiftmod, runmode, altmod, rightclick; int x1, y1, x2, y2, clickreturned = 0; ! if (!x->gl_editor) {bug("editor"); return;}
- shiftmod = mod & SHIFTMOD; - runmode = (mod & CTRLMOD) || !x->gl_edit; - altmod = mod & ALTMOD; - rightclick = mod & RIGHTCLICK; - canvas_undo_already_set_move = 0;
! /* if keyboard was grabbed, notify grabber and cancel the grab */ if (doit && x->gl_editor->e_grab && x->gl_editor->e_keyfn) { --- 880,933 ---- #endif
! void canvas_find_wire(t_canvas *self, t_symbol *linesym, t_outconnect **oc, ! int *obj1, int *port1, int *obj2, int *port2) { ! t_outconnect *w; ! t_linetraverser t; ! t_glist *g = glist_getcanvas(self); ! if (sscanf(linesym->s_name,"l%x",oc)<1) { ! bug("%s:%d BERSERK!\n",__FILE__,__LINE__); ! } ! linetraverser_start(&t, g); ! while (0!=(w=linetraverser_next(&t))) if (*oc==w) break; ! if (!w) bug("%s:%d BERSERK!\n",__FILE__,__LINE__); ! *obj1 = canvas_getindex(g, &t.tr_ob->ob_g); *port1 = t.tr_outno; ! *obj2 = canvas_getindex(g, &t.tr_ob2->ob_g); *port2 = t.tr_inno; ! canvas_setcursor(self, CURSOR_EDITMODE_DISCONNECT); ! } ! ! void canvas_click_on_wire(t_canvas *self, t_symbol *linesym, ! t_float x, t_float y, t_float b, t_float f) { ! post("canvas_click_on_wire: 0x%08x %s %f %f %f %f", ! (unsigned)self, linesym->s_name, x, y, b, f); ! int mod = (int)f; ! int shiftmod = mod & SHIFTMOD; ! int runmode = (mod & CTRLMOD) || !self->gl_edit; ! int altmod = mod & ALTMOD; ! int rightclick = mod & RIGHTCLICK; ! //post("shiftmod=%d runmode=%d altmod=%d rightclick=%d b=%f f=%f",shiftmod,runmode,altmod,rightclick,b,f); ! if (!runmode && !altmod && !shiftmod && !rightclick) { ! t_outconnect *oc; ! int obj1,port1,obj2,port2; ! post("canvas_click_on_wire: selecting this one..."); ! canvas_find_wire(self,linesym,&oc,&obj1,&port1,&obj2,&port2); ! glist_selectline(glist_getcanvas(self),oc,obj1,port1,obj2,port2); ! } ! } ! ! /* mouse click */ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which, int mod, int doit) { ! int shiftmod = mod & SHIFTMOD; ! int runmode = (mod & CTRLMOD) || !x->gl_edit; ! int altmod = mod & ALTMOD; ! int rightclick = mod & RIGHTCLICK; int x1, y1, x2, y2, clickreturned = 0; ! t_gobj *y; if (!x->gl_editor) {bug("editor"); return;}
canvas_undo_already_set_move = 0;
! /* if keyboard was grabbed, notify grabber and cancel the grab */ if (doit && x->gl_editor->e_grab && x->gl_editor->e_keyfn) { *************** *** 992,997 **** else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT); } ! else if (doit) ! goto nooutletafterall; } /* look for an inlet */ --- 1024,1028 ---- else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT); } ! else if (doit) goto nooutletafterall; } /* look for an inlet */ *************** *** 1005,1010 **** canvas_inlettip(x,ob,closest,xpos,ypos); } ! ! /* not in an outlet; select and move */ else if (doit) { --- 1036,1040 ---- canvas_inlettip(x,ob,closest,xpos,ypos); } ! /* not in an outlet; select and move */ else if (doit) { *************** *** 1035,1076 **** return; } ! ! /* if right click doesn't hit any boxes, call rightclick ! routine anyway */ if (rightclick) canvas_rightclick(x, xpos, ypos, 0);
- /* if not an editing action, and if we didn't hit a box, set cursor and return */ if (runmode || rightclick) {canvas_setcursor(x, CURSOR_RUNMODE_NOTHING); return;} - - /* having failed to find a box, we try lines now. */ - if (!runmode && !altmod && !shiftmod) - { - t_linetraverser t; - t_outconnect *oc; - float fx = xpos, fy = ypos; - t_glist *glist2 = glist_getcanvas(x); - linetraverser_start(&t, glist2); - while (oc = linetraverser_next(&t)) - { - float lx1 = t.tr_lx1, ly1 = t.tr_ly1; - float lx2 = t.tr_lx2, ly2 = t.tr_ly2; - float dlx = lx2-lx1, dly = ly2-ly1; - float area = dlx*(fy-ly1) - dly*(fx - lx1); - float dsquare = dlx*dlx + dly*dly; - if (area * area >= 50 * dsquare) continue; - if (dlx*(fx-lx1) + dly*(fy-ly1) < 0) continue; - if (dlx*(lx2-fx) + dly*(ly2-fy) < 0) continue; - if (doit) - { - glist_selectline(glist2, oc, - canvas_getindex(glist2, &t.tr_ob->ob_g), t.tr_outno, - canvas_getindex(glist2, &t.tr_ob2->ob_g), t.tr_inno); - } - canvas_setcursor(x, CURSOR_EDITMODE_DISCONNECT); - return; - } - } canvas_setcursor(x, CURSOR_EDITMODE_NOTHING); if (doit) --- 1065,1074 ---- return; } ! /* if right click doesn't hit any boxes, call rightclick routine anyway */ if (rightclick) canvas_rightclick(x, xpos, ypos, 0);
/* if not an editing action, and if we didn't hit a box, set cursor and return */ if (runmode || rightclick) {canvas_setcursor(x, CURSOR_RUNMODE_NOTHING); return;} canvas_setcursor(x, CURSOR_EDITMODE_NOTHING); if (doit)
Index: u_main.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/u_main.tk,v retrieving revision 1.1.1.4.2.7.4.27 retrieving revision 1.1.1.4.2.7.4.28 diff -C2 -d -r1.1.1.4.2.7.4.27 -r1.1.1.4.2.7.4.28 *** u_main.tk 30 Mar 2004 01:35:09 -0000 1.1.1.4.2.7.4.27 --- u_main.tk 30 Mar 2004 04:57:55 -0000 1.1.1.4.2.7.4.28 *************** *** 765,776 **** }
! proc pdtk_canvas_click {name x y b f} { ! pd [canvastosym $name] mouse [$name canvasx $x] [$name canvasy $y] $b $f ; ! set tags [$name gettags [lindex [$name find overlapping $x $y $x $y] end]] ! puts stderr "click $name $x $y $b $f : $tags " ! if {![regexp {^([a-f0-9]{7})} $tags tag]} {return} ! global _ ! if {[info exists _($tag:class)]} {set class $_($tag:class)} {set class unknown} ! puts stderr " -> $tag ($class)" }
--- 765,785 ---- }
! proc pdtk_canvas_click {canvas x y b f} { ! pd [canvastosym $canvas] mouse [$canvas canvasx $x] [$canvas canvasy $y] $b $f ; ! set stack [$canvas find overlapping [expr $x-2] [expr $y-2] [expr $x+2] [expr $y+2]] ! set tags [$canvas gettags [lindex $stack end]] ! puts stderr "(click) $canvas $x $y $b $f : $tags " ! if {[regexp {^([a-f0-9]{7})} $tags tag]} { ! global _ ! if {[info exists _($tag:class)]} {set class $_($tag:class)} {set class unknown} ! puts stderr "(.....) $tag is a [$class] object" ! return ! } ! if {[regexp {^l([a-f0-9]{7})} $tags tag]} { ! puts stderr "(.....) this is a wire" ! pd "[canvastosym $canvas] click-on-wire $tag $x $y $b $f;" ! return ! } ! puts stderr "(.....) nothing in particular" }
Index: g_canvas.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_canvas.c,v retrieving revision 1.1.1.4.2.7.2.7 retrieving revision 1.1.1.4.2.7.2.8 diff -C2 -d -r1.1.1.4.2.7.2.7 -r1.1.1.4.2.7.2.8 *** g_canvas.c 30 Mar 2004 01:35:09 -0000 1.1.1.4.2.7.2.7 --- g_canvas.c 30 Mar 2004 04:57:55 -0000 1.1.1.4.2.7.2.8 *************** *** 1303,1329 **** /* ------------------------------- setup routine ------------------------ */
! /* why are some of these "glist" and others "canvas"? */ ! extern void glist_text(t_glist *x, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_obj(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_bng(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_toggle(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_vslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_hslider(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_vdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! /* old version... */ ! extern void canvas_hdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_hdial(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! /* new version: */ ! extern void canvas_hradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_vradio(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_vumeter(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_mycnv(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_numbox(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_msg(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_floatatom(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void canvas_symbolatom(t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! extern void glist_scalar(t_glist *canvas, t_symbol *s, int argc, t_atom *argv);
! void canvas_guiext(t_glist *gl, t_symbol *guiobjname, int argc, t_atom *argv);
void g_graph_setup(void); --- 1303,1329 ---- /* ------------------------------- setup routine ------------------------ */
! /* why are some of these "glist" and others "canvas"? */ ! #define DECL(_name) extern void _name (t_glist *gl, t_symbol *s, int argc, t_atom *argv); ! DECL(glist_text) ! DECL(canvas_obj) ! DECL(canvas_bng) ! DECL(canvas_toggle) ! DECL(canvas_vslider) ! DECL(canvas_hslider) ! DECL(canvas_vdial) ! DECL(canvas_hdial) ! DECL(canvas_hradio) ! DECL(canvas_vradio) ! DECL(canvas_vumeter) ! DECL(canvas_mycnv) ! DECL(canvas_numbox) ! DECL(canvas_msg) ! DECL(canvas_floatatom) ! DECL(canvas_symbolatom) ! DECL(glist_scalar) ! //DECL(canvas_guiext)
! void canvas_click_on_wire(t_canvas *self, t_symbol linesym, ! t_float x, t_float y, t_float b, t_float f);
void g_graph_setup(void); *************** *** 1336,1340 **** /* we prevent the user from typing "canvas" in an object box by sending 0 for a creator function. */ ! canvas_class = class_new(gensym("canvas"), 0, (t_method)canvas_free, sizeof(t_canvas), CLASS_NOINLET, 0); /* here is the real creator function, invoked in patch files --- 1336,1340 ---- /* we prevent the user from typing "canvas" in an object box by sending 0 for a creator function. */ ! t_class *c = canvas_class = class_new(gensym("canvas"), 0, (t_method)canvas_free, sizeof(t_canvas), CLASS_NOINLET, 0); /* here is the real creator function, invoked in patch files *************** *** 1343,1347 **** class_addmethod(pd_canvasmaker, (t_method)canvas_new, gensym("canvas"), A_GIMME, 0); ! #define DEF(_f_,_s_) class_addmethod(canvas_class, (t_method)_f_, gensym(_s_), A_GIMME, 0); DEF(canvas_restore,"restore"); DEF(canvas_coords,"coords"); --- 1343,1347 ---- class_addmethod(pd_canvasmaker, (t_method)canvas_new, gensym("canvas"), A_GIMME, 0); ! #define DEF(_f_,_s_) class_addmethod(c, (t_method)_f_, gensym(_s_), A_GIMME, 0); DEF(canvas_restore,"restore"); DEF(canvas_coords,"coords"); *************** *** 1365,1390 **** DEF(canvas_mycnv,"mycnv"); DEF(canvas_numbox,"numbox"); ! DEF(canvas_guiext,"guiext");
/* ------------------------ gui stuff --------------------------- */ ! class_addmethod(canvas_class, (t_method)canvas_pop, gensym("pop"), ! A_DEFFLOAT, A_NULL); ! class_addmethod(canvas_class, (t_method)canvas_loadbang, ! gensym("loadbang"), 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, ! gensym("vis"), A_FLOAT, A_NULL); ! class_addmethod(canvas_class, (t_method)glist_menu_open, ! gensym("menu-open"), A_NULL); ! class_addmethod(canvas_class, (t_method)canvas_map, ! gensym("map"), A_FLOAT, A_NULL); ! /* class_addmethod(canvas_class, (t_method)canvas_redraw, ! gensym("redraw"), A_NULL);*/ class_setpropertiesfn(canvas_class, graph_properties);
/* ---------------------- list handling ------------------------ */ ! class_addmethod(canvas_class, (t_method)glist_clear, gensym("clear"), ! A_NULL);
/* ----- subcanvases, which you get by typing "pd" in a box ---- */ --- 1365,1384 ---- DEF(canvas_mycnv,"mycnv"); DEF(canvas_numbox,"numbox"); ! // DEF(canvas_guiext,"guiext");
/* ------------------------ gui stuff --------------------------- */ ! class_addmethod(c, (t_method)canvas_click_on_wire, gensym("click-on-wire"), ! A_SYMBOL, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_NULL); ! class_addmethod(c, (t_method)canvas_pop, gensym("pop"), A_DEFFLOAT, A_NULL); ! class_addmethod(c, (t_method)canvas_loadbang, gensym("loadbang"), A_NULL); ! class_addmethod(c, (t_method)canvas_relocate, gensym("relocate"), A_SYMBOL, A_SYMBOL, A_NULL); ! class_addmethod(c, (t_method)canvas_vis, gensym("vis"), A_FLOAT, A_NULL); ! class_addmethod(c, (t_method)glist_menu_open, gensym("menu-open"), A_NULL); ! class_addmethod(c, (t_method)canvas_map, gensym("map"), A_FLOAT, A_NULL); ! /* class_addmethod(c, (t_method)canvas_redraw, gensym("redraw"), A_NULL);*/ class_setpropertiesfn(canvas_class, graph_properties);
/* ---------------------- list handling ------------------------ */ ! class_addmethod(canvas_class, (t_method)glist_clear, gensym("clear"), A_NULL);
/* ----- subcanvases, which you get by typing "pd" in a box ---- */ *************** *** 1392,1405 **** class_addcreator((t_newmethod)subcanvas_new, gensym("page"), A_DEFSYMBOL, 0);
! class_addmethod(canvas_class, (t_method)canvas_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); ! class_addmethod(canvas_class, (t_method)canvas_dsp, gensym("dsp"), 0); ! class_addmethod(canvas_class, (t_method)canvas_rename_method, ! gensym("rename"), A_GIMME, 0);
/*---------------------------- tables -- GG ------------------- */
! class_addcreator((t_newmethod)table_new, gensym("table"), ! A_DEFSYM, A_DEFFLOAT, 0);
/* -------------- setups from other files for canvas_class ---------------- */ --- 1386,1397 ---- class_addcreator((t_newmethod)subcanvas_new, gensym("page"), A_DEFSYMBOL, 0);
! class_addmethod(c, (t_method)canvas_click, gensym("click"), A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); ! class_addmethod(c, (t_method)canvas_dsp, gensym("dsp"), 0); ! class_addmethod(c, (t_method)canvas_rename_method, gensym("rename"), A_GIMME, 0);
/*---------------------------- tables -- GG ------------------- */
! class_addcreator((t_newmethod)table_new, gensym("table"), A_DEFSYM, A_DEFFLOAT, 0);
/* -------------- setups from other files for canvas_class ---------------- */