From cdd23c6b9523654eb3bf03542021404888fdbcba Mon Sep 17 00:00:00 2001 From: "N.N." Date: Tue, 10 May 2005 18:02:20 +0000 Subject: toxy alpha17 and pddp alpha1 (see notes.txt for toxy, pddp and shared) svn path=/trunk/externals/miXed/; revision=2940 --- test/cyclone/speedlim-rescheduling.pd | 54 ++++++++ test/toxy/button-test.pd | 2 +- test/toxy/editors/bpf-test.pd | 13 ++ test/toxy/editors/bpf.wid | 224 ++++++++++++++++++++++++++++++++++ test/toxy/listbox-test.pd | 2 +- test/toxy/popcustom-test.pd | 2 +- test/toxy/setup.wid | 47 ++++--- test/toxy/testmess.wid | 3 - test/toxy/tow-test.pd | 2 +- 9 files changed, 327 insertions(+), 22 deletions(-) create mode 100644 test/cyclone/speedlim-rescheduling.pd create mode 100644 test/toxy/editors/bpf-test.pd create mode 100644 test/toxy/editors/bpf.wid (limited to 'test') diff --git a/test/cyclone/speedlim-rescheduling.pd b/test/cyclone/speedlim-rescheduling.pd new file mode 100644 index 0000000..62727ae --- /dev/null +++ b/test/cyclone/speedlim-rescheduling.pd @@ -0,0 +1,54 @@ +#N canvas 246 121 642 393 12; +#X msg 126 17 bang; +#X obj 126 58 t b b b; +#X msg 151 108 1; +#X msg 60 151 2; +#X msg 401 17 bang; +#X obj 401 58 t b b b; +#X msg 426 108 1; +#X msg 335 151 2; +#X obj 151 288 timer; +#X obj 151 241 sel 1 2; +#X obj 426 288 timer; +#X obj 426 241 sel 1 2; +#X obj 285 241 print; +#X floatatom 151 332 5 0 0 0 - - -; +#X floatatom 426 332 5 0 0 0 - - -; +#X msg 242 108 1000; +#X obj 151 198 speedlim 200; +#X msg 202 151 200; +#X msg 517 108 1000; +#X msg 478 151 200; +#X obj 426 198 speedlim 200; +#X obj 60 108 del 600; +#X obj 335 108 del 600; +#X connect 0 0 1 0; +#X connect 1 0 21 0; +#X connect 1 1 15 0; +#X connect 1 2 2 0; +#X connect 2 0 16 0; +#X connect 3 0 16 0; +#X connect 4 0 5 0; +#X connect 5 0 22 0; +#X connect 5 1 6 0; +#X connect 5 2 18 0; +#X connect 6 0 20 0; +#X connect 7 0 20 0; +#X connect 8 0 13 0; +#X connect 9 0 8 0; +#X connect 9 1 8 1; +#X connect 9 1 17 0; +#X connect 10 0 14 0; +#X connect 11 0 10 0; +#X connect 11 1 10 1; +#X connect 11 1 19 0; +#X connect 15 0 16 1; +#X connect 16 0 9 0; +#X connect 16 0 12 0; +#X connect 17 0 16 1; +#X connect 18 0 20 1; +#X connect 19 0 20 1; +#X connect 20 0 11 0; +#X connect 20 0 12 0; +#X connect 21 0 3 0; +#X connect 22 0 7 0; diff --git a/test/toxy/button-test.pd b/test/toxy/button-test.pd index 26e181b..2210319 100644 --- a/test/toxy/button-test.pd +++ b/test/toxy/button-test.pd @@ -21,7 +21,7 @@ red -command .<.>; #X msg 90 213 -command .(set c [tk_chooseColor] .: eval .<| set "-bg" $c "-text" $c.>.); #X obj 294 268 loadbang; -#X msg 294 295 ini .- config -textvariable ""; +#X msg 294 295 set @vis .- config -textvariable ""; #X obj 250 21 widget button bb -bg green -activebackground yellow -command .<.> ; #X connect 0 0 3 0; diff --git a/test/toxy/editors/bpf-test.pd b/test/toxy/editors/bpf-test.pd new file mode 100644 index 0000000..77fc3fc --- /dev/null +++ b/test/toxy/editors/bpf-test.pd @@ -0,0 +1,13 @@ +#N canvas 212 48 778 592 12; +#X obj 70 95 widget bpf f1; +#X obj 240 321 widget bpf f1; +#X obj 432 92 widget bpf f2; +#X msg 77 331 redefine; +#X obj 77 370 tow . bpf f1; +#X msg 80 432 redefine; +#X msg 578 336 redefine; +#X obj 578 375 tow . bpf f2; +#X obj 80 471 tow . bpf; +#X connect 3 0 4 0; +#X connect 5 0 8 0; +#X connect 6 0 7 0; diff --git a/test/toxy/editors/bpf.wid b/test/toxy/editors/bpf.wid new file mode 100644 index 0000000..1b30646 --- /dev/null +++ b/test/toxy/editors/bpf.wid @@ -0,0 +1,224 @@ +catch {console show} +::toxy::package_require BLT "e:/Tcl/bin/BLT24.dll" + +namespace eval ::toxy::bpf {} + +proc ::toxy::bpf::ondrag {path ndx} { + set ${path}::idrag $ndx + if {$ndx > 0} { + incr ndx -1 + set ${path}::mindrag [${path}::xvec range $ndx $ndx] + incr ndx + } else { + set ${path}::mindrag 0 + } + incr ndx + if {$ndx < [${path}::xvec length]} { + set ${path}::maxdrag [${path}::xvec range $ndx $ndx] + } else { + set ${path}::maxdrag [set ${path}::xmax] + } +} + +proc ::toxy::bpf::atData {path args} { + set cmd [lindex $args 0] + switch -- $cmd { + set { + set idrag [lindex $args 1] + set gx [lindex $args 2] + set gy [lindex $args 3] + if {[string is double -strict $idrag] && + [string is double -strict $gx] && + [string is double -strict $gy]} { + + ${path}::xvec variable xvec + ${path}::yvec variable yvec + array set xvec [list $idrag $gx] + array set yvec [list $idrag $gy] + ${path}::xvec sort ${path}::yvec ${path}::zvec + } + } + add { + set gx [lindex $args 1] + set gy [lindex $args 2] + if {[string is double -strict $gx] && + [string is double -strict $gy]} { + + ${path}::xvec append $gx + ${path}::yvec append $gy + ${path}::zvec append 0 + ${path}::xvec sort ${path}::yvec ${path}::zvec + set ndx [${path}::xvec search $gx] + if {[llength $ndx] > 1} { + set ndx [lindex $ndx 0] + } elseif {[llength $ndx] < 1} { + set ${path}::idrag -1 + return + } + ::toxy::bpf::ondrag $path $ndx + } + } + } +} + +proc ::toxy::bpf::motion {path x y} { + if {[set ${path}::locked]} { return } + if {[$path element closest $x $y cl -halo 10 el]} { + $path config -cursor arrow + } else { + $path config -cursor crosshair + } +} + +proc ::toxy::bpf::b1motion {path x y} { + if {[set ${path}::locked]} { return } + variable ${path}::idrag + if {$idrag >= 0 && [$path inside $x $y]} { + variable ${path}::mindrag + variable ${path}::maxdrag + set gxy [$path invtransform $x $y] + set gx [lindex $gxy 0] + if {$gx < $mindrag} { + set gx $mindrag + } elseif {$gx > $maxdrag} { + set gx $maxdrag + } + ${path}::xvec variable xvec + ${path}::yvec variable yvec + array set xvec [list $idrag $gx] + array set yvec [list $idrag [lindex $gxy 1]] + } +} + +proc ::toxy::bpf::b1release {path x y} { + if {[set ${path}::locked]} { return } + variable ${path}::idrag + if {$idrag >= 0 && [$path inside $x $y]} { + variable ${path}::mindrag + variable ${path}::maxdrag + set gxy [$path invtransform $x $y] + set gx [lindex $gxy 0] + set gy [lindex $gxy 1] + if {$gx < $mindrag} { + set gx $mindrag + } elseif {$gx > $maxdrag} { + set gx $maxdrag + } + + variable ${path}::target + pd $target.rp _data set $idrag $gx $gy \; + } + set ${path}::idrag -1 + set ${path}::mindrag 0 + set ${path}::maxdrag ${path}::xmax +} + +proc ::toxy::bpf::b1click {path x y} { + if {[set ${path}::locked]} { return } + if {[$path element closest $x $y cl -halo 10 el]} { + set gxy [$path invtransform $x $y] + set ${path}::xdrag [lindex $gxy 0] + set ${path}::ydrag [lindex $gxy 1] + ::toxy::bpf::ondrag $path $cl(index) + } elseif {[$path inside $x $y]} { + set gxy [$path invtransform $x $y] + set ${path}::xdrag [lindex $gxy 0] + set ${path}::ydrag [lindex $gxy 1] + variable ${path}::xdrag + variable ${path}::ydrag + + variable ${path}::target + pd $target.rp _data add $xdrag $ydrag \; + } else { + set ${path}::idrag -1 + } +} + +proc ::toxy::bpf::shiftb1click {path x y} { + if {[set ${path}::locked]} { return } + if {[$path element closest $x $y cl -halo 10 el]} { + set ndx $cl(index) + ${path}::xvec delete $ndx + ${path}::yvec delete $ndx + ${path}::zvec delete $ndx + } + set ${path}::idrag -1 +} + +proc ::toxy::bpf::lock {path v} { + set ${path}::locked $v + if {$v} { + $path config -cursor hand2 + } else { + $path config -cursor crosshair + } +} + +proc ::toxy::bpf::atVis {path} { + bind $path +[concat ::toxy::bpf::motion %W %x %y] + bind $path <1> +[concat ::toxy::bpf::b1click %W %x %y] + bind $path +[concat ::toxy::bpf::b1motion %W %x %y] + bind $path +[concat ::toxy::bpf::b1release %W %x %y] + bind $path <> +[concat ::toxy::bpf::lock %W 1] + bind $path <> +[concat ::toxy::bpf::lock %W 0] + $path element bind el "::toxy::bpf::shiftb1click %W %x %y" +} + +proc ::toxy::bpf::atNew {path} { + variable ${path}::xmax + variable ${path}::ymin + variable ${path}::ymax + $path axis configure x -min 0.0 -max $xmax + $path axis configure y -min $ymin -max $ymax + $path element create el -x ${path}::xvec -y ${path}::yvec \ + -symbol "circle" -pixels 2 -linewidth 2 -color darkgreen -hide 0 + $path legend config -hide yes +} + +proc ::toxy::bpf::atFree {path} { + blt::vector destroy ${path}::xvec + blt::vector destroy ${path}::yvec + blt::vector destroy ${path}::zvec +} + +#> bpf blt::graph +#. -width 300 -height 200 -bg lightblue -plotbackground lightgrey -halo 10 +#. #domain 1000. + +#@ vis + +# LATER reconsider calling standard procs implicitly, followed by scripts +::toxy::bpf::atVis .- + +#@ new + +# LATER reconsider replacing this with global .- (using ::${path} in procs) +namespace eval ::toxy::bpf::.- { +# this might be implicit + set target .| + +# array interface seems broken inside namespaces +# (cf sf.net/projects/blt bug 651993) + blt::vector create xvec -variable "" + blt::vector create yvec -variable "" + blt::vector create zvec -variable "" + set locked 0 + set xmax .#domain + set ymin 0.0 + set ymax 1.0 + set idrag -1 + set mindrag 0 + set maxdrag $xmax + set xdrag 0 + set ydrag 0 +} + +::toxy::bpf::atNew .- + +#@ free + +::toxy::bpf::atFree .- + +#@ data + +::toxy::bpf::atData .- .#args diff --git a/test/toxy/listbox-test.pd b/test/toxy/listbox-test.pd index 751fb58..99bf2e8 100644 --- a/test/toxy/listbox-test.pd +++ b/test/toxy/listbox-test.pd @@ -12,7 +12,7 @@ white @bang ::toxy::lbcommand .- .|; #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 +curselection]] .`.:].).) \, @vis if .([.- size] == 0.) .(foreach fn [lsort [glob *]] .(.- insert end $fn.) .: bind .- .(::toxy::lbcommand .- .|.).) \, @bang ::toxy::lbcommand .- .|; #X connect 1 0 5 0; diff --git a/test/toxy/popcustom-test.pd b/test/toxy/popcustom-test.pd index 7f49162..2589bfe 100644 --- a/test/toxy/popcustom-test.pd +++ b/test/toxy/popcustom-test.pd @@ -12,7 +12,7 @@ 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] +#X msg 23 41 set @vis ::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; diff --git a/test/toxy/setup.wid b/test/toxy/setup.wid index ce498c4..05e0164 100644 --- a/test/toxy/setup.wid +++ b/test/toxy/setup.wid @@ -1,4 +1,4 @@ -package provide toxywidgets 0.1.0.16 +package provide toxywidgets 0.1.0.17 # LATER keep standard widget setup in a .tcl file (transfered into a .wiq), and # glue separate .wid files with standard widget definitions into another .wiq @@ -10,15 +10,24 @@ package provide toxywidgets 0.1.0.16 # 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. +# FIXME args +proc ::toxy::package_require {pkg dll} { + if {[catch {package require $pkg} res] == 0} { + puts stderr "using package $pkg $res" + } elseif {[catch {load $dll $pkg}] != 0} { + puts stderr "ERROR: missing package $pkg ($res)" + } +} + +# FIXME this should be explicitly requested +# In order to keep the state after tk canvas has been destroyed +# try setting -variable and -textvariable traces proc ::toxy::item_dotrace {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 \; +# pd $target.rp _data $v \; set $varname.last $v } } else { puts stderr [concat failed ::toxy::item_dotrace: $res] } @@ -100,10 +109,16 @@ proc ::toxy::item_visconfig {path target name varname cvpath px py} { if {$failed} { error [concat in $path config: $res] } } + if {[info exists ::toxy::longnewhook]} { + set failed [catch {eval $::toxy::longnewhook} res] + unset ::toxy::longnewhook + if {$failed} { error [concat in ::toxy::longnewhook: $res] } + } + $cvpath create window $px $py \ -anchor nw -window $path -tags [concat toxy$name $target] -# FIXME +# FIXME use ${name}::explicittrace if {[info exists ::toxy::storethispath]} { # FIXME explicit traces set needtraces 0 @@ -129,15 +144,15 @@ proc ::toxy::item_visconfig {path target name varname cvpath px py} { set failed [catch {::toxy::master $path $cvpath $target} res] if {$failed} { error [concat in ::toxy::master: $res] } - if {[info exists ::toxy::typeinit]} { - set failed [catch {eval $::toxy::typeinit} res] - unset ::toxy::typeinit - if {$failed} { error [concat in ::toxy::typeinit: $res] } + if {[info exists ::toxy::longvishook]} { + set failed [catch {eval $::toxy::longvishook} res] + unset ::toxy::longvishook + if {$failed} { error [concat in ::toxy::longvishook: $res] } } - if {[info exists ::toxy::iteminit]} { - set failed [catch {eval $::toxy::iteminit} res] - unset ::toxy::iteminit - if {$failed} { error [concat in ::toxy::iteminit: $res] } + if {[info exists ::toxy::shortvishook]} { + set failed [catch {eval $::toxy::shortvishook} res] + unset ::toxy::shortvishook + if {$failed} { error [concat in ::toxy::shortvishook: $res] } } ::toxy::item_getconfig $path $target @@ -220,7 +235,7 @@ proc ::toxy::master {path cvpath target} { } } -# to be called explicitly from type initializer, LATER rethink +# to be called explicitly from vis proc, LATER rethink proc ::toxy::subwidget {path parent cvpath target} { bind $path "::toxy::master_release $target $cvpath %X %Y %b" bind $path <1> "::toxy::item_click $target $cvpath %X %Y %b 0" @@ -305,6 +320,7 @@ set ::toxy::scale_isactive 1 #. -bg pink -font .(helvetica 24.) -width 16 #. @symbol .- delete 0 end .: .- insert 0 .#1 +#@ vis bind .- {eval .<[.- get].>; focus .^.c} #> popup menubutton @@ -315,4 +331,5 @@ bind .- {eval .<[.- get].>; focus .^.c} #. #items test #. #iprops "-bg" purple "-fg" white "-activebackground" magenta "-borderwidth" 3 +#@ vis ::toxy::popup .- .| . [concat .#items] .#iprops diff --git a/test/toxy/testmess.wid b/test/toxy/testmess.wid index 0481e2f..85894be 100644 --- a/test/toxy/testmess.wid +++ b/test/toxy/testmess.wid @@ -42,6 +42,3 @@ puts "another initializer part added from \"#@ vis\" block" #@ free puts "\ndestructor: evaluated once, after Pd object destruction" puts "(Tk widget should be already gone)" - -#@ ini -puts "yet another initializer part added from \"#@ ini\" block" diff --git a/test/toxy/tow-test.pd b/test/toxy/tow-test.pd index d0a8c95..cf6ece4 100644 --- a/test/toxy/tow-test.pd +++ b/test/toxy/tow-test.pd @@ -42,7 +42,7 @@ #X msg 63 183 -bg orange; #X msg 50 153 -bg brown; #X obj 136 21 loadbang; -#X msg 136 56 ini .^.c configure -bg darkgreen; +#X msg 136 56 set @vis .^.c configure -bg darkgreen; #X connect 0 0 5 0; #X connect 2 0 4 0; #X connect 4 0 3 0; -- cgit v1.2.1