Update of /cvsroot/pure-data/extensions/gui/ix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8123
Modified Files: mat.wid Log Message: ^G Get Help ^O WriteOut ^R Read File ^Y Prev Page ^K Cut Text ^C Cur Pos
Index: mat.wid =================================================================== RCS file: /cvsroot/pure-data/extensions/gui/ix/mat.wid,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** mat.wid 19 Jun 2005 02:21:13 -0000 1.8 --- mat.wid 19 Jun 2005 08:34:31 -0000 1.9 *************** *** 8,118 **** set vel [$p.m itemcget $item -fillopacity] pd [concat $t.rp _cb note [dict get $_($t) $id y] $vel $len ;]} ! namespace eval actions { ! proc action {p t o} {puts gah} ! proc draw {p t o} {puts draw} ! proc resize_canvas {p t o} {} ! proc move_canvas {p t o} {puts cvda} ! proc move_object {p t o} { ! puts hiihect ! } ! } ! proc mat_click {m button action p t x y} { ! variable _ ! set a [$p.m itemcget mode -text] ! eval actions::$a $p $t o ! switch $m { ! control {mat_draw $action $p $t $x $y} ! "" { ! set clicked [$p.m find overlapping $x $y $x $y] ! switch $action { ! hover { ! foreach item $clicked { ! if {[lindex [$p.m itemcget $item -tags] 0] eq "item"} { ! mat_note $p $t $item ! } ! } ! if {$clicked ne "" && [lindex [$p.m itemcget $item -tags] 0] eq "item"} { ! mat_mode $p $t {move_object} ! } {mat_mode $p $t {move_canvas}} ! set junk "" ! foreach cfg [$p.m itemconfigure $clicked] {set junk "$junk\n$cfg"} ! mat_info $p $t $junk ! } ! first { ! # if {$clicked ne ""} { ! set _($t:cl) $clicked ! # } ! foreach xy {x y} {set _($t:f$xy) [set $xy]} ! switch $button {2 {mat_mode $p $t resize_canvas}} ! } ! motion { ! set mx [expr $x - $_($t:cx)] ! set my [expr $y - $_($t:cy)] ! foreach xy {x y} { ! set mvt [mat_tr $p $t $xy d [expr $$xy - $_($t:c$xy)]] ! switch $button { ! 1 { ! foreach ab {a b} { ! set _($t:${xy}$ab) [expr $_($t:${xy}$ab) - $mvt] ! } ! } ! 2 { ! set _($t:${xy}a) [expr $_($t:${xy}a) - $mvt] ! set _($t:${xy}b) [expr $_($t:${xy}b) + $mvt] ! } ! } ! } ! switch $button { ! 1 { ! if {$clicked ne ""} { ! set items $clicked ! } else { ! set items [$p.m find withtag item] ! mat_gridlines $p $t ! } ! foreach item $items { ! set m [$p.m itemcget $item -matrix] ! set m [list [lindex $m 0] [lindex $m 1] [list [expr [lindex [lindex $m 2] 0] + $mx] [expr [lindex [lindex $m 2] 1] + $my]]] ! $p.m itemconfigure $item -matrix $m ! } ! } ! 2 { ! foreach item [$p.m find withtag item] { ! set id [lindex [$p.m itemcget $item -tags] 1] ! set px [mat_tr $p $t x t [dict get $_($t) $id x]] ! set py [mat_tr $p $t y t [dict get $_($t) $id y]] ! set sx [mat_tr $p $t x id [expr [dict get $_($t) $id xx] - [dict get $_($t) $id x]]] ! set sy [mat_tr $p $t y id 1] ! $p.m coords $item [::tkpath::coords rect $px $py $sx $sy -rx 3 -ry 3] ! } ! mat_gridlines $p $t ! } ! 3 { ! set velo [expr ($x - $_($t:cx)) / 100.0] ! foreach item $_($t:cl) { ! set vel [expr $velo + [$p.m itemcget $item -fillopacity]] ! if {$vel > 1} {set vel 1} ! if {$vel < 0} {set vel 0} ! $p.m itemconfigure $item -fillopacity $vel ! } ! } ! } ! } ! release { ! switch $button { ! 2 {mat_mode $p $t move_canvas} ! } ! } ! } ! foreach xy {x y} {set _($t:c$xy) [set $xy]} ! } ! } ! } ! ! proc mat_draw {action p t x y} { variable _ ! switch $action { motion { ! if {$x >= $_($t:cx)} {set xa $_($t:cx);set xb $x} else {set xa $x;set xb $_($t:cx)} $p.m coords drawing [::tkpath::coords rect $xa $y [expr $xb - $xa] [mat_tr $p $t y id 1] -rx 3 -ry 3] set yi [mat_tr $p $t y i $y] --- 8,17 ---- set vel [$p.m itemcget $item -fillopacity] pd [concat $t.rp _cb note [dict get $_($t) $id y] $vel $len ;]} ! proc mat_action {p t a x y} {puts gah} ! proc mat_draw {p t a x y} { variable _ ! switch $a { motion { ! if {$x >= $_($t:cx)} {set xa $_($t:fx);set xb $x} else {set xa $x;set xb $_($t:fx)} $p.m coords drawing [::tkpath::coords rect $xa $y [expr $xb - $xa] [mat_tr $p $t y id 1] -rx 3 -ry 3] set yi [mat_tr $p $t y i $y] *************** *** 129,132 **** --- 28,134 ---- incr _($t:i) 2}}}
+ proc mat_resize_canvas {p t a x y} { + variable _ + set mx [expr $x - $_($t:cx)] + set my [expr $y - $_($t:cy)] + foreach xy {x y} { + set mvt [mat_tr $p $t $xy d [expr $$xy - $_($t:c$xy)]] + set _($t:${xy}a) [expr $_($t:${xy}a) - $mvt] + set _($t:${xy}b) [expr $_($t:${xy}b) + $mvt] + } + foreach item [$p.m find withtag item] { + set id [lindex [$p.m itemcget $item -tags] 1] + set px [mat_tr $p $t x t [dict get $_($t) $id x]] + set py [mat_tr $p $t y t [dict get $_($t) $id y]] + set sx [mat_tr $p $t x id [expr [dict get $_($t) $id xx] - [dict get $_($t) $id x]]] + set sy [mat_tr $p $t y id 1] + $p.m coords $item [::tkpath::coords rect $px $py $sx $sy -rx 3 -ry 3] + } + mat_gridlines $p $t + } + proc mat_object_trans {p t a x y} { + variable _ + set velo [expr ($x - $_($t:cx)) / 100.0] + foreach item $_($t:cl) { + set vel [expr $velo + [$p.m itemcget $item -fillopacity]] + if {$vel > 1} {set vel 1} + if {$vel < 0} {set vel 0} + $p.m itemconfigure $item -fillopacity $vel + } + } + proc mat_move_canvas {p t a x y} { + variable _ + set mx [expr $x - $_($t:cx)] + set my [expr $y - $_($t:cy)] + foreach xy {x y} { + set mvt [mat_tr $p $t $xy d [expr $$xy - $_($t:c$xy)]] + foreach ab {a b} {set _($t:${xy}$ab) [expr $_($t:${xy}$ab) - $mvt]}} + foreach item [$p.m find withtag item] { + set m [$p.m itemcget $item -matrix] + set m [list [lindex $m 0] [lindex $m 1] [list [expr [lindex [lindex $m 2] 0] + $mx] [expr [lindex [lindex $m 2] 1] + $my]]] + $p.m itemconfigure $item -matrix $m + } + mat_gridlines $p $t + } + + proc mat_move_object {p t a x y} { + variable _ + set mx [expr $x - $_($t:cx)] + set my [expr $y - $_($t:cy)] + foreach item $_($t:cl) { + set m [$p.m itemcget $item -matrix] + set m [list [lindex $m 0] [lindex $m 1] [list [expr [lindex [lindex $m 2] 0] + $mx] [expr [lindex [lindex $m 2] 1] + $my]]] + $p.m itemconfigure $item -matrix $m + } + } + + proc mat_click {m button action p t x y} { + variable _ + set clicked [$p.m find overlapping $x $y $x $y] + set a [$p.m itemcget mode -text] + switch $action { + hover { + foreach item $clicked { + if {[lindex [$p.m itemcget $item -tags] 0] eq "item"} { + mat_note $p $t $item + } + } + + set junk "" + foreach cfg [$p.m itemconfigure $clicked] {set junk "$junk\n$cfg"} + mat_info $p $t $junk + } + first { + set _($t:cl) $clicked + foreach xy {x y} {set _($t:f$xy) [set $xy]} + switch $button { + 1 { + # mat_mode $p $t move_canvas + if {$a eq "draw"} {mat_draw $p $t $action $x $y} else { + if {$clicked ne "" && [lindex [$p.m itemcget [lindex $clicked 0] -tags] 0] eq "item"} { + mat_mode $p $t move_object + } else { + mat_mode $p $t move_canvas + } + } + } + 2 {mat_mode $p $t resize_canvas} + 3 {mat_mode $p $t object_trans} + } + } + motion {eval mat_$a $p $t $action $x $y} + release { + switch $button { + 1 { + if {$a eq "draw"} {mat_draw $p $t $action $x $y} + } + 2 {mat_mode $p $t move_canvas} + 3 {mat_mode $p $t move_canvas} + } + } + } + foreach xy {x y} {set _($t:c$xy) [set $xy]} + } + proc mat_tr {p t d inv v} { variable _