Update of /cvsroot/pure-data/extensions/gui/ix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12160
Modified Files: kbd-demo.pd Added Files: kbd2.wid Log Message: k2
Index: kbd-demo.pd =================================================================== RCS file: /cvsroot/pure-data/extensions/gui/ix/kbd-demo.pd,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** kbd-demo.pd 5 Apr 2005 13:32:37 -0000 1.1 --- kbd-demo.pd 17 May 2005 17:53:41 -0000 1.2 *************** *** 1,8 **** #N canvas 360 12 554 299 12; ! #X obj 56 57 widget kbd k1 #octaves 7 -width 472.441 -height 67.4916 ; - #X obj 343 246 tow . kbd k1; - #X msg 302 223 -width $1; - #X msg 365 223 -height $1; #X obj 56 134 unpack; #X floatatom 56 155 5 0 0 0 - - -; --- 1,5 ---- #N canvas 360 12 554 299 12; ! #X obj 56 57 widget kbd k1 #octaves 7 -width 444.094 -height 63.4421 ; #X obj 56 134 unpack; #X floatatom 56 155 5 0 0 0 - - -; *************** *** 22,62 **** #X obj 92 173 * 0.4; #X floatatom 115 14 5 0 1 0 - - -; - #X obj 305 172 hsl 128 15 0 600 0 0 empty empty empty -2 -6 0 8 -262144 - -1 -1 10000 1; - #X floatatom 335 187 5 0 0 0 - - -; #X floatatom 149 21 5 0 12 0 - - -; #X msg 148 38 #octaves $1; ! #X obj 56 174 + 24; ! #X obj 367 202 / 7; ! #X floatatom 441 180 5 5 9 0 - - -; ! #X obj 397 195 t b f; #X connect 0 0 4 0; ! #X connect 0 0 7 0; ! #X connect 2 0 1 0; ! #X connect 3 0 1 0; ! #X connect 4 0 5 0; ! #X connect 4 1 6 0; ! #X connect 5 0 24 0; ! #X connect 6 0 18 0; #X connect 8 0 0 0; ! #X connect 9 0 8 0; ! #X connect 10 0 8 1; ! #X connect 11 0 0 0; ! #X connect 12 0 17 0; ! #X connect 13 0 12 0; ! #X connect 14 0 17 1; ! #X connect 15 0 14 0; ! #X connect 17 0 16 0; ! #X connect 17 0 16 1; ! #X connect 18 0 15 0; ! #X connect 19 0 8 1; ! #X connect 20 0 21 0; ! #X connect 21 0 2 0; ! #X connect 21 0 25 0; ! #X connect 22 0 23 0; ! #X connect 23 0 0 0; ! #X connect 24 0 13 0; ! #X connect 25 0 3 0; ! #X connect 26 0 27 0; ! #X connect 27 0 21 0; ! #X connect 27 1 25 1; --- 19,47 ---- #X obj 92 173 * 0.4; #X floatatom 115 14 5 0 1 0 - - -; #X floatatom 149 21 5 0 12 0 - - -; #X msg 148 38 #octaves $1; ! #X obj 165 140 widget kbd2 k2 #octaves 3 #bg purple #fg pink -height ! 32; ! #X obj 56 174 + 36; ! #X connect 0 0 1 0; #X connect 0 0 4 0; ! #X connect 1 0 2 0; ! #X connect 1 1 3 0; ! #X connect 2 0 20 0; ! #X connect 3 0 15 0; ! #X connect 5 0 0 0; ! #X connect 6 0 5 0; ! #X connect 7 0 5 1; #X connect 8 0 0 0; ! #X connect 9 0 14 0; ! #X connect 10 0 9 0; ! #X connect 11 0 14 1; ! #X connect 12 0 11 0; ! #X connect 14 0 13 0; ! #X connect 14 0 13 1; ! #X connect 15 0 12 0; ! #X connect 16 0 5 1; ! #X connect 17 0 18 0; ! #X connect 18 0 0 0; ! #X connect 19 0 1 0; ! #X connect 20 0 10 0;
--- NEW FILE: kbd2.wid --- namespace eval ::ix { proc kbd2_play {b x y} { array set rs {0 sunken 1 raised} ; array set sr {0 $rs(1) 1 $rs(0)} array set v {0 0 1 {($y - [winfo rooty $w]) / ([winfo height $w] + 0.0)}} set w [winfo containing $x $y] if {[$w cget -relief] eq $rs($b)} { eval $w config -relief $sr($b) pd "[winfo name [winfo parent [winfo parent $w]]].rp _cb [winfo name $w] [eval expr $v($b)] ;"}}
proc kbd2 {path target octaves b f} { if {![winfo exists $path.f0]} { $path config -width [expr $octaves * 66] set bw {0 1 0 1 0 0 1 0 1 0 1 0} ; set npl {0 1 1 2 2 3 4 4 5 5 6 6} array set bg "0 $b 1 $f" array set fg {1 $bg(0) 0 $bg(1)} array set rw {0 {[expr 1 / 7.]} 1 {[expr 1 / 10.]}} array set rh {0 {[expr 1.]} 1 {[expr 6 / 10.]}} array set an {0 ";lower $wk" 1 "-anchor n"} for {set o 0} {$o < $octaves} {incr o} { set w $path.f$o frame $w -bd 0 -height 66 -width 66 for {set on 0} {$on < 12} {incr on} { set wk $w.[expr $o * 12 + $on] set n [lindex $bw $on] eval label $wk -bg $bg($n) -fg $fg($n) -bd 1 -relief raised eval place $wk -relx [expr [lindex $npl $on] / 7.] -y 0 -relwidth $rw($n) -relheight $rh($n) $an($n) bind $wk <1> {::ix::kbd2_play 1 %X %Y}; bind $wk <B1-Motion> [bind $wk <1>] bind $wk <ButtonRelease-1> {::ix::kbd2_play 0 %X %Y}; bind $wk <Leave> [bind $wk <ButtonRelease-1>]} place $w -y 0 -relheight 1.0 -relx [expr $o / $octaves.0] -relwidth [expr 1 / $octaves.0]}}}}
#> kbd2 frame #. -height 100 -width 60 #. #octaves 6 #bg black #fg white
#@ new ::ix::kbd2 .- .| .#octaves .#bg .#fg