Update of /cvsroot/pure-data/extensions/gui/ix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22895
Modified Files: mat.wid Log Message: ......................stfoi
Index: mat.wid =================================================================== RCS file: /cvsroot/pure-data/extensions/gui/ix/mat.wid,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** mat.wid 6 Jul 2005 12:27:06 -0000 1.16 --- mat.wid 9 Jul 2005 17:30:22 -0000 1.17 *************** *** 55,59 **** variable _ incr _($t:i) ! mat_item_update $p $t $_($t:i) [$p.m create path [::tkpath::coords rect 0 0 0 0 -rx 3 -ry 3] -tags [list item $_($t:i)] -fill [color [dict get $_($t:g) 0 color]] -stroke [color [darken [dict get $_($t:g) 0 color] 0.5]] -fillopacity 0.8] abs 0 0 0 0}
proc mat_quant {p t y v} { --- 55,65 ---- variable _ incr _($t:i) ! $p.m create path [::tkpath::coords rect 0 0 0 0 -rx 3 -ry 3] -tags [list item i$_($t:i) $_($t:i)] -fill [color [dict get $_($t:g) 0 color]] -stroke [color [darken [dict get $_($t:g) 0 color] 0.5]] -fillopacity 0.8 ! mat_item_update $p $t $_($t:i) abs 0 0 0 0 0} ! ! proc mat_item_delete {p t} { ! variable _ ! foreach item $_($t:sel) {$p.m delete $item} ! }
proc mat_quant {p t y v} { *************** *** 66,77 **** }
! proc mat_item_update {p t item ci r x y xx yy} { variable _ ! foreach v {ci x xx y yy} { if {[set $v] ne "-"} { switch $r { abs {dict set _($t) $item $v [set $v]} rel {dict set _($t) $item $v [expr {[dict get $_($t) $item $v] + [set $v]}]}}}} ! mat_redraw $p $t [dict get $_($t) $item ci]}
proc mat_item_ua {p t item r u} { --- 72,83 ---- }
! proc mat_item_update {p t item r x y xx yy g} { variable _ ! foreach v {x xx y yy g} { if {[set $v] ne "-"} { switch $r { abs {dict set _($t) $item $v [set $v]} rel {dict set _($t) $item $v [expr {[dict get $_($t) $item $v] + [set $v]}]}}}} ! mat_redraw $p $t $item}
proc mat_item_ua {p t item r u} { *************** *** 79,85 **** foreach a [dict keys $u] { switch $r { ! abs {dict set _($t) $item $a [dict get $u $a]} rel {dict set _($t) $item $a [expr {[dict get $_($t) $item $a] + [dict get $u $a]}]}}} ! mat_redraw $p $t [dict get $_($t) $item ci]}
proc mat_draw {p t a x y} { --- 85,92 ---- foreach a [dict keys $u] { switch $r { ! abs {dict set _($t) $item $a [dict get $u $a] ! } rel {dict set _($t) $item $a [expr {[dict get $_($t) $item $a] + [dict get $u $a]}]}}} ! mat_redraw $p $t $item}
proc mat_draw {p t a x y} { *************** *** 88,92 **** motion { if {$x >= $_($t:cx)} {set xa $_($t:fx);set xb $x} else {set xa $x;set xb $_($t:fx)} ! mat_item_update $p $t $_($t:i) - abs [mat_tr $p $t x i $xa] [mat_tr $p $t y i $y] [mat_tr $p $t x i $xb] [mat_tr $p $t y i $y]} first {mat_item_new $p $t}}}
--- 95,99 ---- motion { if {$x >= $_($t:cx)} {set xa $_($t:fx);set xb $x} else {set xa $x;set xb $_($t:fx)} ! mat_item_update $p $t $_($t:i) abs [mat_tr $p $t x i $xa] [mat_tr $p $t y i $y] [mat_tr $p $t x i $xb] [mat_tr $p $t y i $y] 0} first {mat_item_new $p $t}}}
*************** *** 106,113 **** variable _ switch $items { ! all {set items [$p.m find withtag item]} default {}} ! foreach item $items { ! 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]] --- 113,121 ---- variable _ switch $items { ! all {set items [dict keys $_($t)]} default {}} ! foreach id $items { ! set item [$p.m find withtag i$id] ! puts "redrawing $item" 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]] *************** *** 117,121 **** set sx [expr {abs([mat_tr $p $t x id $w])}] set sy [expr {abs([mat_tr $p $t y id $h])}] ! # puts "$px $py $sx $sy" $p.m coords $item [::tkpath::coords rect $px $py $sx $sy -rx 3 -ry 3]}}
--- 125,129 ---- set sx [expr {abs([mat_tr $p $t x id $w])}] set sy [expr {abs([mat_tr $p $t y id $h])}] ! $p.m itemconfigure $item -fill [color [dict get $_($t:g) [dict get $_($t) $id g] color]] $p.m coords $item [::tkpath::coords rect $px $py $sx $sy -rx 3 -ry 3]}}
*************** *** 124,131 **** set velo [expr {($x - $_($t:cx)) / 100.0}] foreach item $_($t:sel) { ! 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 } } --- 132,140 ---- set velo [expr {($x - $_($t:cx)) / 100.0}] foreach item $_($t:sel) { ! set id [$p.m find withtag i$item] ! set vel [expr {$velo + [$p.m itemcget $id -fillopacity]}] if {$vel > 1} {set vel 1} if {$vel < 0} {set vel 0} ! $p.m itemconfigure $id -fillopacity $vel } } *************** *** 146,150 **** set mx [mat_tr $p $t x d [expr {$x - $_($t:cx)}]] set my [mat_tr $p $t y d [expr {$y - $_($t:cy)}]] ! foreach item $_($t:sel) {mat_item_update $p $t [lindex [$p.m itemcget $item -tags] 1] - rel $mx $my $mx $my} mat_item_info $p $t $_($t:sel) } --- 155,159 ---- set mx [mat_tr $p $t x d [expr {$x - $_($t:cx)}]] set my [mat_tr $p $t y d [expr {$y - $_($t:cy)}]] ! foreach item $_($t:sel) {mat_item_update $p $t $item rel $mx $my $mx $my 0} mat_item_info $p $t $_($t:sel) } *************** *** 159,163 **** array set ax {x x xx x y y yy y} set m [mat_tr $p $t $ax($e) d [expr $$ax($e) - $_($t:c$ax($e))]] ! foreach item $_($t:sel) {mat_item_ua $p $t [lindex [$p.m itemcget $item -tags] 1] rel [dict create $e $m]} mat_item_info $p $t $_($t:sel) } --- 168,172 ---- array set ax {x x xx x y y yy y} set m [mat_tr $p $t $ax($e) d [expr $$ax($e) - $_($t:c$ax($e))]] ! foreach item $_($t:sel) {mat_item_ua $p $t $item rel [dict create $e $m]} mat_item_info $p $t $_($t:sel) } *************** *** 165,170 **** proc mat_cleansel {p t sel} { set clean {} ! foreach item $sel {if {[lindex [$p.m itemcget $item -tags] 0] eq "item"} { lappend clean $item}} ! return $clean}
proc mat_hover {p t x y} { --- 174,181 ---- proc mat_cleansel {p t sel} { set clean {} ! foreach item $sel {if {[lindex [$p.m itemcget $item -tags] 0] eq "item"} {lappend clean [lindex [$p.m itemcget $item -tags] 2]}} ! set clean [lsort -integer -unique $clean] ! return $clean ! }
proc mat_hover {p t x y} { *************** *** 173,185 **** if {[$p.m find withtag sel] ne ""} { set _($t:hover) 1 ! set clicked [$p.m find overlapping $_($t:fx) $_($t:fy) $x $y] mat_sel $p $t motion $x $y } else { ! set clicked [$p.m find overlapping $x $y $x $y] } - set clicked [mat_cleansel $p $t $clicked] if {$clicked ne ""} { mat_mode $p $t move_object ! set id [lindex [$p.m itemcget [lindex $clicked 0] -tags] 1] set eX [mat_tr $p $t x t [dict get $_($t) $id x]] set eXX [mat_tr $p $t x t [dict get $_($t) $id xx]] --- 184,195 ---- if {[$p.m find withtag sel] ne ""} { set _($t:hover) 1 ! set clicked [mat_cleansel $p $t [$p.m find overlapping $_($t:fx) $_($t:fy) $x $y]] mat_sel $p $t motion $x $y } else { ! set clicked [mat_cleansel $p $t [$p.m find overlapping $x $y $x $y]] } if {$clicked ne ""} { mat_mode $p $t move_object ! set id [lindex $clicked 0] set eX [mat_tr $p $t x t [dict get $_($t) $id x]] set eXX [mat_tr $p $t x t [dict get $_($t) $id xx]] *************** *** 188,193 **** if {[expr {abs($eX - $x)}] < 5} {mat_mode $p $t resize_left} if {[expr {abs($eXX - $x)}] < 5} {mat_mode $p $t resize_right} ! # if {[expr {abs($eY - $y)}] < 1} {mat_mode $p $t resize_top} ! # if {[expr {abs($eYY - $y)}] < 1} {mat_mode $p $t resize_bottom} if {[$p.m find withtag sel] eq "" && [llength $_($t:sel)] > 1} {return} mat_updatesel $p $t $clicked --- 198,203 ---- if {[expr {abs($eX - $x)}] < 5} {mat_mode $p $t resize_left} if {[expr {abs($eXX - $x)}] < 5} {mat_mode $p $t resize_right} ! if {[expr {abs($eY - $y)}] < 1} {mat_mode $p $t resize_top} ! if {[expr {abs($eYY - $y)}] < 1} {mat_mode $p $t resize_bottom} if {[$p.m find withtag sel] eq "" && [llength $_($t:sel)] > 1} {return} mat_updatesel $p $t $clicked *************** *** 202,206 **** foreach item $clicked { set info "" ! set data [dict get $_($t) [lindex [$p.m itemcget $item -tags] 1]] foreach d $data {lappend info [string range $d 0 7]} $p.m create text [list [expr [winfo width $p.m] - 8.0] [expr [winfo height $p.m] - 8.0 - 11 * $n.0]] -fill $_($t:sc) -justify right -anchor se -font {{bitstream vera sans mono} 10} -tags hover -text $info --- 212,216 ---- foreach item $clicked { set info "" ! set data [dict get $_($t) $item] foreach d $data {lappend info [string range $d 0 7]} $p.m create text [list [expr [winfo width $p.m] - 8.0] [expr [winfo height $p.m] - 8.0 - 11 * $n.0]] -fill $_($t:sc) -justify right -anchor se -font {{bitstream vera sans mono} 10} -tags hover -text $info *************** *** 211,222 **** variable _ foreach item $_($t:sel) { ! if {[lsearch -integer $clicked $item] < 0} { ! $p.m itemconfigure $item -fill [color [dict get $_($t:g) 0 color]]}} foreach item $clicked { ! $p.m itemconfigure $item -fill $_($t:sc) } mat_item_info $p $t $clicked set _($t:sel) $clicked - }
--- 221,231 ---- variable _ foreach item $_($t:sel) { ! if {[lsearch -integer $clicked $item] < 0 && $item >= 0} { ! $p.m itemconfigure [$p.m find withtag i$item] -fill [color [dict get $_($t:g) [dict get $_($t) $item g] color]]}} foreach item $clicked { ! $p.m itemconfigure [$p.m find withtag i$item] -fill $_($t:sc) } mat_item_info $p $t $clicked set _($t:sel) $clicked }
*************** *** 254,257 **** --- 263,267 ----
proc mat_rmenu {p t x y} { + variable _ if {[winfo exists $p.rmenu] != 1} { set m [menu $p.rmenu -tearoff no] *************** *** 259,266 **** $m add command -label "reset zoom" -command "::ix::mat_zoom $p $t reset" $m add command -label "add group" -command "::ix::mat_group_new $p $t -" ! $m add command -label "frukas" -command {} -state disabled } else { ! # $p.rmenu entryconfigure 0 -label $x } tk_popup $p.rmenu $x $y } --- 269,283 ---- $m add command -label "reset zoom" -command "::ix::mat_zoom $p $t reset" $m add command -label "add group" -command "::ix::mat_group_new $p $t -" ! $m add cascade -label "sel to group" -menu [menu $p.rmenu.seltogroup -tearoff no] } else { ! # $p.rmenu entryconfigure 0 -label $x ! } ! $p.rmenu.seltogroup delete 0 end ! foreach group [dict keys $_($t:g)] { ! $p.rmenu.seltogroup add command -label [dict get $_($t:g) $group name] -command "::ix::mat_group_assign $p $t $group" } + + + tk_popup $p.rmenu $x $y } *************** *** 321,324 **** --- 338,348 ---- }
+ proc mat_group_assign {p t group} { + variable _ + foreach item $_($t:sel) { + mat_item_ua $p $t $item abs [dict create g $group] + } + } + proc mat_group_new {p t grp} { variable _ *************** *** 337,340 **** --- 361,366 ---- switch $k { 37 {mat_mode $p $t draw} + 22 {mat_item_delete $p $t} + 107 {mat_item_delete $p $t} } } *************** *** 351,358 **** set _($t) {} set _($t:g) {} ! set i -1;set sel -1;set gi 0;set hover 0 set sc white foreach xy {x y} {foreach ab {a b} {set ${xy}${ab}o [set ${xy}${ab}]}} ! foreach a {i sc gi hover sel ln xa xb ya yb xao xbo yao ybo qx qy} {set _($t:$a) [set $a]}
if {[winfo exists $p.m] != 1} { --- 377,386 ---- set _($t) {} set _($t:g) {} ! set i -1; ! set sel -1; ! set gi 0;set hover 0 set sc white foreach xy {x y} {foreach ab {a b} {set ${xy}${ab}o [set ${xy}${ab}]}} ! foreach a {i sel sc gi hover ln xa xb ya yb xao xbo yao ybo qx qy} {set _($t:$a) [set $a]}
if {[winfo exists $p.m] != 1} {