Update of /cvsroot/pure-data/externals/miXed/toxy In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1117/toxy
Modified Files: build_counter notes.txt tot.c widget.c widgettype.c Log Message: cyclone alpha54 and toxy alpha16 (see notes.txt for cyclone, toxy and shared)
Index: notes.txt =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/toxy/notes.txt,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** notes.txt 27 Jan 2005 14:42:55 -0000 1.1 --- notes.txt 12 Mar 2005 00:19:13 -0000 1.2 *************** *** 1,6 **** --- 1,22 ---- TODO for toxy + * widget + . cached handlers + . better megawidgets + . editor: handle semicolons (need to revisit resolution rules) + . editor: differentiate argument keys from casual #strings (color-names) + * tow: canvas-wide and type-on-canvas-wide broadcasting
DONE for toxy
+ alpha16 + * widget: + . editor for options, handlers and arguments made more or less functional + . better 'redefine' (although still only external types may be redefined) + * tow: + . fixed handling of gop-ed targets and missing windows + . new messages: 'retarget', 'pwd' + * tot: + . scriptlet editor improved a little bit (still unfinished) + alpha15 * fixes for megawidgets
Index: widgettype.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/toxy/widgettype.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** widgettype.c 11 Jan 2005 10:33:23 -0000 1.11 --- widgettype.c 12 Mar 2005 00:19:13 -0000 1.12 *************** *** 1,3 **** ! /* Copyright (c) 2003-2004 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ --- 1,3 ---- ! /* Copyright (c) 2003-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ *************** *** 21,27 **** { t_pd wt_pd; ! t_symbol *wt_typekey; /* this is a typemap symbol */ ! t_symbol *wt_tkclass; /* also 'undefined' flag (gensym symbol) */ ! t_symbol *wt_tkpackage; /* gensym symbol */ t_props *wt_options; t_props *wt_handlers; --- 21,28 ---- { t_pd wt_pd; ! t_symbol *wt_typekey; /* this is a typemap symbol */ ! t_symbol *wt_tkclass; /* also 'undefined' flag (gensym symbol) */ ! t_symbol *wt_tkpackage; /* gensym symbol */ ! int wt_isinternal; /* true if built-in or defined in setup.wid */ t_props *wt_options; t_props *wt_handlers; *************** *** 58,61 **** --- 59,70 ---- }
+ static void widgettype_clear(t_widgettype *wt) + { + props_clearall(wt->wt_options); + scriptlet_reset(wt->wt_iniscript); + scriptlet_reset(wt->wt_newscript); + scriptlet_reset(wt->wt_freescript); + } + #if 0 /* only for debugging (never call, unless certain that nobody references wt) */ *************** *** 79,82 **** --- 88,92 ---- wt->wt_typekey = dict_key(mw->mw_typemap, typ); widgettype_map(wt, cls, pkg); + wt->wt_isinternal = 0; wt->wt_options = props_new(0, "option", "-", 0, 0); wt->wt_handlers = props_new(0, "handler", "@", wt->wt_options, 0); *************** *** 118,122 **** if (typeval) { ! /* LATER rethink */ loud_warning((t_pd *)mw, 0, "redefinition of '%s'\ in "%s.wid" file, ignored", buf, rc); --- 128,133 ---- if (typeval) { ! /* LATER may need revisiting, when/if we accept explicit ! 'redefine' requests for internal types */ loud_warning((t_pd *)mw, 0, "redefinition of '%s'\ in "%s.wid" file, ignored", buf, rc); *************** *** 139,143 **** --- 150,157 ---- widgettype_map(typeval, cls, pkg); else + { typeval = widgettype_new(mw, buf, cls, pkg); + typeval->wt_isinternal = (caller == (t_pd *)mw); + } mw->mw_parsedtype = typeval; #ifdef WIDGETTYPE_DEBUG *************** *** 161,169 **** t_props *pp; if (!(empty = props_add(pp = mw->mw_parsedtype->wt_options, ! 0, 0, ac, av)) && !(empty = props_add(pp = mw->mw_parsedtype->wt_handlers, ! 0, 0, ac, av))) empty = props_add(pp = mw->mw_parsedtype->wt_arguments, ! 0, 0, ac, av); if (empty) loud_warning((t_pd *)mw, 0, --- 175,183 ---- t_props *pp; if (!(empty = props_add(pp = mw->mw_parsedtype->wt_options, ! 0, 0, 0, ac, av)) && !(empty = props_add(pp = mw->mw_parsedtype->wt_handlers, ! 0, 0, 0, ac, av))) empty = props_add(pp = mw->mw_parsedtype->wt_arguments, ! 0, 0, 0, ac, av); if (empty) loud_warning((t_pd *)mw, 0, *************** *** 267,272 **** /* first instance of a type not defined in setup.wid */ wt = widgettype_new(masterwidget, s->s_name, 0, 0); ! widgettype_doload(wt, s); ! return (wt); }
--- 281,291 ---- /* first instance of a type not defined in setup.wid */ wt = widgettype_new(masterwidget, s->s_name, 0, 0); ! if (wt && !wt->wt_isinternal) ! { /* LATER consider safe-loading through a temporary type */ ! widgettype_clear(wt); ! if (widgettype_doload(wt, s)) ! return (wt); ! } ! return (0); }
Index: build_counter =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/toxy/build_counter,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** build_counter 27 Jan 2005 14:42:55 -0000 1.13 --- build_counter 12 Mar 2005 00:19:13 -0000 1.14 *************** *** 1,7 **** #define TOXY_VERSION "0.1" #define TOXY_RELEASE "alpha" ! #define TOXY_BUILD 15
#if 0 ! TOXY_SNAPSHOT = 0.1-alpha15 #endif --- 1,7 ---- #define TOXY_VERSION "0.1" #define TOXY_RELEASE "alpha" ! #define TOXY_BUILD 16
#if 0 ! TOXY_SNAPSHOT = 0.1-alpha16 #endif
Index: widget.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/toxy/widget.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** widget.c 28 Feb 2005 13:10:41 -0000 1.15 --- widget.c 12 Mar 2005 00:19:13 -0000 1.16 *************** *** 56,60 **** { t_object x_ob; ! t_glist *x_glist; /* containing glist */ t_widgettype *x_typedef; t_symbol *x_type; /* 1st creation arg: our type */ --- 56,60 ---- { t_object x_ob; ! t_glist *x_glist; /* containing glist */ t_widgettype *x_typedef; t_symbol *x_type; /* 1st creation arg: our type */ *************** *** 69,72 **** --- 69,76 ---- t_props *x_handlers; /* instance handlers */ t_props *x_arguments; /* instance arguments */ + t_props *x_xargs; /* type and instance arguments, resolved */ + t_props *x_diffoptions; /* type options minus instance options */ + t_props *x_diffhandlers; /* same for handlers */ + t_props *x_diffarguments; /* same for arguments */ t_widgethandlers x_cache; /* actual handlers */ t_scriptlet *x_iniscript; /* instance initializer */ *************** *** 90,100 **** { t_object x_ob; ! t_glist *x_glist; /* containing glist */ ! t_symbol *x_cvremote; /* null if containing glist is our destination */ t_symbol *x_cvname; ! t_symbol *x_type; /* 2nd creation arg: widget's type */ ! t_symbol *x_name; /* 3rd creation arg: widget's name */ t_widgetentry *x_widgetlist; ! struct _tow *x_next; /* next in the global towlist */ } t_tow;
--- 94,105 ---- { t_object x_ob; ! t_glist *x_glist; /* containing glist */ ! t_glist *x_targetglist; /* containing or parent glist */ ! t_symbol *x_cvremote; /* null if targetglist is set */ t_symbol *x_cvname; ! t_symbol *x_type; /* 2nd creation arg: widget's type */ ! t_symbol *x_name; /* 3rd creation arg: widget's name */ t_widgetentry *x_widgetlist; ! struct _tow *x_next; /* next in the global towlist */ } t_tow;
*************** *** 104,108 **** /* Global towlist, searched in widget_attach(). There is no global widgetlist, because a destination glist is searched instead in tow_attach(). */ ! static t_tow *towlist = 0;
static t_symbol *widgetps_mouse; --- 109,113 ---- /* Global towlist, searched in widget_attach(). There is no global widgetlist, because a destination glist is searched instead in tow_attach(). */ ! static t_tow *widget_towlist = 0;
static t_symbol *widgetps_mouse; *************** *** 177,180 **** --- 182,186 ---- #endif
+ /* resolving type and instance arguments into x_xargs */ static char *widget_propsresolver(t_pd *owner, int ac, t_atom *av) { *************** *** 257,261 **** outlet_new(newt, &s_); inlet_new(newt, &newt->ob_pd, &s_, &s_); ! /* FIXME preserve connections */ glist_add(x->x_glist, &newt->te_g); if (glist_isvisible(x->x_glist)) --- 263,267 ---- outlet_new(newt, &s_); inlet_new(newt, &newt->ob_pd, &s_, &s_); ! /* LATER preserve connections (although connected widget is a bad thing) */ glist_add(x->x_glist, &newt->te_g); if (glist_isvisible(x->x_glist)) *************** *** 338,343 **** { char *mypathname = widget_getmypathname(x, x->x_glist)->s_name; ! if (scriptlet_evaluate(x->x_optscript, x->x_transient, 0, ! 0, 0, x->x_arguments)) { #ifdef WIDGET_DEBUG --- 344,348 ---- { char *mypathname = widget_getmypathname(x, x->x_glist)->s_name; ! if (scriptlet_evaluate(x->x_optscript, x->x_transient, 0, 0, 0, x->x_xargs)) { #ifdef WIDGET_DEBUG *************** *** 363,373 **** int sz; if (widgettype_ievaluate(x->x_typedef, x->x_transient, 0, ! 0, 0, x->x_arguments)) scriptlet_vpush(x->x_transient, "typeinit"); else if (*widgettype_getinitializer(x->x_typedef, &sz) && sz > 0) loudbug_bug("widget_pushinits (type)"); } ! if (scriptlet_evaluate(x->x_iniscript, x->x_transient, 0, ! 0, 0, x->x_arguments)) scriptlet_vpush(x->x_transient, "iteminit"); else if (!scriptlet_isempty(x->x_iniscript)) --- 368,377 ---- int sz; if (widgettype_ievaluate(x->x_typedef, x->x_transient, 0, ! 0, 0, x->x_xargs)) scriptlet_vpush(x->x_transient, "typeinit"); else if (*widgettype_getinitializer(x->x_typedef, &sz) && sz > 0) loudbug_bug("widget_pushinits (type)"); } ! if (scriptlet_evaluate(x->x_iniscript, x->x_transient, 0, 0, 0, x->x_xargs)) scriptlet_vpush(x->x_transient, "iteminit"); else if (!scriptlet_isempty(x->x_iniscript)) *************** *** 382,386 **** int sz; if (widgettype_cevaluate(x->x_typedef, x->x_transient, 0, ! 0, 0, x->x_arguments)) scriptlet_push(x->x_transient); else if (*widgettype_getconstructor(x->x_typedef, &sz) && sz > 0) --- 386,390 ---- int sz; if (widgettype_cevaluate(x->x_typedef, x->x_transient, 0, ! 0, 0, x->x_xargs)) scriptlet_push(x->x_transient); else if (*widgettype_getconstructor(x->x_typedef, &sz) && sz > 0) *************** *** 396,400 **** int sz; if (widgettype_devaluate(x->x_typedef, x->x_transient, 0, ! 0, 0, x->x_arguments)) scriptlet_push(x->x_transient); else if (*widgettype_getdestructor(x->x_typedef, &sz) && sz > 0) --- 400,404 ---- int sz; if (widgettype_devaluate(x->x_typedef, x->x_transient, 0, ! 0, 0, x->x_xargs)) scriptlet_push(x->x_transient); else if (*widgettype_getdestructor(x->x_typedef, &sz) && sz > 0) *************** *** 459,512 **** }
! /* FIXME */ ! static void widget_properties(t_gobj *z, t_glist *glist) { ! t_widget *x = (t_widget *)z; t_atom *ap; ! int ac, nleft; ! char *head = scriptlet_getcontents(x->x_optscript, &nleft); ! char buf[MAXPDSTRING + 1]; ! buf[MAXPDSTRING] = 0; ! sprintf(buf, "%s %s", x->x_type->s_name, x->x_name->s_name); ! hammereditor_open(x->x_filehandle, buf, 0); ! while (nleft > 0) ! { ! if (nleft > MAXPDSTRING) ! { ! strncpy(buf, head, MAXPDSTRING); ! head += MAXPDSTRING; ! nleft -= MAXPDSTRING; ! } ! else ! { ! strncpy(buf, head, nleft); ! buf[nleft] = 0; ! nleft = 0; ! } ! hammereditor_append(x->x_filehandle, buf); ! } ! scriptlet_reset(x->x_auxscript); ! ap = props_getall(x->x_handlers, &ac); ! if (ac) scriptlet_add(x->x_auxscript, 0, 0, ac, ap); ! head = scriptlet_getcontents(x->x_auxscript, &nleft); ! hammereditor_append(x->x_filehandle, "\n"); ! while (nleft > 0) { ! if (nleft > MAXPDSTRING) ! { ! strncpy(buf, head, MAXPDSTRING); ! head += MAXPDSTRING; ! nleft -= MAXPDSTRING; ! } ! else { ! strncpy(buf, head, nleft); ! buf[nleft] = 0; ! nleft = 0; } ! hammereditor_append(x->x_filehandle, buf); } }
static t_widgetbehavior widget_behavior = { --- 463,519 ---- }
! static void widget_editorappend(t_widget *x, t_props *pp) { ! int ac; t_atom *ap; ! if (ap = props_getfirst(pp, &ac)) { ! if (pp != x->x_diffoptions) ! hammereditor_append(x->x_filehandle, "\n"); ! do { ! int nleft; ! char buf[MAXPDSTRING + 1], *head; ! buf[MAXPDSTRING] = 0; ! scriptlet_reset(x->x_auxscript); ! scriptlet_add(x->x_auxscript, 0, 0, ac, ap); ! head = scriptlet_getcontents(x->x_auxscript, &nleft); ! while (nleft > 0) ! { ! if (nleft > MAXPDSTRING) ! { ! strncpy(buf, head, MAXPDSTRING); ! head += MAXPDSTRING; ! nleft -= MAXPDSTRING; ! } ! else ! { ! strncpy(buf, head, nleft); ! buf[nleft] = 0; ! nleft = 0; ! } ! hammereditor_append(x->x_filehandle, buf); ! } ! hammereditor_append(x->x_filehandle, "\n"); } ! while (ap = props_getnext(pp, &ac)); } }
+ static void widget_properties(t_gobj *z, t_glist *glist) + { + t_widget *x = (t_widget *)z; + char buf[MAXPDSTRING]; + sprintf(buf, "%s %s", x->x_type->s_name, x->x_name->s_name); + hammereditor_open(x->x_filehandle, buf, 0); + widget_editorappend(x, x->x_diffoptions); + widget_editorappend(x, x->x_options); + widget_editorappend(x, x->x_diffhandlers); + widget_editorappend(x, x->x_handlers); + widget_editorappend(x, x->x_diffarguments); + widget_editorappend(x, x->x_arguments); + hammereditor_setdirty(x->x_filehandle, 0); + } + static t_widgetbehavior widget_behavior = { *************** *** 533,538 **** t_atom *ap; int ac; scriptlet_reset(x->x_optscript); ! ap = props_getall(widgettype_getoptions(x->x_typedef), &ac); if (ac) scriptlet_add(x->x_optscript, 0, 0, ac, ap); ap = props_getall(x->x_options, &ac); --- 540,547 ---- t_atom *ap; int ac; + props_diff(x->x_diffoptions, + widgettype_getoptions(x->x_typedef), x->x_options); scriptlet_reset(x->x_optscript); ! ap = props_getall(x->x_diffoptions, &ac); if (ac) scriptlet_add(x->x_optscript, 0, 0, ac, ap); ap = props_getall(x->x_options, &ac); *************** *** 554,566 **** } } ! else { /* LATER cache handlers. We get here both during construction, and after any change in our handlers -- the cache never stales. */ } }
! static t_symbol *widget_addprops(t_widget *x, t_props *op, int single, t_symbol *s, int ac, t_atom *av) { --- 563,586 ---- } } ! else if (op == x->x_handlers) { + props_diff(x->x_diffhandlers, + widgettype_gethandlers(x->x_typedef), x->x_handlers); /* LATER cache handlers. We get here both during construction, and after any change in our handlers -- the cache never stales. */ } + else if (op == x->x_arguments) + { + props_diff(x->x_diffarguments, + widgettype_getarguments(x->x_typedef), x->x_arguments); + props_clearvalues(x->x_xargs); + props_clonevalues(x->x_xargs, x->x_diffarguments); + props_clonevalues(x->x_xargs, x->x_arguments); + } }
! static t_symbol *widget_addprops(t_widget *x, t_props *op, ! int single, t_props *filter, t_symbol *s, int ac, t_atom *av) { *************** *** 568,572 **** { t_symbol *empty; ! empty = props_add(op, single, s, ac, av); if (empty) loud_error((t_pd *)x, "no value given for %s '%s'", --- 588,592 ---- { t_symbol *empty; ! empty = props_add(op, single, filter, s, ac, av); if (empty) loud_error((t_pd *)x, "no value given for %s '%s'", *************** *** 582,591 **** }
! static t_symbol *widget_addmessage(t_widget *x, t_symbol *s, int ac, t_atom *av) { t_symbol *empty; ! if (!(empty = widget_addprops(x, x->x_arguments, 0, s, ac, av)) && ! !(empty = widget_addprops(x, x->x_handlers, 0, s, ac, av))) ! empty = widget_addprops(x, x->x_options, 0, s, ac, av); return (empty); } --- 602,633 ---- }
! static t_symbol *widget_addmessage(t_widget *x, int unique, ! t_symbol *s, int ac, t_atom *av) { t_symbol *empty; ! if (s) ! { ! /* FIXME mixed messages */ ! if (*s->s_name == '-') ! x->x_update = WIDGET_PUSHVIS; ! else if (*s->s_name == '#') ! x->x_update = WIDGET_REVIS; ! else ! x->x_update = WIDGET_NOVIS; ! } ! /* Instance-type duplicates are not removed, unless 'unique' is set. ! If it is set, we are called from editorhook, so we assume duplicates ! were not specified explicitly. In other cases we keep duplicates, ! because type may change until next time this widget is created or ! refreshed. */ ! if (!(empty = widget_addprops(x, x->x_arguments, 0, ! (unique ? x->x_diffarguments : 0), ! s, ac, av)) && ! !(empty = widget_addprops(x, x->x_handlers, 0, ! (unique ? x->x_diffhandlers : 0), ! s, ac, av))) ! empty = widget_addprops(x, x->x_options, 0, ! (unique ? x->x_diffoptions : 0), ! s, ac, av); return (empty); } *************** *** 598,609 **** { t_symbol *empty; ! /* FIXME mixed messages */ ! if (*s->s_name == '-') ! x->x_update = WIDGET_PUSHVIS; ! else if (*s->s_name == '#') ! x->x_update = WIDGET_REVIS; ! else ! x->x_update = WIDGET_NOVIS; ! if (empty = widget_addmessage(x, s, ac, av)) loud_errand((t_pd *)x, "(use 'remove %s' if that is what you want).", --- 640,644 ---- { t_symbol *empty; ! if (empty = widget_addmessage(x, 0, s, ac, av)) loud_errand((t_pd *)x, "(use 'remove %s' if that is what you want).", *************** *** 630,634 **** scriptlet_add(x->x_auxscript, 0, 0, hlen - 1, hp + 1); if (scriptlet_evaluate(x->x_auxscript, x->x_transient, 1, ! ac, av, x->x_arguments)) { WIDGETPROFILE_HANDLER_PUSH; --- 665,669 ---- scriptlet_add(x->x_auxscript, 0, 0, hlen - 1, hp + 1); if (scriptlet_evaluate(x->x_auxscript, x->x_transient, 1, ! ac, av, x->x_xargs)) { WIDGETPROFILE_HANDLER_PUSH; *************** *** 682,686 **** scriptlet_add(x->x_auxscript, 0, 0, ac - 1, av + 1); if (scriptlet_evaluate(x->x_auxscript, x->x_transient, 1, ! 1, &at, x->x_arguments)) { WIDGETPROFILE_HANDLER_PUSH; --- 717,721 ---- scriptlet_add(x->x_auxscript, 0, 0, ac - 1, av + 1); if (scriptlet_evaluate(x->x_auxscript, x->x_transient, 1, ! 1, &at, x->x_xargs)) { WIDGETPROFILE_HANDLER_PUSH; *************** *** 710,714 **** scriptlet_add(x->x_auxscript, 0, 0, ac - 1, av + 1); if (scriptlet_evaluate(x->x_auxscript, x->x_transient, 1, ! 1, &at, x->x_arguments)) { WIDGETPROFILE_HANDLER_PUSH; --- 745,749 ---- scriptlet_add(x->x_auxscript, 0, 0, ac - 1, av + 1); if (scriptlet_evaluate(x->x_auxscript, x->x_transient, 1, ! 1, &at, x->x_xargs)) { WIDGETPROFILE_HANDLER_PUSH; *************** *** 744,753 **** { x->x_update = WIDGET_PUSHVIS; ! empty = widget_addprops(x, x->x_options, 1, prp, ac, av); } else if (*prp->s_name == '@') ! empty = widget_addprops(x, x->x_handlers, 1, prp, ac, av); else if (*prp->s_name == '#') ! empty = widget_addprops(x, x->x_arguments, 1, prp, ac, av); if (empty) loud_errand((t_pd *)x, --- 779,788 ---- { x->x_update = WIDGET_PUSHVIS; ! empty = widget_addprops(x, x->x_options, 1, 0, prp, ac, av); } else if (*prp->s_name == '@') ! empty = widget_addprops(x, x->x_handlers, 1, 0, prp, ac, av); else if (*prp->s_name == '#') ! empty = widget_addprops(x, x->x_arguments, 1, 0, prp, ac, av); if (empty) loud_errand((t_pd *)x, *************** *** 773,777 **** if (op && props_remove(op, s)) { ! if (op == x->x_options) x->x_update = WIDGET_REVIS; widget_update(x, op); } --- 808,813 ---- if (op && props_remove(op, s)) { ! if (op == x->x_options) /* LATER rethink */ ! x->x_update = WIDGET_REVIS; widget_update(x, op); } *************** *** 796,800 **** scriptlet_add(x->x_auxscript, 1, 1, ac, av); if (scriptlet_evaluate(x->x_auxscript, x->x_transient, 1, ! 0, 0, x->x_arguments)) scriptlet_push(x->x_transient); } --- 832,836 ---- scriptlet_add(x->x_auxscript, 1, 1, ac, av); if (scriptlet_evaluate(x->x_auxscript, x->x_transient, 1, ! 0, 0, x->x_xargs)) scriptlet_push(x->x_transient); } *************** *** 804,822 **** { x->x_update = WIDGET_REVIS; - widget_update(x, x->x_options); - widget_update(x, x->x_handlers); widget_update(x, x->x_arguments); }
static int widget_resettype(t_widget *x, t_widgettype *wt) { ! if (wt == x->x_typedef) { if (!(x->x_tkclass = widgettype_tkclass(x->x_typedef))) x->x_tkclass = x->x_type; ! props_clone(x->x_arguments, widgettype_getarguments(x->x_typedef)); ! /* FIXME widget_addmessage(x, 0, ac, av); */ widget_pushconstructors(x); ! widget_refresh(x); return (1); } --- 840,860 ---- { x->x_update = WIDGET_REVIS; widget_update(x, x->x_arguments); + widget_update(x, x->x_handlers); + widget_update(x, x->x_options); }
static int widget_resettype(t_widget *x, t_widgettype *wt) { ! if (!wt || /* LATER rethink, cf widgettype_reload() */ ! wt == x->x_typedef) { if (!(x->x_tkclass = widgettype_tkclass(x->x_typedef))) x->x_tkclass = x->x_type; ! x->x_update = WIDGET_REVIS; ! widget_update(x, x->x_arguments); widget_pushconstructors(x); ! widget_update(x, x->x_handlers); ! widget_update(x, x->x_options); return (1); } *************** *** 833,836 **** --- 871,882 ---- }
+ static void widget_editorhook(t_pd *z, t_symbol *s, int ac, t_atom *av) + { + t_widget *x = (t_widget *)z; + props_clearall(x->x_options); + widget_addmessage(x, 1, 0, ac, av); + widget_refresh(x); + } + static void widget__failure(t_widget *x) { *************** *** 995,1010 **** widgettype_getoptions(x->x_typedef)); widgetbug_postprops("instance options:", x->x_options); widgetbug_postprops("default handlers:", widgettype_gethandlers(x->x_typedef)); widgetbug_postprops("instance handlers:", x->x_handlers); widgetbug_postprops("default arguments:", widgettype_getarguments(x->x_typedef)); widgetbug_postprops("instance arguments:", x->x_arguments); loudbug_post("dictionary:"); ! bp = props_firstvalue(x->x_arguments, &key); while (bp) { loudbug_post("\t%s: "%s"", key, bp); ! bp = props_nextvalue(x->x_arguments, &key); } bp = scriptlet_getcontents(x->x_transient, &sz); --- 1041,1059 ---- widgettype_getoptions(x->x_typedef)); widgetbug_postprops("instance options:", x->x_options); + widgetbug_postprops("diff options:", x->x_diffoptions); widgetbug_postprops("default handlers:", widgettype_gethandlers(x->x_typedef)); widgetbug_postprops("instance handlers:", x->x_handlers); + widgetbug_postprops("diff handlers:", x->x_diffhandlers); widgetbug_postprops("default arguments:", widgettype_getarguments(x->x_typedef)); widgetbug_postprops("instance arguments:", x->x_arguments); + widgetbug_postprops("diff arguments:", x->x_diffarguments); loudbug_post("dictionary:"); ! bp = props_firstvalue(x->x_xargs, &key); while (bp) { loudbug_post("\t%s: "%s"", key, bp); ! bp = props_nextvalue(x->x_xargs, &key); } bp = scriptlet_getcontents(x->x_transient, &sz); *************** *** 1045,1048 **** --- 1094,1099 ---- gui_unbind((t_pd *)x, x->x_rptarget); props_freeall(x->x_options); + props_freeall(x->x_xargs); + props_freeall(x->x_diffoptions); scriptlet_free(x->x_iniscript); scriptlet_free(x->x_optscript); *************** *** 1112,1117 **** x->x_options = props_new((t_pd *)x, "option", "-", 0, 0); x->x_handlers = props_new((t_pd *)x, "handler", "@", x->x_options, 0); ! x->x_arguments = props_new((t_pd *)x, "argument", "#", x->x_options, ! widget_propsresolver);
outlet_new((t_object *)x, &s_anything); --- 1163,1173 ---- x->x_options = props_new((t_pd *)x, "option", "-", 0, 0); x->x_handlers = props_new((t_pd *)x, "handler", "@", x->x_options, 0); ! x->x_arguments = props_new((t_pd *)x, "argument", "#", x->x_options, 0); ! x->x_xargs = props_new((t_pd *)x, "argument", "#", 0, widget_propsresolver); ! x->x_diffoptions = props_new((t_pd *)x, "option", "-", 0, 0); ! x->x_diffhandlers = props_new((t_pd *)x, "handler", "@", ! x->x_diffoptions, 0); ! x->x_diffarguments = props_new((t_pd *)x, "argument", "#", ! x->x_diffoptions, 0);
outlet_new((t_object *)x, &s_anything); *************** *** 1122,1128 **** x->x_width = 5; x->x_height = 5; ! props_clone(x->x_arguments, widgettype_getarguments(x->x_typedef)); ! widget_addmessage(x, 0, ac, av); ! x->x_filehandle = hammerfile_new((t_pd *)x, 0, 0, 0, 0); x->x_transclock = clock_new(x, (t_method)widget_transtick); x->x_background = 0; --- 1178,1182 ---- x->x_width = 5; x->x_height = 5; ! x->x_filehandle = hammerfile_new((t_pd *)x, 0, 0, 0, widget_editorhook); x->x_transclock = clock_new(x, (t_method)widget_transtick); x->x_background = 0; *************** *** 1132,1135 **** --- 1186,1190 ---- x->x_vised = 0; widget_attach(x); + widget_addmessage(x, 0, 0, ac, av); widget_pushconstructors(x); return (x); *************** *** 1138,1204 **** static t_glist *tow_getglist(t_tow *x, int complain) { ! t_glist *glist = ! (x->x_cvremote ? ! (t_glist *)pd_findbyclass(x->x_cvremote, canvas_class) : x->x_glist); ! if (!glist && complain) loud_error((t_pd *)x, "bad canvas name '%s'", x->x_cvname->s_name); ! return (glist_getcanvas(glist)); ! } ! ! static void tow_bang(t_tow *x) ! { ! t_widgetentry *we; ! for (we = x->x_widgetlist; we; we = we->we_next) ! widget_bang(we->we_widget); ! } ! ! static void tow_float(t_tow *x, t_float f) ! { ! t_widgetentry *we; ! for (we = x->x_widgetlist; we; we = we->we_next) ! widget_float(we->we_widget, f); ! } ! ! static void tow_symbol(t_tow *x, t_symbol *s) ! { ! t_widgetentry *we; ! for (we = x->x_widgetlist; we; we = we->we_next) ! widget_symbol(we->we_widget, s); ! } ! ! static void tow_anything(t_tow *x, t_symbol *s, int ac, t_atom *av) ! { ! t_widgetentry *we; ! for (we = x->x_widgetlist; we; we = we->we_next) ! typedmess((t_pd *)we->we_widget, s, ac, av); ! } ! ! static void tow_redefine(t_tow *x) ! { ! t_widgettype *wt = widgettype_reload(x->x_type); ! t_widgetentry *we; ! for (we = x->x_widgetlist; we; we = we->we_next) ! if (!widget_resettype(we->we_widget, wt)) ! break; ! } ! ! static void tow__callback(t_tow *x, t_symbol *s, int ac, t_atom *av) ! { ! if (ac == 1) ! { ! if (av->a_type == A_FLOAT) ! outlet_float(((t_object *)x)->ob_outlet, av->a_w.w_float); ! else if (av->a_type == A_SYMBOL) ! outlet_symbol(((t_object *)x)->ob_outlet, av->a_w.w_symbol); ! } ! else if (ac) ! { ! if (av->a_type == A_FLOAT) ! outlet_list(((t_object *)x)->ob_outlet, &s_list, ac, av); ! else if (av->a_type == A_SYMBOL) ! outlet_anything(((t_object *)x)->ob_outlet, ! av->a_w.w_symbol, ac - 1, av + 1); ! } ! else outlet_bang(((t_object *)x)->ob_outlet); }
--- 1193,1202 ---- static t_glist *tow_getglist(t_tow *x, int complain) { ! t_glist *glist = (x->x_cvremote ? ! (t_glist *)pd_findbyclass(x->x_cvremote, canvas_class) : ! x->x_targetglist); ! if (!glist && x->x_cvname && complain) loud_error((t_pd *)x, "bad canvas name '%s'", x->x_cvname->s_name); ! return (glist); }
*************** *** 1247,1251 **** { t_tow *t; ! for (t = towlist; t; t = t->x_next) if (x->x_glist == tow_getglist(t, 0) && t->x_type == x->x_type && t->x_name == x->x_name) --- 1245,1249 ---- { t_tow *t; ! for (t = widget_towlist; t; t = t->x_next) if (x->x_glist == tow_getglist(t, 0) && t->x_type == x->x_type && t->x_name == x->x_name) *************** *** 1286,1290 **** } #ifdef TOW_DEBUG ! else loudbug_post("glist '%s' not found", x->x_cvname->s_name); #endif } --- 1284,1289 ---- } #ifdef TOW_DEBUG ! else if (x->x_cvname) ! loudbug_post("glist '%s' not found", x->x_cvname->s_name); #endif } *************** *** 1321,1324 **** --- 1320,1433 ---- }
+ static void tow_bang(t_tow *x) + { + t_widgetentry *we; + for (we = x->x_widgetlist; we; we = we->we_next) + widget_bang(we->we_widget); + } + + static void tow_float(t_tow *x, t_float f) + { + t_widgetentry *we; + for (we = x->x_widgetlist; we; we = we->we_next) + widget_float(we->we_widget, f); + } + + static void tow_symbol(t_tow *x, t_symbol *s) + { + t_widgetentry *we; + for (we = x->x_widgetlist; we; we = we->we_next) + widget_symbol(we->we_widget, s); + } + + static void tow_anything(t_tow *x, t_symbol *s, int ac, t_atom *av) + { + t_widgetentry *we; + for (we = x->x_widgetlist; we; we = we->we_next) + typedmess((t_pd *)we->we_widget, s, ac, av); + } + + static void tow_redefine(t_tow *x) + { + t_widgettype *wt = widgettype_reload(x->x_type); + t_widgetentry *we; + for (we = x->x_widgetlist; we; we = we->we_next) + if (!widget_resettype(we->we_widget, wt)) + break; + } + + /* LATER broadcasting: canvas-wide or type-on-canvas-wide */ + static void tow_settarget(t_tow *x, t_symbol *s1, t_symbol *s2, t_symbol *s3) + { + char buf[64]; + if (s1 == &s_ || !strcmp(s1->s_name, ".")) + s1 = 0; + if (s1 && strcmp(s1->s_name, ".parent")) + { + x->x_cvremote = canvas_makebindsym(x->x_cvname = s1); + x->x_targetglist = 0; + } + else + { + x->x_cvremote = 0; + if (s1) + { + if (x->x_glist->gl_owner) + x->x_targetglist = x->x_glist->gl_owner; + else + { /* The case of a tow pointing out from an abstraction, + targeting its parent, is considered invalid (otherwise, + opening an abstraction as a top-level patch should not be + flagged as error). LATER rethink. */ + loud_error((t_pd *)x, "parent of a top level patch requested,"); + loud_errand((t_pd *)x, "this is a dangling tow..."); + x->x_cvname = 0; + x->x_targetglist = 0; + } + } + else x->x_targetglist = x->x_glist; + } + if (x->x_targetglist) + x->x_cvname = x->x_targetglist->gl_name; + x->x_type = s2; + x->x_name = s3; + tow_attach(x); + } + + static void tow_retarget(t_tow *x, t_symbol *s1, t_symbol *s2, t_symbol *s3) + { + tow_detach(x); + tow_settarget(x, s1, s2, s3); + } + + static void tow_pwd(t_tow *x, t_symbol *s) + { + t_glist *glist; + t_symbol *dir; + if (s && s->s_thing && (glist = tow_getglist(x, 1)) && + (dir = canvas_getdir(glist))) + pd_symbol(s->s_thing, dir); + } + + static void tow__callback(t_tow *x, t_symbol *s, int ac, t_atom *av) + { + if (ac == 1) + { + if (av->a_type == A_FLOAT) + outlet_float(((t_object *)x)->ob_outlet, av->a_w.w_float); + else if (av->a_type == A_SYMBOL) + outlet_symbol(((t_object *)x)->ob_outlet, av->a_w.w_symbol); + } + else if (ac) + { + if (av->a_type == A_FLOAT) + outlet_list(((t_object *)x)->ob_outlet, &s_list, ac, av); + else if (av->a_type == A_SYMBOL) + outlet_anything(((t_object *)x)->ob_outlet, + av->a_w.w_symbol, ac - 1, av + 1); + } + else outlet_bang(((t_object *)x)->ob_outlet); + } + #ifdef TOW_DEBUG static void tow_debug(t_tow *x) *************** *** 1350,1354 **** loudbug_startpost("updating towlist..."); #endif ! for (t1 = 0, t2 = towlist; t2; t2 = t2->x_next) { if (t2 == x) --- 1459,1463 ---- loudbug_startpost("updating towlist..."); #endif ! for (t1 = 0, t2 = widget_towlist; t2; t2 = t2->x_next) { if (t2 == x) *************** *** 1357,1361 **** t1->x_next = t2->x_next; else ! towlist = t2->x_next; #ifdef TOW_DEBUG loudbug_post("ok"); --- 1466,1470 ---- t1->x_next = t2->x_next; else ! widget_towlist = t2->x_next; #ifdef TOW_DEBUG loudbug_post("ok"); *************** *** 1371,1410 **** { t_tow *x = (t_tow *)pd_new(tow_class); - char buf[64]; x->x_glist = canvas_getcurrent(); ! if (s1 == &s_ || !strcmp(s1->s_name, ".")) ! s1 = 0; ! if (s1) ! { ! if (strcmp(s1->s_name, ".parent")) ! x->x_cvremote = canvas_makebindsym(x->x_cvname = s1); ! else ! { ! if (x->x_glist->gl_owner) ! { ! x->x_glist = x->x_glist->gl_owner; ! x->x_cvremote = 0; ! x->x_cvname = x->x_glist->gl_name; ! } ! else ! { ! /* FIXME */ ! loud_error((t_pd *)x, "no parent patch"); ! x->x_cvremote = canvas_makebindsym(x->x_cvname = s1); ! } ! } ! } ! else ! { ! x->x_cvremote = 0; ! x->x_cvname = x->x_glist->gl_name; ! } ! x->x_type = s2; ! x->x_name = s3; ! outlet_new((t_object *)x, &s_anything); x->x_widgetlist = 0; ! x->x_next = towlist; ! towlist = x; ! tow_attach(x); return (x); } --- 1480,1490 ---- { t_tow *x = (t_tow *)pd_new(tow_class); x->x_glist = canvas_getcurrent(); ! x->x_targetglist = 0; x->x_widgetlist = 0; ! x->x_next = widget_towlist; ! widget_towlist = x; ! outlet_new((t_object *)x, &s_anything); ! tow_settarget(x, s1, s2, s3); return (x); } *************** *** 1482,1486 **** (t_newmethod)tow_new, (t_method)tow_free, ! sizeof(t_tow), 0, A_SYMBOL, A_SYMBOL, A_SYMBOL, 0); class_addbang(tow_class, tow_bang); class_addfloat(tow_class, tow_float); --- 1562,1566 ---- (t_newmethod)tow_new, (t_method)tow_free, ! sizeof(t_tow), 0, A_SYMBOL, A_DEFSYM, A_DEFSYM, 0); class_addbang(tow_class, tow_bang); class_addfloat(tow_class, tow_float); *************** *** 1489,1492 **** --- 1569,1576 ---- class_addmethod(tow_class, (t_method)tow_redefine, gensym("redefine"), 0); + class_addmethod(tow_class, (t_method)tow_retarget, + gensym("retarget"), A_SYMBOL, A_SYMBOL, A_SYMBOL, 0); + class_addmethod(tow_class, (t_method)tow_pwd, + gensym("pwd"), A_SYMBOL, 0); class_addmethod(tow_class, (t_method)tow__callback, gensym("_cb"), A_GIMME, 0);
Index: tot.c =================================================================== RCS file: /cvsroot/pure-data/externals/miXed/toxy/tot.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tot.c 28 Feb 2005 13:10:41 -0000 1.8 --- tot.c 12 Mar 2005 00:19:13 -0000 1.9 *************** *** 1,3 **** ! /* Copyright (c) 2003-2004 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ --- 1,3 ---- ! /* Copyright (c) 2003-2005 krzYszcz and others. * For information on usage and redistribution, and for a DISCLAIMER OF ALL * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ *************** *** 10,13 **** --- 10,14 ---- #include "g_canvas.h" #include "common/loud.h" + #include "unstable/forky.h" #include "hammer/file.h" #include "hammer/gui.h" *************** *** 252,280 **** }
! /* LATER use properties in widgetbehavior (if gop visibility rules change) */ ! static void tot_click(t_tot *x, t_floatarg xpos, t_floatarg ypos, ! t_floatarg shift, t_floatarg ctrl, t_floatarg alt) { int nleft; char *head = scriptlet_getcontents(x->x_persistent, &nleft); - char buf[MAXPDSTRING + 1]; - buf[MAXPDSTRING] = 0; hammereditor_open(x->x_filehandle, "scriptlet editor", 0); ! while (nleft > 0) { ! if (nleft > MAXPDSTRING) ! { ! strncpy(buf, head, MAXPDSTRING); ! head += MAXPDSTRING; ! nleft -= MAXPDSTRING; ! } ! else { ! strncpy(buf, head, nleft); ! buf[nleft] = 0; ! nleft = 0; } ! hammereditor_append(x->x_filehandle, buf); } }
--- 253,320 ---- }
! static void tot_properties(t_gobj *z, t_glist *glist) { + t_tot *x = (t_tot *)z; int nleft; char *head = scriptlet_getcontents(x->x_persistent, &nleft); hammereditor_open(x->x_filehandle, "scriptlet editor", 0); ! if (nleft) { ! char buf[MAXPDSTRING + 1], *lastptr = buf + MAXPDSTRING; ! *lastptr = 0; ! while (nleft > 0) { ! if (nleft > MAXPDSTRING) ! { ! strncpy(buf, head, MAXPDSTRING); ! head += MAXPDSTRING; ! nleft -= MAXPDSTRING; ! } ! else ! { ! strncpy(buf, head, nleft); ! lastptr = buf + nleft; ! *lastptr = 0; ! nleft = 0; ! } ! hammereditor_append(x->x_filehandle, buf); } ! hammereditor_append(x->x_filehandle, "\n"); } + hammereditor_setdirty(x->x_filehandle, 0); + } + + static void tot_editorhook(t_pd *z, t_symbol *s, int ac, t_atom *av) + { + t_tot *x = (t_tot *)z; + scriptlet_reset(x->x_persistent); + scriptlet_add(x->x_persistent, 0, 0, ac, av); + } + + static void tot_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) + { + scriptlet_read(((t_tot *)z)->x_persistent, fn); + } + + static void tot_writehook(t_pd *z, t_symbol *fn, int ac, t_atom *av) + { + scriptlet_write(((t_tot *)z)->x_persistent, fn); + } + + static void tot_read(t_tot *x, t_symbol *s) + { + if (s && s != &s_) + scriptlet_read(x->x_persistent, s); + else + hammerpanel_open(x->x_filehandle, 0); + } + + static void tot_write(t_tot *x, t_symbol *s) + { + if (s && s != &s_) + scriptlet_write(x->x_persistent, s); + else + hammerpanel_save(x->x_filehandle, + canvas_getdir(x->x_glist), x->x_defname); }
*************** *** 306,309 **** --- 346,381 ----
#ifdef TOT_DEBUG + static void tot_postscriptlet(t_scriptlet *sp, char *message) + { + int nleft; + char *head = scriptlet_getbuffer(sp, &nleft); + loudbug_startpost("*** %s (size %d)", message, nleft); + if (nleft) + { + char buf[MAXPDSTRING + 1], *lastptr = buf + MAXPDSTRING; + *lastptr = 0; + loudbug_stringpost(" ***\n""); + while (nleft > 0) + { + if (nleft > MAXPDSTRING) + { + strncpy(buf, head, MAXPDSTRING); + head += MAXPDSTRING; + nleft -= MAXPDSTRING; + } + else + { + strncpy(buf, head, nleft); + lastptr = buf + nleft; + *lastptr = 0; + nleft = 0; + } + loudbug_stringpost(buf); + } + loudbug_stringpost(""\n---------------\n"); + } + else loudbug_stringpost(": "" ***\n"); + } + static void tot_debug(t_tot *x) { *************** *** 315,352 **** loudbug_post("pathname%s %s", (pn ? ":" : ""), (pn ? pn->s_name : "unknown")); ! bp = scriptlet_getbuffer(x->x_transient, &sz); ! loudbug_post("transient buffer (size %d):\n"%s"", sz, bp); ! bp = scriptlet_getbuffer(x->x_persistent, &sz); ! loudbug_post("persistent buffer (size %d):\n"%s"", sz, bp); } #endif
- static void tot_readhook(t_pd *z, t_symbol *fn, int ac, t_atom *av) - { - scriptlet_read(((t_tot *)z)->x_persistent, fn); - } - - static void tot_writehook(t_pd *z, t_symbol *fn, int ac, t_atom *av) - { - scriptlet_write(((t_tot *)z)->x_persistent, fn); - } - - static void tot_read(t_tot *x, t_symbol *s) - { - if (s && s != &s_) - scriptlet_read(x->x_persistent, s); - else - hammerpanel_open(x->x_filehandle, 0); - } - - static void tot_write(t_tot *x, t_symbol *s) - { - if (s && s != &s_) - scriptlet_write(x->x_persistent, s); - else - hammerpanel_save(x->x_filehandle, - canvas_getdir(x->x_glist), x->x_defname); - } - static void tot_detach(t_tot *x) { --- 387,395 ---- loudbug_post("pathname%s %s", (pn ? ":" : ""), (pn ? pn->s_name : "unknown")); ! tot_postscriptlet(x->x_transient, "transient buffer"); ! tot_postscriptlet(x->x_persistent, "persistent buffer"); } #endif
static void tot_detach(t_tot *x) { *************** *** 572,576 **** else x->x_defname = &s_; x->x_filehandle = hammerfile_new((t_pd *)x, 0, ! tot_readhook, tot_writehook, 0); hammergui_bindvised((t_pd *)x); x->x_visedpathname = tot_getvisedpathname(x, 0); --- 615,620 ---- else x->x_defname = &s_; x->x_filehandle = hammerfile_new((t_pd *)x, 0, ! tot_readhook, tot_writehook, ! tot_editorhook); hammergui_bindvised((t_pd *)x); x->x_visedpathname = tot_getvisedpathname(x, 0); *************** *** 627,633 **** class_addmethod(tot_class, (t_method)tot__callback, gensym("_cb"), A_GIMME, 0); - class_addmethod(tot_class, (t_method)tot_click, - gensym("click"), - A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); class_addmethod(tot_class, (t_method)tot__vised, gensym("_vised"), A_SYMBOL, A_FLOAT, 0); --- 671,674 ---- *************** *** 636,639 **** --- 677,681 ---- gensym("debug"), 0); #endif + forky_setpropertiesfn(tot_class, tot_properties); hammerfile_setup(tot_class, 0); totspy_class = class_new(gensym("tot spy"), 0, 0,