Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21215
Modified Files: Tag: impd_0_37 g_all_guis.h g_canvas.c g_text.c m_conf.c makefile.mingw u_main.tk u_object.tk Added Files: Tag: impd_0_37 g_dropper.c Log Message: +g_dropper.c / icon: http://replic.net/~ix/pd/dropper.gif / http://tkdnd.sourceforge.net
Index: g_text.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_text.c,v retrieving revision 1.1.1.4.2.2.2.13 retrieving revision 1.1.1.4.2.2.2.14 diff -C2 -d -r1.1.1.4.2.2.2.13 -r1.1.1.4.2.2.2.14 *** g_text.c 19 Apr 2004 17:28:39 -0000 1.1.1.4.2.2.2.13 --- g_text.c 26 Apr 2004 11:37:43 -0000 1.1.1.4.2.2.2.14 *************** *** 190,193 **** --- 190,194 ---- CONSTR(vradio, "vradio"); CONSTR(hradio, "hradio"); + CONSTR(dropper, "dropper"); CONSTR(vumeter, "vu"); CONSTR(mycnv, "cnv");
Index: u_main.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/u_main.tk,v retrieving revision 1.1.1.4.2.7.4.46 retrieving revision 1.1.1.4.2.7.4.47 diff -C2 -d -r1.1.1.4.2.7.4.46 -r1.1.1.4.2.7.4.47 *** u_main.tk 26 Apr 2004 08:45:12 -0000 1.1.1.4.2.7.4.46 --- u_main.tk 26 Apr 2004 11:37:43 -0000 1.1.1.4.2.7.4.47 *************** *** 667,670 **** --- 667,671 ---- {Hradio {pd "%W hradio 0 ;"} "Alt+i"} {VU {pd "%W vumeter 0 ;"} "Alt+u"} + {dropper {pd "%W dropper 0 ;"} "Alt+x"} {Canvas {pd "%W mycnv 0 ;"} "Alt+c"} {} *************** *** 2259,2262 **** --- 2260,2264 ---- {hradio {hradio 0}} {vu {vumeter 0}} + {dropper {dropper 0}} {canvas {mycnv 0}} {graph {graph}}
Index: makefile.mingw =================================================================== RCS file: /cvsroot/pure-data/pd/src/makefile.mingw,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** makefile.mingw 11 Apr 2004 05:16:40 -0000 1.1.2.4 --- makefile.mingw 26 Apr 2004 11:37:43 -0000 1.1.2.5 *************** *** 38,42 **** SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \ g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \ ! g_all_guis.c g_bang.c g_hdial.c g_hslider.c g_mycanvas.c g_numbox.c \ g_toggle.c g_vumeter.c m_pd.c m_class.c m_obj.c m_atom.c m_memory.c \ m_binbuf.c m_conf.c m_glob.c m_sched.c s_main.c s_inter.c s_file.c \ --- 38,43 ---- SRC = g_canvas.c g_graph.c g_text.c g_rtext.c g_array.c g_template.c g_io.c \ g_scalar.c g_traversal.c g_guiconnect.c g_readwrite.c g_editor.c \ ! g_all_guis.c g_bang.c g_hdial.c g_hslider.c \ ! g_mycanvas.c g_dropper.c g_numbox.c \ g_toggle.c g_vumeter.c m_pd.c m_class.c m_obj.c m_atom.c m_memory.c \ m_binbuf.c m_conf.c m_glob.c m_sched.c s_main.c s_inter.c s_file.c \
Index: g_all_guis.h =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_all_guis.h,v retrieving revision 1.1.1.4.2.2.2.10 retrieving revision 1.1.1.4.2.2.2.11 diff -C2 -d -r1.1.1.4.2.2.2.10 -r1.1.1.4.2.2.2.11 *** g_all_guis.h 8 Apr 2004 10:50:02 -0000 1.1.1.4.2.2.2.10 --- g_all_guis.h 26 Apr 2004 11:37:43 -0000 1.1.1.4.2.2.2.11 *************** *** 150,153 **** --- 150,154 ---- int x_bcol; int x_lcol; + t_symbol *x_s; t_symbol *x_snd; /* send symbol */ t_symbol *x_rcv; /* receive */ *************** *** 218,221 **** --- 219,233 ---- } t_my_canvas;
+ typedef struct _dropper + { + t_iemgui x_gui; + int x_flashed; + int x_flashtime_break; + int x_flashtime_hold; + t_clock *x_clock_hld; + t_clock *x_clock_brk; + t_clock *x_clock_lck; + } t_dropper; + typedef struct _vu {
Index: m_conf.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/m_conf.c,v retrieving revision 1.1.1.3 retrieving revision 1.1.1.3.4.1 diff -C2 -d -r1.1.1.3 -r1.1.1.3.4.1 *** m_conf.c 9 May 2003 16:03:43 -0000 1.1.1.3 --- m_conf.c 26 Apr 2004 11:37:43 -0000 1.1.1.3.4.1 *************** *** 23,26 **** --- 23,27 ---- /* iemlib */ void g_io_setup(void); + void g_dropper_setup(void); void g_scalar_setup(void); void g_template_setup(void); *************** *** 69,72 **** --- 70,74 ---- /* iemlib */ g_io_setup(); + g_dropper_setup(); g_scalar_setup(); g_template_setup();
--- NEW FILE: g_dropper.c --- /* Copyright (c) 1997-1999 Miller Puckette. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
/* drag & drop filer (c) 2004 Carmen Rocco */
#include <stdlib.h> #include <string.h> #include <stdio.h> #include <ctype.h> #include "m_pd.h" #include "g_canvas.h" #include "t_tk.h" #include "g_all_guis.h" #include <math.h>
#ifdef MSW #include <io.h> #else #include <unistd.h> #endif
t_widgetbehavior dropper_widgetbehavior; static t_class *dropper_class;
void dropper_draw(t_dropper *x, t_glist *glist, int mode) { if (mode==IEM_GUI_DRAW_MODE_ERASE) sys_mgui((t_iemgui *)x,"dropper","erase",""); else if (mode==IEM_GUI_DRAW_MODE_SELECT) sys_mgui((t_iemgui *)x,"dropper","select","i",x->x_gui.x_fsf.x_selected); else { pd_upload((t_gobj *)x,glist); sys_mgui((t_iemgui *)x,"dropper","draw","");} }
/* ------------------------ dropper widgetbehaviour----------------------------- */
static void dropper_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) { t_dropper *x = (t_dropper *)z; *xp1 = text_xpix(&x->x_gui.x_obj, glist); *yp1 = text_ypix(&x->x_gui.x_obj, glist); *xp2 = *xp1 + x->x_gui.x_w; *yp2 = *yp1 + x->x_gui.x_h; }
static void dropper_save(t_gobj *z, t_binbuf *b) { t_dropper *x = (t_dropper *)z; int bflcol[3]; t_symbol *srl[3];
iemgui_save(&x->x_gui, srl, bflcol); binbuf_addv(b, "ssiisiiiisssiiiiiii", gensym("#X"),gensym("obj"), (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix, gensym("dropper"), x->x_gui.x_w, x->x_flashtime_hold, x->x_flashtime_break, iem_symargstoint(&x->x_gui.x_isa), srl[0], srl[1], srl[2], x->x_gui.x_ldx, x->x_gui.x_ldy, iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, bflcol[0], bflcol[1], bflcol[2]); binbuf_addv(b, ";"); }
static void dropper_symbol(t_dropper *x, t_symbol *s) { outlet_symbol(x->x_gui.x_obj.ob_outlet, s); }
static void dropper_init(t_dropper *x, t_floatarg f) {x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;}
static void *dropper_new(t_symbol *s, int argc, t_atom *argv) { char buf[50]; t_dropper *x = (t_dropper *)pd_new(dropper_class); int bflcol[]={-262144, -1, -1}; int a=IEM_GUI_DEFAULTSIZE; int ldx=0, ldy=-6, isa=0, fstyle=0, fs=8; int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold= IEM_BNG_DEFAULTHOLDFLASHTIME; t_symbol *srl[3]={0,0,0}; pd_scanargs(argc,argv,"iiiiaaaiiiiiii", &a,&fthold,&ftbreak,&isa,&srl[0],&srl[1],&srl[2], &ldx,&ldy,&fstyle,&fs,&bflcol[0],&bflcol[1],&bflcol[2]); iem_inttosymargs(&x->x_gui.x_isa, isa); iem_inttofstyle(&x->x_gui.x_fsf, fstyle); iemgui_new_getnames2(&x->x_gui, 4, srl[0], srl[1], srl[2]); x->x_gui.x_draw = (t_iemfunptr)dropper_draw; x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); x->x_gui.x_ldx=ldx; x->x_gui.x_ldy=ldy; x->x_flashed = 0; x->x_gui.x_fsf.x_snd_able = strcmp(x->x_gui.x_snd->s_name, "empty")!=0; x->x_gui.x_fsf.x_rcv_able = strcmp(x->x_gui.x_rcv->s_name, "empty")!=0; iemgui_set_font_style((t_iemgui *)x, x->x_gui.x_fsf.x_font_style); sprintf(buf, "d%x", (int)x); x->x_gui.x_s = gensym(buf); pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_s); x->x_gui.x_fontsize = MAX(fs,4); x->x_gui.x_h = x->x_gui.x_w = iemgui_clip_size(a); iemgui_all_colfromload(&x->x_gui, bflcol); x->x_gui.x_isa.x_locked = 0; iemgui_verify_snd_ne_rcv(&x->x_gui); outlet_new(&x->x_gui.x_obj, &s_symbol); return (x); }
static void dropper_ff(t_dropper *x) { if(x->x_gui.x_fsf.x_rcv_able) pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); clock_free(x->x_clock_lck); clock_free(x->x_clock_brk); clock_free(x->x_clock_hld); gfxstub_deleteforkey(x); }
void g_dropper_setup(void) { t_class *c = dropper_class = class_new(gensym("dropper"), (t_newmethod)dropper_new, (t_method)dropper_ff, sizeof(t_dropper), 0, A_GIMME, 0); class_addsymbol(c, dropper_symbol); class_addmethod(c, (t_method)dropper_init, gensym("init"), A_FLOAT, 0); iemgui_register_class(c); dropper_widgetbehavior.w_getrectfn = dropper_getrect; dropper_widgetbehavior.w_displacefn = iemgui_displace; dropper_widgetbehavior.w_selectfn = iemgui_select; dropper_widgetbehavior.w_activatefn = NULL; dropper_widgetbehavior.w_deletefn = iemgui_delete; dropper_widgetbehavior.w_visfn = iemgui_vis; class_setwidget(dropper_class, &dropper_widgetbehavior); class_sethelpsymbol(dropper_class, gensym("dropper")); class_setsavefn(dropper_class, dropper_save); }
Index: u_object.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/u_object.tk,v retrieving revision 1.1.2.20 retrieving revision 1.1.2.21 diff -C2 -d -r1.1.2.20 -r1.1.2.21 *** u_object.tk 26 Apr 2004 08:45:12 -0000 1.1.2.20 --- u_object.tk 26 Apr 2004 11:37:43 -0000 1.1.2.21 *************** *** 53,56 **** --- 53,57 ---- set fields(vdl) $fields(hradio) set fields(vu) [eval list $fields1 w h rcv lab ldx ldy fstyle fs bcol lcol scale isa] + set fields(dropper) [eval list $fields1 w hold break isa $fields2]
proc update_object {x d} { *************** *** 802,803 **** --- 803,846 ---- $canvas delete ${self}MASK } + + + #drag'n'drop filer + lappend auto_path . + package require tkdnd + + proc dropper_draw {self canvas} { + global _ + set isnew [expr [llength [$canvas gettags ${self}DROPr]] == 0] + foreach {x1 y1} [object_xy $self $canvas] {} + set x2 [expr $x1+10 ] + set y2 [expr $y1+10 ] + # set xs $_($self:w) + # set ys $_($self:h) + set ins [expr [string compare $_($self:rcv) empty]==0] + set outs [expr [string compare $_($self:snd) empty]==0] + # io_draw $self $canvas $x1 $y1 24 24 $ins $outs + bluebox_draw $self $canvas $x1 $y1 24 24 $ins $outs + if {$isnew} { + $canvas create rectangle $x1 $y1 $x2 $y2 -tags ${self}DROPr -fill red + canvas $canvas.${self}DROP -width 20 -height 20 -bg purple + place $canvas.${self}DROP -x [expr $x1 + 10] -y $y1 + dnd bindtarget $canvas.${self}DROP text/uri-list <Drop> "pd "d[list ${self}] symbol [pdtk_enquote %D] ;"" + } { + place $canvas.${self}DROP -x [expr $x1 + 10] -y $y1 + $canvas coords ${self}DROPr $x1 $y1 $x2 $y2 + } + label_draw $self $canvas + + return + } + + proc dropper_select {self canvas flag} { + global look + if {$flag} {set colour #ff0000} {set colour $look(objectframe3)} + $canvas itemconfigure ${self}DROPr -bg $colour + } + + proc dropper_erase {self canvas} { + $canvas delete ${self}DROPr + bluebox_erase $self $canvas + }
Index: g_canvas.c =================================================================== RCS file: /cvsroot/pure-data/pd/src/g_canvas.c,v retrieving revision 1.1.1.4.2.7.2.12 retrieving revision 1.1.1.4.2.7.2.13 diff -C2 -d -r1.1.1.4.2.7.2.12 -r1.1.1.4.2.7.2.13 *** g_canvas.c 17 Apr 2004 06:04:01 -0000 1.1.1.4.2.7.2.12 --- g_canvas.c 26 Apr 2004 11:37:43 -0000 1.1.1.4.2.7.2.13 *************** *** 1313,1316 **** --- 1313,1317 ---- DECL(canvas_vradio) DECL(canvas_vumeter) + DECL(canvas_dropper) DECL(canvas_mycnv) DECL(canvas_numbox) *************** *** 1362,1365 **** --- 1363,1367 ---- DEF(canvas_vradio,"vradio"); DEF(canvas_vumeter,"vumeter"); + DEF(canvas_dropper,"dropper"); DEF(canvas_mycnv,"mycnv"); DEF(canvas_numbox,"numbox");