From bc5e203f7787980f65f81ddbf69a619ab34fa85e Mon Sep 17 00:00:00 2001 From: "N.N." Date: Tue, 9 Mar 2004 12:41:22 +0000 Subject: toxy alpha6 svn path=/trunk/externals/miXed/; revision=1396 --- Makefile | 21 ++++ Makefile.common | 3 +- shared/toxy/scriptlet.c | 14 ++- test/toxy/button-test.pd | 3 + test/toxy/default.wid | 235 ------------------------------------- test/toxy/kb-test.pd | 18 +-- test/toxy/kb.wid | 8 +- test/toxy/listbox-test.pd | 38 +++--- test/toxy/multiscale-test.pd | 20 ++++ test/toxy/multiscale.wid | 39 +++++++ test/toxy/popcustom-test.pd | 39 +++++++ test/toxy/popup-test.pd | 90 +++++++------- test/toxy/setup.wid | 272 +++++++++++++++++++++++++++++++++++++++++++ test/toxy/stress/pophurd.pd | 84 +++++++++++++ test/toxy/tclversion.pd | 29 +++-- toxy/Makefile | 6 +- toxy/Makefile.sources | 5 + toxy/build_counter | 2 +- toxy/widget.c | 53 +++++++-- toxy/widgettype.c | 53 +++++---- 20 files changed, 674 insertions(+), 358 deletions(-) delete mode 100644 test/toxy/default.wid create mode 100644 test/toxy/multiscale-test.pd create mode 100644 test/toxy/multiscale.wid create mode 100644 test/toxy/popcustom-test.pd create mode 100644 test/toxy/setup.wid create mode 100644 test/toxy/stress/pophurd.pd diff --git a/Makefile b/Makefile index 3bd3c7e..048ad44 100644 --- a/Makefile +++ b/Makefile @@ -14,9 +14,30 @@ diff depend emptydeps: @for i in $(MIXED_DIRS) ; \ do ( if [ -d $$i ] ; then cd $$i; $(MAKE) $@ ; fi ) ; done +ALLSRC_TAR = release/miXed-`date +%F`-src.tar +ALLSRC_ROOTFILES = LICENSE.txt Makefile.common Makefile Makefile.dirs \ + dumpsetups quoteinitializer + snap release: @for i in $(RELEASE_DIRS) ; \ do ( if [ -d $$i ] ; then cd $$i; $(MAKE) $@ ; fi ) ; done +rootsnap: + tar -cf $(ALLSRC_TAR) $(ALLSRC_ROOTFILES) + @for i in $(RELEASE_DIRS) ; \ + do ( if [ -d $$i ] ; then tar -X $$i/$$i-all.exclude -rf \ + $(ALLSRC_TAR) $$i/* ; fi ) ; done + tar -X shared/shared-all.exclude -rf $(ALLSRC_TAR) shared/* + @for i in $(RELEASE_DIRS) ; \ + do ( if [ -d $$i ] ; then tar -X $$i/$$i-test.exclude -rf \ + $(ALLSRC_TAR) test/$$i/* ; fi ) ; done + @for i in $(RELEASE_DIRS) ; \ + do ( if [ -d $$i ] ; then tar -X $$i/$$i-vicious.exclude -rf \ + $(ALLSRC_TAR) ViCious/$$i/* ; fi ) ; done + tar -rf $(ALLSRC_TAR) bin/keepme + gzip -f $(ALLSRC_TAR) + +fullsnap: snap rootsnap + backup: tar -X miXed-bak-exclude.files -zcf miXed-bak.tar.gz * diff --git a/Makefile.common b/Makefile.common index eaeaadd..9d49295 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1,7 +1,7 @@ # next line has to be edited manually PD_DIR = $(ROOT_DIR)/../../pd/src -# FIXME +# FIXME ./configure should set this (or not) before "include Makefile.sources" TCL_LIB = -l`grep -osm1 'tcl8\.[345]' $(PD_DIR)/makefile` OS_NAME = $(shell uname -s) @@ -267,6 +267,7 @@ stestrelease: emptydeps define_build $(SRC_TAR) test/$(BASE_NAME)/* cd $(ROOT_DIR); tar -X $(BASE_DIR)/$(BASE_NAME)-vicious.exclude -rf \ $(SRC_TAR) ViCious/$(BASE_DIR)/* + cd $(ROOT_DIR); tar -rf $(SRC_TAR) bin/keepme cd $(ROOT_DIR); gzip -f $(SRC_TAR) brelease: define_build diff --git a/shared/toxy/scriptlet.c b/shared/toxy/scriptlet.c index 4806065..4f4221f 100644 --- a/shared/toxy/scriptlet.c +++ b/shared/toxy/scriptlet.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2003 krzYszcz and others. +/* 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. */ @@ -425,9 +425,13 @@ void scriptlet_qpush(t_scriptlet *sp) strcpy(tail, "]}}\n"); sys_gui(sp->s_buffer); *tail = 0; - /* LATER find out if reply does not fit better inside the query proc */ - sprintf(buf, "after 0 {::toxy::query\n\ - pd [concat %s _rp $::toxy::reply \\;]}\n", sp->s_rptarget->s_name); + /* Could not find anything more flexible, than blocking while waiting + for ::toxy::query to complete. The model case is a Tk dialog + hanging over the arrival of new queries. LATER probably use + a thread-safe replacement of the 'pd' command in order to prevent + competing tcl threads from corrupting the gui-to-pd stream. */ + sprintf(buf, "after 0 {::toxy::query}\nvwait ::toxy::reply\n\ + pd [concat %s _rp $::toxy::reply \\;]\n", sp->s_rptarget->s_name); sys_gui(buf); } } @@ -613,7 +617,7 @@ int scriptlet_rcload(t_scriptlet *sp, t_pd *caller, char *rc, char *ext, if (sp->s_glist) dir = canvas_getdir(sp->s_glist)->s_name; else - dir = ""; + dir = ""; /* which means pwd, usually the same as at Pd startup... */ if ((fd = open_via_path(dir, rc, ext, buf, &nameptr, MAXPDSTRING, 0)) < 0) { result = SCRIPTLET_NOFILE; diff --git a/test/toxy/button-test.pd b/test/toxy/button-test.pd index b37978b..26e181b 100644 --- a/test/toxy/button-test.pd +++ b/test/toxy/button-test.pd @@ -22,6 +22,8 @@ red -command .<.>; $c "-text" $c.>.); #X obj 294 268 loadbang; #X msg 294 295 ini .- config -textvariable ""; +#X obj 250 21 widget button bb -bg green -activebackground yellow +-command .<.> ; #X connect 0 0 3 0; #X connect 1 0 0 0; #X connect 2 0 0 0; @@ -39,3 +41,4 @@ $c "-text" $c.>.); #X connect 16 0 0 0; #X connect 17 0 18 0; #X connect 18 0 0 0; +#X connect 19 0 10 0; diff --git a/test/toxy/default.wid b/test/toxy/default.wid deleted file mode 100644 index c7898af..0000000 --- a/test/toxy/default.wid +++ /dev/null @@ -1,235 +0,0 @@ -# LATER transfer the `standard' toxy setup definitions into a tcl package -# LATER think about using a slave interpreter, and a toxy-specific connection - -# LATER ask for adding something of the sort to pd.tk: -bind Canvas <1> {+focus %W} - -# In order to keep the state after our canvas has been destroyed -# (i.e. our subpatch closed) -- use 'store' and 'restore' handlers, -# if defined, otherwise try setting -variable and -textvariable traces. - -proc ::toxy::itemdotrace {target varname ndxname op} { - if {[catch {set v [set $varname]}] == 0} { - if {$v != [set $varname.last]} { -# FIXME activate this on demand (for explicit traces) -# pd $target.rp _value $v \; - set $varname.last $v - } - } else { puts stderr [concat failed ::toxy::itemdotrace] } -} - -proc ::toxy::itembindtrace {varname mastername ndxname op} { - set $varname [set $mastername] -} - -proc ::toxy::itemsettrace {op path target varname} { - if {[catch {$path cget $op} res] == 0} { - if {$res == ""} { - if {[catch {$path config $op $varname} err]} { - error $err - } - } else { - if {[info tclversion] < 8.4} { - trace variable $res w "::toxy::itembindtrace $varname" - } else { - trace add variable $res write "::toxy::itembindtrace $varname" - } - } - if {![info exists $varname.last]} { set $varname.last "" } - if {[info tclversion] < 8.4} { - trace variable $varname w "::toxy::itemdotrace $target" - } else { - trace add variable $varname write "::toxy::itemdotrace $target" - } - return - } else { return 0 } -} - -# LATER revisit -- seems clumsy and fragile -proc ::toxy::itemremovetrace {op path varname} { - if {[catch {$path cget $op} res] == 0} { - if {$res == $varname} { - if {[catch {$path config $op ""} err]} { - error $err - } - } elseif {$res != ""} { - if {[info tclversion] < 8.4} { - catch { trace vdelete $res w "::toxy::itembindtrace $varname" } - } else { - catch { trace remove variable \ - $res write "::toxy::itembindtrace $varname" } - } - } - } -} - -proc ::toxy::itemdestroy {path varname} { - ::toxy::itemremovetrace -variable $path $varname.var - ::toxy::itemremovetrace -textvariable $path $varname.txt - if {[info tclversion] < 8.4} { - catch { unset $varname.last $varname.var $varname.txt $varname } - } else { - unset -nocomplain $varname.last $varname.var $varname.txt $varname - } - catch {destroy $path} -} - -proc ::toxy::itemgetconfig {path target} { - pd $target.rp _config $target.rp [$path cget -bg] \ - [winfo reqwidth $path] [winfo reqheight $path] \ - [catch {$path config -state normal}]\; -} - -proc ::toxy::itemvisconfig {path target name varname cvpath px py} { - if {[info exists ::toxy::itemoptions]} { - catch {eval $path config $::toxy::itemoptions} - unset ::toxy::itemoptions - } - - $cvpath create window $px $py \ - -anchor nw -window $path -tags [concat toxy$name $target] - -# FIXME - if {[info exists ::toxy::storethispath]} { -# FIXME explicit traces - set needtraces 0 - } else { - set needtraces 1 - } - - if {$needtraces != 0} { - if {[catch {::toxy::itemsettrace -variable \ - $path $target $varname.var} res1]} { - error $res1 - } - if {[catch {::toxy::itemsettrace -textvariable \ - $path $target $varname.txt} res2]} { - error $res2 - } -# puts stderr [concat traces: ($res1) ($res2)] - if {$res1 == 0 && $res2 == 0} { -# puts stderr [concat toxy warning: $path untraceable] - } - } - - if {[info exists ::toxy::masterinits]} { - catch {eval $::toxy::masterinits} - unset ::toxy::masterinits - } - if {[info exists ::toxy::typeinits]} { - catch {eval $::toxy::typeinits} - unset ::toxy::typeinits - } - if {[info exists ::toxy::iteminits]} { - catch {eval $::toxy::iteminits} - unset ::toxy::iteminits - } - - ::toxy::itemgetconfig $path $target - - return -} - -proc ::toxy::itemvis {tkclass path target name varname cvpath px py} { - if {[winfo exists $path]} { -# puts [concat $path exists] - set ::toxy::itemfailure 0 - } else { - set ::toxy::itemfailure [catch {$tkclass $path} ::toxy::itemerrmess] - } - if {$::toxy::itemfailure == 0} { - set ::toxy::itemfailure [catch {::toxy::itemvisconfig \ - $path $target $name $varname $cvpath $px $py} \ - ::toxy::itemerrmess] - } - if {$::toxy::itemfailure} { - if {[winfo exists $path]} {destroy $path} - pd $target.rp _failure $::toxy::itemerrmess \; - } -} - -proc ::toxy::itemclick {target cvpath x y b f} { - pd $target.rp _click \ - [$cvpath canvasx [expr $x - [winfo rootx $cvpath]]] \ - [$cvpath canvasy [expr $y - [winfo rooty $cvpath]]] $b $f\; -} - -# FIXME -proc ::toxy::scalecommand {target sel v} { - pd [concat $target $sel $v \;] -} - -proc ::toxy::popupcommand {path target remote i text} { - set [$path cget -textvariable] $text - pd [concat $target _cb $i \;] - if {$remote != "."} { - pd [concat $remote $i \;] - } -} - -proc ::toxy::popup {path target remote entries args} { - eval {menu $path.pop} $args - set i 1 - foreach e $entries { - $path.pop add command -label [lindex $e 0] \ - -command [concat ::toxy::popupcommand $path $target $remote $i \ - [lindex $e [expr {[llength $e] > 1}]]] - incr i - } -} - -# the default initializer -#> default - -# empirically, binding event coords as %X - [winfo rootx .^.c] works better, -# than %x + [winfo x %W], or %x + t->te_xpix, LATER investigate - -# pdtk_canvas_mouseup is a hack, which we must call anyway -bind .- { - eval .<|_inout 3.> - pdtk_canvas_mouseup .^.c \ - [expr %X - [winfo rootx .^.c]] [expr %Y - [winfo rooty .^.c]] %b -} - -bind .- <1> {::toxy::itemclick .| .^.c %X %Y %b 0} -bind .- {::toxy::itemclick .| .^.c %X %Y %b 1} -bind .- {::toxy::itemclick .| .^.c %X %Y %b 2} -bind .- {::toxy::itemclick .| .^.c %X %Y %b 3} -bind .- {::toxy::itemclick .| .^.c %X %Y %b 4} -bind .- {::toxy::itemclick .| .^.c %X %Y %b 5} -bind .- {::toxy::itemclick .| .^.c %X %Y %b 6} -bind .- {::toxy::itemclick .| .^.c %X %Y %b 7} -bind .- <3> {::toxy::itemclick .| .^.c %X %Y %b 8} - -bind .- .<|_motion \ - [.^.c canvasx [expr %X - [winfo rootx .^.c]]] \ - [.^.c canvasy [expr %Y - [winfo rooty .^.c]]] 0.> -bind .- .<|_inout 1.> -bind .- .<|_inout 0.> - -# standard widget types - -#> bang button -#. -image ::toxy::img::empty -command .<.> -#. -bg pink -activebackground red -width 50 -height 50 -#. @bang .- flash .: .- invoke - -#> float scale -#. -command [concat ::toxy::scalecommand .| _cb] -#. -bg pink -activebackground red -length 200 -#. @float .- set .#1 - -#> symbol entry -#. -bg pink -font .(helvetica 24.) -width 16 -#. @symbol .- delete 0 end .: .- insert 0 .#1 - -bind .- {eval .<[.- get].>; focus .^.c} - -#> popup menubutton -#. -menu .-.pop -#. -bg purple -fg white -activebackground magenta -width 8 -text popup -#. @float if .(.#1 >= 1.) .(.-.pop invoke .#1.) -#. #items test -#. #iprops "-bg" purple "-fg" white "-activebackground" magenta - -::toxy::popup .- .| . [concat .#items] .#iprops diff --git a/test/toxy/kb-test.pd b/test/toxy/kb-test.pd index 2978dce..22df275 100644 --- a/test/toxy/kb-test.pd +++ b/test/toxy/kb-test.pd @@ -1,17 +1,21 @@ #N canvas 354 116 645 486 12; -#X obj 37 61 widget kb k1; +#X obj 37 59 widget kb k1; #X floatatom 37 160 5 0 0 0 - - -; -#X obj 37 310 widget kb k2 #oct 8 #size 0.35 -bg red; +#X obj 37 310 widget kb k2 #oct 10 #size 0.35 -bg red; #X floatatom 37 369 5 0 0 0 - - -; -#X msg 120 271 #oct \$1 \, refresh; #X floatatom 120 237 5 0 0 0 - - -; #X floatatom 37 24 5 0 0 0 - - -; #X msg 114 24 bang; #X floatatom 37 237 5 0 0 0 - - -; +#X floatatom 205 237 5 0 0 0 - - -; +#X msg 205 271 #size \$1; +#X msg 120 271 #oct \$1; #X connect 0 0 1 0; #X connect 2 0 3 0; -#X connect 4 0 2 0; -#X connect 5 0 4 0; +#X connect 4 0 10 0; +#X connect 5 0 0 0; #X connect 6 0 0 0; -#X connect 7 0 0 0; -#X connect 8 0 2 0; +#X connect 7 0 2 0; +#X connect 8 0 9 0; +#X connect 9 0 2 0; +#X connect 10 0 2 0; diff --git a/test/toxy/kb.wid b/test/toxy/kb.wid index e447697..9a64d70 100644 --- a/test/toxy/kb.wid +++ b/test/toxy/kb.wid @@ -1,10 +1,10 @@ proc ::toxy::kb {path target remote noctaves size} { set lft [expr {round(5 * $size)}] - set top [expr {5 * $size}] - set bot [expr {100 * $size}] + set top [expr {round(5 * $size)}] + set bot [expr {round(100 * $size)}] set dx [expr {round(17 * $size)}] - set wid [expr {$dx - $size * .5}] - set blbot [expr {$bot * .65}] + set wid [expr {round($dx - $size * .5)}] + set blbot [expr {round($bot * .65)}] $path config -height [expr {$bot + $top}] \ -width [expr {$dx * ($noctaves * 7 + 1) + $lft * 2 - 1}] diff --git a/test/toxy/listbox-test.pd b/test/toxy/listbox-test.pd index cd1fa46..751fb58 100644 --- a/test/toxy/listbox-test.pd +++ b/test/toxy/listbox-test.pd @@ -1,18 +1,24 @@ -#N canvas 154 52 626 383 12; -#X obj 281 144 widget listbox lb -width 32 -height 12 -bg black -fg -white; -#X obj 20 282 tow . listbox lb; -#X obj 20 21 loadbang; -#X msg 20 52 ini foreach fn [lsort [glob *]] .(.- insert end $fn.) -; -#X obj 236 143 widget button b -text ok -height 14 -bg black -fg white +#N canvas 445 76 626 425 12; +#X obj 281 179 widget listbox lb -width 32 -height 12 -bg black -fg +white @bang ::toxy::lbcommand .- .|; +#X obj 20 295 tow . listbox lb; +#X obj 20 23 loadbang; +#X obj 236 179 widget button b -text ok -height 1 -bg black -fg white -command .<.>; -#X obj 112 21 tow . button b; -#X msg 36 83 tot if .([.- curselection] != "".) .(eval ..); -#X msg 20 324; -#X connect 1 0 7 0; -#X connect 2 0 3 0; -#X connect 3 0 1 0; -#X connect 5 0 6 0; +#X obj 84 179 tow . button b; +#X msg 20 337; +#X msg 54 257 tot puts [.- size]; +#X msg 44 222 tot .- delete 0 end; +#X msg 33 179 bang; +#X msg 20 57 tot proc ::toxy::lbcommand .(path target.) .(if .([$path +curselection] != "".) .(pd [concat $target _cb set [$path get [$path +curselection]] .`.:].).) \, ini if .([.- size] == 0.) .(foreach fn +[lsort [glob *]] .(.- insert end $fn.) .: bind .- +.(::toxy::lbcommand .- .|.).) \, @bang ::toxy::lbcommand .- .|; +#X connect 1 0 5 0; +#X connect 2 0 9 0; +#X connect 4 0 1 0; #X connect 6 0 1 0; +#X connect 7 0 1 0; +#X connect 8 0 1 0; +#X connect 9 0 1 0; diff --git a/test/toxy/multiscale-test.pd b/test/toxy/multiscale-test.pd new file mode 100644 index 0000000..c0383a6 --- /dev/null +++ b/test/toxy/multiscale-test.pd @@ -0,0 +1,20 @@ +#N canvas 39 49 775 469 12; +#X obj 27 98 widget multiscale m1 #n 30 #dx 15 #dy 60; +#X obj 27 200 widget multiscale m2 #bg red #dy 120; +#X obj 188 371 tow . multiscale m1; +#X msg 27 59 #n \$1; +#X floatatom 27 24 5 0 0 0 - - -; +#N canvas 0 0 450 300 graph1 0; +#X array t 50 float 0; +#X coords 0 1 49 0 400 140 1; +#X restore 296 206 graph; +#X obj 188 410 tabwrite t; +#X obj 27 367 unpack; +#X floatatom 27 411 5 0 0 0 - - -; +#X floatatom 100 411 5 0 0 0 - - -; +#X connect 1 0 7 0; +#X connect 2 0 6 0; +#X connect 3 0 0 0; +#X connect 4 0 3 0; +#X connect 7 0 8 0; +#X connect 7 1 9 0; diff --git a/test/toxy/multiscale.wid b/test/toxy/multiscale.wid new file mode 100644 index 0000000..f66ef6c --- /dev/null +++ b/test/toxy/multiscale.wid @@ -0,0 +1,39 @@ +proc ::toxy::multiscalecommand {target sel ndx v} { + pd [concat $target $sel $v $ndx \;] +} + +proc ::toxy::multiscale {path target remote count dx dy bg} { + if {[winfo exists $path.s0]} { +# puts stderr [concat $path.s0 exists] + } else { + set width [expr {$count * $dx + 10}] + set height [expr {$dy + 10}] + $path config -width $width -height $height -bg $bg + set px 5 + set py 5 + for {set ndx 0} {$ndx < $count} {incr ndx} { + scale $path.s$ndx -width $dx -length $dy \ + -from 1 -to 0 -resolution 0.01 \ + -bg $bg -highlightthickness 0 \ + -command [concat ::toxy::multiscalecommand $target _cb $ndx] + if {$dx < 50} { + $path.s$ndx config -showvalue 0 -relief flat + } else { + $path.s$ndx config -digits 3 -relief sunken + } + set id [$path create window $px $py -width $dx -height $dy \ + -anchor nw -window $path.s$ndx -tags $path.s$ndx] + ::toxy::masterinit $path.s$ndx $target $path + incr px $dx + } + } +} + +#> multiscale canvas +#. #n 3 #dx 60 #dy 90 +#. #bg yellow + +::toxy::multiscale .- .| . .#n .#dx .#dy .#bg + +# undo the "bind Canvas <1> {+focus %W}" in the setup part above +bind .- {focus .^.c} diff --git a/test/toxy/popcustom-test.pd b/test/toxy/popcustom-test.pd new file mode 100644 index 0000000..7f49162 --- /dev/null +++ b/test/toxy/popcustom-test.pd @@ -0,0 +1,39 @@ +#N canvas 356 9 338 241 12; +#X obj 38 104 r rpop; +#X floatatom 38 142 5 0 0 0 - - -; +#X floatatom 120 142 5 0 0 0 - - -; +#X obj 120 104 r rpop1; +#X floatatom 210 142 5 0 0 0 - - -; +#X obj 210 104 r rpop2; +#N canvas 12 11 293 279 blackpanel 1; +#X obj 23 111 widget menubutton mb -menu .-.pop -bg green -activebackground +yellow -width 5 -text one @float if .(.#1 >= 1.) .(.-.pop invoke .#1.) +; +#X obj 23 12 loadbang; +#X obj 96 110 widget pop1 p1; +#X obj 188 110 widget pop2 p2; +#X msg 23 41 ini ::toxy::popup .- .| rpop [list one two three four five] +-bg green -activebackground yellow .: destroy .^.m .: .^.scrollvert +configure -width 0 .: .^.scrollhort configure -width 0 .: .^.c configure +-bg black; +#X obj 23 150 r topop; +#X obj 96 150 r topop1; +#X obj 188 150 r topop2; +#X connect 1 0 4 0; +#X connect 4 0 0 0; +#X connect 5 0 0 0; +#X connect 6 0 2 0; +#X connect 7 0 3 0; +#X restore 95 198 pd blackpanel; +#X floatatom 38 24 5 0 0 0 - - -; +#X floatatom 120 24 5 0 0 0 - - -; +#X floatatom 210 24 5 0 0 0 - - -; +#X obj 38 58 s topop; +#X obj 120 58 s topop1; +#X obj 210 58 s topop2; +#X connect 0 0 1 0; +#X connect 3 0 2 0; +#X connect 5 0 4 0; +#X connect 7 0 10 0; +#X connect 8 0 11 0; +#X connect 9 0 12 0; diff --git a/test/toxy/popup-test.pd b/test/toxy/popup-test.pd index 7f49162..ff8df82 100644 --- a/test/toxy/popup-test.pd +++ b/test/toxy/popup-test.pd @@ -1,39 +1,51 @@ -#N canvas 356 9 338 241 12; -#X obj 38 104 r rpop; -#X floatatom 38 142 5 0 0 0 - - -; -#X floatatom 120 142 5 0 0 0 - - -; -#X obj 120 104 r rpop1; -#X floatatom 210 142 5 0 0 0 - - -; -#X obj 210 104 r rpop2; -#N canvas 12 11 293 279 blackpanel 1; -#X obj 23 111 widget menubutton mb -menu .-.pop -bg green -activebackground -yellow -width 5 -text one @float if .(.#1 >= 1.) .(.-.pop invoke .#1.) -; -#X obj 23 12 loadbang; -#X obj 96 110 widget pop1 p1; -#X obj 188 110 widget pop2 p2; -#X msg 23 41 ini ::toxy::popup .- .| rpop [list one two three four five] --bg green -activebackground yellow .: destroy .^.m .: .^.scrollvert -configure -width 0 .: .^.scrollhort configure -width 0 .: .^.c configure --bg black; -#X obj 23 150 r topop; -#X obj 96 150 r topop1; -#X obj 188 150 r topop2; -#X connect 1 0 4 0; -#X connect 4 0 0 0; -#X connect 5 0 0 0; -#X connect 6 0 2 0; -#X connect 7 0 3 0; -#X restore 95 198 pd blackpanel; -#X floatatom 38 24 5 0 0 0 - - -; -#X floatatom 120 24 5 0 0 0 - - -; -#X floatatom 210 24 5 0 0 0 - - -; -#X obj 38 58 s topop; -#X obj 120 58 s topop1; -#X obj 210 58 s topop2; -#X connect 0 0 1 0; -#X connect 3 0 2 0; -#X connect 5 0 4 0; -#X connect 7 0 10 0; -#X connect 8 0 11 0; -#X connect 9 0 12 0; +#N canvas 80 56 700 405 12; +#X obj 17 17 widget popup p #items [.- config] -width 20; +#X obj 20 130 tow . popup p; +#X floatatom 20 71 5 0 0 0 - - -; +#X obj 437 287 tow . popup q; +#X obj 271 17 widget popup q -width 40; +#X obj 20 208 t 0 0; +#X obj 150 130 r rdefault; +#X msg 55 249 list rdefault \$1 3; +#X msg 20 287 list rcurrent \$1 4; +#X msg 89 71 tot pd [concat \$1 set [lindex [.- config [lindex [lindex +[.- config] \$2] 0]] \$3] .`.:]; +#X obj 20 170 - 1; +#X obj 331 130 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 +1; +#X obj 405 130 r rcurrent; +#X msg 150 170; +#X msg 405 170; +#X obj 225 213 route set; +#X obj 331 249 random 20; +#X msg 437 249 tot .-.pop add separator; +#X msg 225 330 tot .-.pop add command -label \$1 .: set [.- cget -textvariable] +\$1; +#X obj 490 208 sel 1; +#X obj 331 170 t 0 0; +#X obj 331 208 metro 500; +#X obj 225 249 route float; +#X obj 308 287 symbol; +#X connect 1 0 10 0; +#X connect 2 0 1 0; +#X connect 5 0 8 0; +#X connect 5 1 7 0; +#X connect 6 0 13 0; +#X connect 7 0 9 0; +#X connect 8 0 9 0; +#X connect 9 0 1 0; +#X connect 10 0 5 0; +#X connect 11 0 20 0; +#X connect 12 0 14 0; +#X connect 12 0 15 0; +#X connect 15 0 22 0; +#X connect 16 0 8 0; +#X connect 17 0 3 0; +#X connect 18 0 3 0; +#X connect 19 0 17 0; +#X connect 20 0 21 0; +#X connect 20 1 19 0; +#X connect 21 0 16 0; +#X connect 22 0 18 0; +#X connect 22 1 23 0; +#X connect 23 0 18 0; diff --git a/test/toxy/setup.wid b/test/toxy/setup.wid new file mode 100644 index 0000000..9f66b61 --- /dev/null +++ b/test/toxy/setup.wid @@ -0,0 +1,272 @@ +# LATER transfer the `standard' toxy setup definitions into a tcl package +# LATER think about using a slave interpreter, and a toxy-specific connection +# LATER gather aqua incompatibilities, and decide, if there is no other +# way than branching (different meaning of -bg, -borderwidth trouble, +# right click, etc.) + +# LATER ask for adding something of the sort to pd.tk: +bind Canvas <1> {+focus %W} + +# In order to keep the state after our canvas has been destroyed +# (i.e. our subpatch closed) -- use 'store' and 'restore' handlers, +# if defined, otherwise try setting -variable and -textvariable traces. + +proc ::toxy::itemdotrace {target varname ndxname op} { + if {[catch {set v [set $varname]} res] == 0} { + if {$v != [set $varname.last]} { +# FIXME activate this on demand (for explicit traces) +# pd $target.rp _value $v \; + set $varname.last $v + } + } else { puts stderr [concat failed ::toxy::itemdotrace: $res] } +} + +proc ::toxy::itembindtrace {varname mastername ndxname op} { + set $varname [set $mastername] +} + +proc ::toxy::itemsettrace {op path target varname} { + if {[catch {$path cget $op} res] == 0} { + if {$res == ""} { + if {[catch {$path config $op $varname} err]} { + error $err + } + } else { + if {[info tclversion] < 8.4} { + trace variable $res w "::toxy::itembindtrace $varname" + } else { + trace add variable $res write "::toxy::itembindtrace $varname" + } + } + if {![info exists $varname.last]} { set $varname.last "" } + if {[info tclversion] < 8.4} { + trace variable $varname w "::toxy::itemdotrace $target" + } else { + trace add variable $varname write "::toxy::itemdotrace $target" + } + return + } else { return 0 } +} + +# LATER revisit -- seems clumsy and fragile +proc ::toxy::itemremovetrace {op path varname} { + if {[catch {$path cget $op} res] == 0} { + if {$res == $varname} { + if {[catch {$path config $op ""} err]} { + error $err + } + } elseif {$res != ""} { + if {[info tclversion] < 8.4} { + catch { trace vdelete $res w "::toxy::itembindtrace $varname" } + } else { + catch { trace remove variable \ + $res write "::toxy::itembindtrace $varname" } + } + } + } +} + +proc ::toxy::itemdestroy {path varname} { + ::toxy::itemremovetrace -variable $path $varname.var + ::toxy::itemremovetrace -textvariable $path $varname.txt + if {[info tclversion] < 8.4} { + catch { unset $varname.last $varname.var $varname.txt $varname } + } else { + unset -nocomplain $varname.last $varname.var $varname.txt $varname + } + catch {destroy $path} +} + +proc ::toxy::itemgetconfig {path target} { + pd $target.rp _config $target.rp [$path cget -bg] \ + [winfo reqwidth $path] [winfo reqheight $path] \ + [catch {$path config -state normal}]\; +} + +proc ::toxy::itemvisconfig {path target name varname cvpath px py} { + if {[info exists ::toxy::itemoptions]} { + set failed [catch {eval $path config $::toxy::itemoptions} res] + unset ::toxy::itemoptions + if {$failed} { error [concat in $path config: $res] } + } + + $cvpath create window $px $py \ + -anchor nw -window $path -tags [concat toxy$name $target] + +# FIXME + if {[info exists ::toxy::storethispath]} { +# FIXME explicit traces + set needtraces 0 + } else { + set needtraces 1 + } + + if {$needtraces != 0} { + if {[catch {::toxy::itemsettrace -variable \ + $path $target $varname.var} res1]} { + error [concat in ::toxy::itemsettrace: $res1] + } + if {[catch {::toxy::itemsettrace -textvariable \ + $path $target $varname.txt} res2]} { + error [concat in ::toxy::itemsettrace: $res2] + } +# puts stderr [concat traces: ($res1) ($res2)] + if {$res1 == 0 && $res2 == 0} { +# puts stderr [concat toxy warning: $path untraceable] + } + } + + if {[info exists ::toxy::masterinits]} { + set failed [catch {eval $::toxy::masterinits} res] + unset ::toxy::masterinits + if {$failed} { error [concat in ::toxy::masterinits: $res] } + } + if {[info exists ::toxy::typeinits]} { + set failed [catch {eval $::toxy::typeinits} res] + unset ::toxy::typeinits + if {$failed} { error [concat in ::toxy::typeinits: $res] } + } + if {[info exists ::toxy::iteminits]} { + set failed [catch {eval $::toxy::iteminits} res] + unset ::toxy::iteminits + if {$failed} { error [concat in ::toxy::iteminits: $res] } + } + + ::toxy::itemgetconfig $path $target + + return +} + +proc ::toxy::itemvis {tkclass path target name varname cvpath px py} { + if {[winfo exists $path]} { +# puts stderr [concat $path exists] + set ::toxy::itemfailure 0 + } else { + set ::toxy::itemfailure [catch {$tkclass $path} ::toxy::itemerrmess] + } + if {$::toxy::itemfailure == 0} { + set ::toxy::itemfailure [catch {::toxy::itemvisconfig \ + $path $target $name $varname $cvpath $px $py} \ + ::toxy::itemerrmess] + } + if {$::toxy::itemfailure} { + if {[winfo exists $path]} {destroy $path} + puts stderr [concat tcl error: $::toxy::itemerrmess] + pd $target.rp _failure \; + } +} + +# FIXME +proc ::toxy::scalecommand {target sel v} { + pd [concat $target $sel $v \;] +} + +proc ::toxy::popupcommand {path target remote i text} { + set [$path cget -textvariable] $text + pd [concat $target _cb $i \;] + if {$remote != "."} { + pd [concat $remote $i \;] + } +} + +proc ::toxy::popup {path target remote entries args} { + if {[winfo exists $path.pop]} { +# puts stderr [concat $path.pop exists] + } elseif {[catch {eval {menu $path.pop} $args} err] == 0} { + set i 0 + foreach e $entries { + if {$e == "."} { + $path.pop add separator + } else { + incr i + $path.pop add command -label [lindex $e 0] \ + -command [concat ::toxy::popupcommand \ + $path $target $remote $i \ + [lindex $e [expr {[llength $e] > 1}]]] + } + } + } else { error [concat in ::toxy::popup: $err] } +} + +# empirically, binding event coords as %X - [winfo rootx $cvpath] works +# better, than %x + [winfo x %W], or %x + t->te_xpix, LATER investigate + +proc ::toxy::itemclick {target cvpath x y b f} { + pd $target.rp _click \ + [$cvpath canvasx [expr {$x - [winfo rootx $cvpath]}]] \ + [$cvpath canvasy [expr {$y - [winfo rooty $cvpath]}]] $b $f\; +} + +proc ::toxy::iteminout {target v} { + pd [concat $target.rp _inout $v \;] +} + +proc ::toxy::masterrelease {target cvpath x y b} { + ::toxy::iteminout $target 3 +# pdtk_canvas_mouseup is a hack, which we must call anyway + pdtk_canvas_mouseup $cvpath \ + [expr {$x - [winfo rootx $cvpath]}] \ + [expr {$y - [winfo rooty $cvpath]}] $b +} + +proc ::toxy::mastermotion {target cvpath x y} { + pd $target.rp _motion \ + [$cvpath canvasx [expr {$x - [winfo rootx $cvpath]}]] \ + [$cvpath canvasy [expr {$y - [winfo rooty $cvpath]}]] 0 \; +} + +proc ::toxy::masterinit {path target cvpath} { + set topitem [expr {[string index $cvpath end-1] == "."}] +# FIXME subitem handling + if {$topitem} { + bind $path \ + "::toxy::masterrelease $target $cvpath %X %Y %b" + } + bind $path <1> "::toxy::itemclick $target $cvpath %X %Y %b 0" + bind $path "::toxy::itemclick $target $cvpath %X %Y %b 1" + bind $path "::toxy::itemclick $target $cvpath %X %Y %b 2" + bind $path "::toxy::itemclick $target $cvpath %X %Y %b 3" + bind $path "::toxy::itemclick $target $cvpath %X %Y %b 4" + bind $path "::toxy::itemclick $target $cvpath %X %Y %b 5" + bind $path "::toxy::itemclick $target $cvpath %X %Y %b 6" + bind $path \ + "::toxy::itemclick $target $cvpath %X %Y %b 7" + bind $path <3> "::toxy::itemclick $target $cvpath %X %Y %b 8" + + bind $path "::toxy::mastermotion $target $cvpath %X %Y" + bind $path "::toxy::iteminout $target 1" + bind $path "::toxy::iteminout $target 0" +} + +# master initializer +#> master + +::toxy::masterinit .- .| .^.c + +# standard widget types + +#> bang button +#. -image ::toxy::img::empty -command .<.> +#. -bg pink -activebackground red -width 50 -height 50 +#. @bang .- flash .: .- invoke + +#> float scale +#. -command [concat ::toxy::scalecommand .| _cb] +#. -bg pink -activebackground red -length 200 +#. @float .- set .#1 + +#> symbol entry +#. -bg pink -font .(helvetica 24.) -width 16 +#. @symbol .- delete 0 end .: .- insert 0 .#1 + +bind .- {eval .<[.- get].>; focus .^.c} + +#> popup menubutton +#. -menu .-.pop +#. -bg purple -fg white -activebackground magenta -text popup +#. -width 8 -relief raised -borderwidth 3 +#. @float if .(.#1 >= 1.) .(.-.pop invoke .#1.) +#. #items test +#. #iprops "-bg" purple "-fg" white "-activebackground" magenta "-borderwidth" 3 + +::toxy::popup .- .| . [concat .#items] .#iprops diff --git a/test/toxy/stress/pophurd.pd b/test/toxy/stress/pophurd.pd new file mode 100644 index 0000000..0a55222 --- /dev/null +++ b/test/toxy/stress/pophurd.pd @@ -0,0 +1,84 @@ +#N canvas 151 100 700 416 12; +#X obj 16 47 tow . popup p; +#X floatatom 16 15 5 0 0 0 - - -; +#X floatatom 16 84 5 0 0 0 - - -; +#X obj 180 10 widget popup p #items [info globals]; +#X obj 260 10 widget popup p #items [info globals]; +#X obj 340 10 widget popup p #items [info globals]; +#X obj 420 10 widget popup p #items [info globals]; +#X obj 500 10 widget popup p #items [info globals]; +#X obj 580 10 widget popup p #items [info globals]; +#X obj 180 40 widget popup p #items [info globals]; +#X obj 260 40 widget popup p #items [info globals]; +#X obj 340 40 widget popup p #items [info globals]; +#X obj 420 40 widget popup p #items [info globals]; +#X obj 500 40 widget popup p #items [info globals]; +#X obj 580 40 widget popup p #items [info globals]; +#X obj 180 70 widget popup p #items [info globals]; +#X obj 260 70 widget popup p #items [info globals]; +#X obj 340 70 widget popup p #items [info globals]; +#X obj 420 70 widget popup p #items [info globals]; +#X obj 500 70 widget popup p #items [info globals]; +#X obj 580 70 widget popup p #items [info globals]; +#X obj 180 100 widget popup p #items [info globals]; +#X obj 260 100 widget popup p #items [info globals]; +#X obj 340 100 widget popup p #items [info globals]; +#X obj 420 100 widget popup p #items [info globals]; +#X obj 500 100 widget popup p #items [info globals]; +#X obj 580 100 widget popup p #items [info globals]; +#X obj 180 130 widget popup p #items [info globals]; +#X obj 260 130 widget popup p #items [info globals]; +#X obj 340 130 widget popup p #items [info globals]; +#X obj 420 130 widget popup p #items [info globals]; +#X obj 500 130 widget popup p #items [info globals]; +#X obj 580 130 widget popup p #items [info globals]; +#X obj 180 160 widget popup p #items [info globals]; +#X obj 260 160 widget popup p #items [info globals]; +#X obj 340 160 widget popup p #items [info globals]; +#X obj 420 160 widget popup p #items [info globals]; +#X obj 500 160 widget popup p #items [info globals]; +#X obj 580 160 widget popup p #items [info globals]; +#X obj 180 190 widget popup p #items [info globals]; +#X obj 260 190 widget popup p #items [info globals]; +#X obj 340 190 widget popup p #items [info globals]; +#X obj 420 190 widget popup p #items [info globals]; +#X obj 500 190 widget popup p #items [info globals]; +#X obj 580 190 widget popup p #items [info globals]; +#X obj 180 220 widget popup p #items [info globals]; +#X obj 260 220 widget popup p #items [info globals]; +#X obj 340 220 widget popup p #items [info globals]; +#X obj 420 220 widget popup p #items [info globals]; +#X obj 500 220 widget popup p #items [info globals]; +#X obj 580 220 widget popup p #items [info globals]; +#X obj 180 250 widget popup p #items [info globals]; +#X obj 260 250 widget popup p #items [info globals]; +#X obj 340 250 widget popup p #items [info globals]; +#X obj 420 250 widget popup p #items [info globals]; +#X obj 500 250 widget popup p #items [info globals]; +#X obj 580 250 widget popup p #items [info globals]; +#X obj 180 280 widget popup p #items [info globals]; +#X obj 260 280 widget popup p #items [info globals]; +#X obj 340 280 widget popup p #items [info globals]; +#X obj 420 280 widget popup p #items [info globals]; +#X obj 500 280 widget popup p #items [info globals]; +#X obj 580 280 widget popup p #items [info globals]; +#X obj 180 310 widget popup p #items [info globals]; +#X obj 260 310 widget popup p #items [info globals]; +#X obj 340 310 widget popup p #items [info globals]; +#X obj 420 310 widget popup p #items [info globals]; +#X obj 500 310 widget popup p #items [info globals]; +#X obj 580 310 widget popup p #items [info globals]; +#X obj 180 340 widget popup p #items [info globals]; +#X obj 260 340 widget popup p #items [info globals]; +#X obj 340 340 widget popup p #items [info globals]; +#X obj 420 340 widget popup p #items [info globals]; +#X obj 500 340 widget popup p #items [info globals]; +#X obj 580 340 widget popup p #items [info globals]; +#X obj 180 370 widget popup p #items [info globals]; +#X obj 260 370 widget popup p #items [info globals]; +#X obj 340 370 widget popup p #items [info globals]; +#X obj 420 370 widget popup p #items [info globals]; +#X obj 500 370 widget popup p #items [info globals]; +#X obj 580 370 widget popup p #items [info globals]; +#X connect 0 0 2 0; +#X connect 1 0 0 0; diff --git a/test/toxy/tclversion.pd b/test/toxy/tclversion.pd index 9b348b0..442e81f 100644 --- a/test/toxy/tclversion.pd +++ b/test/toxy/tclversion.pd @@ -1,13 +1,20 @@ -#N canvas 68 131 532 301 24; -#X obj 38 191 tot .; +#N canvas 68 131 662 379 24; +#X obj 38 247 tot .; #X obj 38 29 loadbang; -#X msg 38 138 query concat set [info tclversion]; -#X msg 38 243; -#X obj 38 86 t b b; -#X msg 147 191 set; -#X connect 0 0 3 0; +#X msg 38 299; +#X msg 147 247 set; +#X obj 38 79 t b b b; +#X obj 231 247 tot .; +#X msg 231 299; +#X msg 78 188 query concat set patchlevel [info patchlevel]; +#X msg 38 138 query concat set version [info tclversion]; +#X connect 0 0 2 0; #X connect 1 0 4 0; -#X connect 2 0 0 0; -#X connect 4 0 2 0; -#X connect 4 1 5 0; -#X connect 5 0 3 0; +#X connect 3 0 2 0; +#X connect 3 0 6 0; +#X connect 4 0 8 0; +#X connect 4 1 7 0; +#X connect 4 2 3 0; +#X connect 5 0 6 0; +#X connect 7 0 5 0; +#X connect 8 0 0 0; diff --git a/toxy/Makefile b/toxy/Makefile index 1718111..a9b675c 100644 --- a/toxy/Makefile +++ b/toxy/Makefile @@ -1,6 +1,6 @@ ROOT_DIR = .. -redefault: default.wiq default -default.wiq: $(ROOT_DIR)/test/toxy/default.wid +redefault: setup.wiq default +setup.wiq: $(ROOT_DIR)/test/toxy/setup.wid $(ROOT_DIR)/quoteinitializer $< \ - '"puts [concat loading built-in widget definitions]\n"' > $@ + '"puts stderr [concat loading built-in widget definitions]\n"' > $@ include $(ROOT_DIR)/Makefile.common diff --git a/toxy/Makefile.sources b/toxy/Makefile.sources index 1626cd6..8befa8d 100644 --- a/toxy/Makefile.sources +++ b/toxy/Makefile.sources @@ -1,4 +1,9 @@ +# this conditional will make sense LATER, when TCL_LIB is ./configured +ifdef TCL_LIB TYPES = TOT TOW WIDGET PLUSTOT +else +TYPES = TOT TOW WIDGET +endif TOT_SOURCES = tot.c TOW_SOURCES = tow.c diff --git a/toxy/build_counter b/toxy/build_counter index 2e12651..7f25b3b 100644 --- a/toxy/build_counter +++ b/toxy/build_counter @@ -1,3 +1,3 @@ #define TOXY_VERSION "0.1" #define TOXY_RELEASE "alpha" -#define TOXY_BUILD 4 +#define TOXY_BUILD 6 diff --git a/toxy/widget.c b/toxy/widget.c index 03be25d..9d1413a 100644 --- a/toxy/widget.c +++ b/toxy/widget.c @@ -1,7 +1,9 @@ -/* Copyright (c) 2003 krzYszcz and others. +/* 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. */ +/* LATER consider supporting a special @ini handler, also think about + differentiating 'ini' from 'vis' */ /* LATER think about reloading method for .wid files */ #include @@ -164,6 +166,10 @@ static void widget_postatoms(char *msg, int ac, t_atom *av) has to be scheduled through a 'transclock', instead. When the clock fires, the widget object creates, and glist_adds a 'makeshift' text object, then glist_deletes itself. */ + +/* this lock prevents glist_noselect() from reevaluating failure boxes */ +static int widget_transforming = 0; + /* LATER also bind this to F4 or something */ static void widget_transtick(t_widget *x) { @@ -173,6 +179,8 @@ static void widget_transtick(t_widget *x) t_atom *opt = props_getall(x->x_options, &nopt); t_atom *hnd = props_getall(x->x_handlers, &nhnd); t_atom *arg = props_getall(x->x_arguments, &narg); + if (widget_transforming++) + bug("widget_transtick"); binbuf_addv(bb, "sss", gensym("widget"), x->x_type, x->x_name); if (narg) binbuf_add(bb, narg, arg); if (nopt) binbuf_add(bb, nopt, opt); @@ -195,6 +203,7 @@ static void widget_transtick(t_widget *x) canvas_unsetcurrent(x->x_glist); canvas_dirty(x->x_glist, 1); glist_delete(x->x_glist, (t_gobj *)x); + widget_transforming--; } /* FIXME x_glist field validation against glist parameter (all handlers) */ @@ -419,6 +428,12 @@ static t_widgetbehavior widget_behavior = FORKY_WIDGETPADDING }; +static void widget_novis(t_widget *x) +{ + sys_vgui("::toxy::itemdestroy %s %s\n", + widget_getmypathname(x, x->x_glist)->s_name, x->x_varname->s_name); +} + static void widget_update(t_widget *x, t_props *op) { if (op == x->x_options) @@ -435,7 +450,7 @@ static void widget_update(t_widget *x, t_props *op) { if (x->x_update == WIDGET_REVIS) { - widget_vis((t_gobj *)x, x->x_glist, 0); + widget_novis(x); widget_vis((t_gobj *)x, x->x_glist, 1); } else if (x->x_update == WIDGET_PUSHVIS) @@ -475,9 +490,9 @@ static t_symbol *widget_addprops(t_widget *x, t_props *op, int single, 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_options, 0, s, ac, av)) && + 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_arguments, 0, s, ac, av); + empty = widget_addprops(x, x->x_options, 0, s, ac, av); return (empty); } @@ -488,7 +503,13 @@ static void widget_anything(t_widget *x, t_symbol *s, int ac, t_atom *av) if (*s->s_name == '-' || *s->s_name == '@' || *s->s_name == '#') { t_symbol *empty; - x->x_update = WIDGET_PUSHVIS; + /* 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).", @@ -672,9 +693,12 @@ static void widget_refresh(t_widget *x) static void widget__failure(t_widget *x, t_symbol *s, int ac, t_atom *av) { +#if 0 + /* moved to the gui side, in order to alow special chars in error message */ startpost("tcl error:"); postatom(ac, av); endpost(); +#endif loud_error((t_pd *)x, "creation failure"); x->x_vised = 0; clock_delay(x->x_transclock, 0); @@ -859,8 +883,7 @@ static void gui_unbind(t_pd *x, t_symbol *s) static void widget_free(t_widget *x) { - sys_vgui("::toxy::itemdestroy %s %s\n", - widget_getmypathname(x, x->x_glist)->s_name, x->x_varname->s_name); + widget_novis(x); gui_unbind((t_pd *)x, x->x_cbtarget); gui_unbind((t_pd *)x, x->x_rptarget); props_freeall(x->x_options); @@ -875,9 +898,12 @@ static void widget_free(t_widget *x) static void *widget_new(t_symbol *s, int ac, t_atom *av) { - t_widget *x = (t_widget *)pd_new(widget_class); + t_widget *x; char buf[MAXPDSTRING]; + if (widget_transforming) + return (0); masterwidget_initialize(); + x = (t_widget *)pd_new(widget_class); x->x_type = 0; x->x_name = 0; if (ac && av->a_type == A_SYMBOL) @@ -904,11 +930,11 @@ static void *widget_new(t_symbol *s, int ac, t_atom *av) sprintf(buf, "%s%x.rp", x->x_name->s_name, (int)x); pd_bind((t_pd *)x, x->x_rptarget = gensym(buf)); + x->x_glist = canvas_getcurrent(); x->x_typedef = widgettype_get(x->x_type); if (!(x->x_tkclass = widgettype_tkclass(x->x_typedef))) x->x_tkclass = x->x_type; - x->x_glist = canvas_getcurrent(); sprintf(buf, ".x%x.c", (int)x->x_glist); x->x_cvpathname = gensym(buf); sprintf(buf, ".x%x", (int)x->x_glist); @@ -931,9 +957,12 @@ static void *widget_new(t_symbol *s, int ac, t_atom *av) widget_propsresolver); outlet_new((t_object *)x, &s_anything); - /* LATER consider estimating these, based on widget class and options */ - x->x_width = 50; - x->x_height = 50; + /* LATER consider estimating these, based on widget class and options. + The default used to be 50x50, which confused people wanting widgets + in small gops, of size exactly as specified by the 'coords' message, + but finding gops stretched, to accomodate the widget's default area. */ + 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); diff --git a/toxy/widgettype.c b/toxy/widgettype.c index 3e04824..4541947 100644 --- a/toxy/widgettype.c +++ b/toxy/widgettype.c @@ -1,4 +1,4 @@ -/* Copyright (c) 2003 krzYszcz and others. +/* 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. */ @@ -12,7 +12,7 @@ #include "widgettype.h" static char masterwidget_builtin[] = -#include "default.wiq" +#include "setup.wiq" ; #define WIDGETTYPE_VERBOSE @@ -36,9 +36,9 @@ struct _masterwidget t_symbol *mw_target; t_scriptlet *mw_setupscript; t_dict *mw_typemap; - t_widgettype *mw_defaulttype; /* contains master iniscript */ - t_widgettype *mw_parsedtype; /* the type currently parsed, if loading */ - t_binbuf *mw_bb; /* auxiliary, LATER remove */ + t_widgettype *mw_mastertype; /* contains master iniscript */ + t_widgettype *mw_parsedtype; /* the type currently parsed, if loading */ + t_binbuf *mw_bb; /* auxiliary, LATER remove */ }; static t_class *widgettype_class; @@ -95,10 +95,10 @@ static t_scriptlet *masterwidget_cmnthook(t_pd *caller, char *rc, typekey = dict_key(mw->mw_typemap, buf); typeval = (t_widgettype *)dict_value(mw->mw_typemap, typekey); if (caller == (t_pd *)mw) - { /* default.wid or built-in defaults */ - if (mw->mw_defaulttype) - { /* no default type in default.wid, extracting built-in one */ - if (typeval != mw->mw_defaulttype) + { /* setup.wid or built-in defaults */ + if (mw->mw_mastertype) + { /* no master type in setup.wid, extracting built-in one */ + if (typeval != mw->mw_mastertype) return (SCRIPTLET_LOCK); } else @@ -168,23 +168,26 @@ static t_scriptlet *masterwidget_cmnthook(t_pd *caller, char *rc, t_widgettype *widgettype_get(t_symbol *s) { t_widgettype *wt; - /* default.wid defs are NOT overridden by .wid -- - feature stability comes first, LATER rethink */ + /* Design decision: setup.wid defs are NOT overridden by .wid + (sacrificing flexibility for feature stability). */ if (wt = (t_widgettype *)dict_value(masterwidget->mw_typemap, dict_key(masterwidget->mw_typemap, s->s_name))) masterwidget->mw_parsedtype = 0; else { - /* first instance of a type not defined in default.wid */ + /* first instance of a type not defined in setup.wid */ wt = widgettype_new(masterwidget, s->s_name, 0, 0); masterwidget->mw_parsedtype = wt; } if (masterwidget->mw_parsedtype) { + /* .wid searched in the current patch's dir + pd_path, + but not in `pwd` */ t_scriptlet *mwsp = scriptlet_new((t_pd *)masterwidget, masterwidget->mw_target, - masterwidget->mw_target, 0, 0, 0); + masterwidget->mw_target, 0, + canvas_getcurrent(), 0); if (scriptlet_rcload(mwsp, (t_pd *)wt, s->s_name, ".wid", 0, masterwidget_cmnthook) == SCRIPTLET_OK) @@ -264,7 +267,7 @@ void widgettype_setup(void) int masterwidget_evaluate(t_scriptlet *outsp, int visedonly, int ac, t_atom *av, t_props *argprops) { - return (scriptlet_evaluate(masterwidget->mw_defaulttype->wt_iniscript, + return (scriptlet_evaluate(masterwidget->mw_mastertype->wt_iniscript, outsp, visedonly, ac, av, argprops)); } @@ -288,44 +291,46 @@ void masterwidget_initialize(void) masterwidget->mw_typemap = dict_new(0); + /* setup.wid searched in `pwd` + pd_path, but not in current patch's dir + (LATER only the pd_path should be searched) */ masterwidget->mw_setupscript = scriptlet_new((t_pd *)masterwidget, masterwidget->mw_target, masterwidget->mw_target, 0, 0, 0); masterwidget->mw_bb = binbuf_new(); masterwidget->mw_parsedtype = 0; - masterwidget->mw_defaulttype = 0; + masterwidget->mw_mastertype = 0; rcresult = - scriptlet_rcload(masterwidget->mw_setupscript, 0, "default", ".wid", + scriptlet_rcload(masterwidget->mw_setupscript, 0, "setup", ".wid", masterwidget_builtin, masterwidget_cmnthook); if (rcresult == SCRIPTLET_OK) { #ifdef WIDGETTYPE_VERBOSE - post("using file 'default.wid'"); + post("using file 'setup.wid'"); #endif } else { loud_warning((t_pd *)masterwidget, - "no file 'default.wid'... using built-in defaults"); + "no file 'setup.wid'... using built-in defaults"); } - typekey = dict_key(masterwidget->mw_typemap, "default"); + typekey = dict_key(masterwidget->mw_typemap, "master"); if ((typeval = (t_widgettype *)dict_value(masterwidget->mw_typemap, typekey)) && !scriptlet_isempty(masterwidget->mw_setupscript)) { - masterwidget->mw_defaulttype = typeval; + masterwidget->mw_mastertype = typeval; rcresult = SCRIPTLET_OK; } else if (rcresult == SCRIPTLET_OK) { /* LATER think about adding only missing part to existing local defs */ - loud_warning((t_pd *)masterwidget, "%s missing in file 'default.wid'", + loud_warning((t_pd *)masterwidget, "%s missing in file 'setup.wid'", (typeval ? "setup definitions" : "master initializer")); - masterwidget->mw_defaulttype = - widgettype_new(masterwidget, "default", 0, 0); + masterwidget->mw_mastertype = + widgettype_new(masterwidget, "master", 0, 0); scriptlet_reset(masterwidget->mw_setupscript); rcresult = - scriptlet_rcparse(masterwidget->mw_setupscript, 0, "default", + scriptlet_rcparse(masterwidget->mw_setupscript, 0, "master", masterwidget_builtin, masterwidget_cmnthook); } else -- cgit v1.2.1