Update of /cvsroot/pure-data/extensions/gui/ix In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10062
Modified Files: mat.wid Log Message: daily check-in, this script doesnt do anything yet so dont bother
Index: mat.wid =================================================================== RCS file: /cvsroot/pure-data/extensions/gui/ix/mat.wid,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** mat.wid 5 Jul 2005 11:02:00 -0000 1.15 --- mat.wid 6 Jul 2005 12:27:06 -0000 1.16 *************** *** 2,6 **** namespace eval ::ix { proc rc {} {return [format "#%06x" [expr "int(floor(rand() * 16777216))"]]} ! proc mat_note {p t item} { variable _ --- 2,20 ---- namespace eval ::ix { proc rc {} {return [format "#%06x" [expr "int(floor(rand() * 16777216))"]]} ! proc rgb {} {return [list [expr "int(floor(rand() * 256))"] [expr "int(floor(rand() * 256))"] [expr "int(floor(rand() * 256))"]]} ! proc lighten {rgb r} {set l {}; foreach c $rgb {lappend l [expr {(256 - $c) * $r + $c}]}; return $l} ! proc darken {rgb r} {set l {}; foreach c $rgb {lappend l [expr {$c - ($c * $r)}]}; return $l} ! proc color {rgb} {return [format "#%02x%02x%02x" [expr int([lindex $rgb 0])] [expr int([lindex $rgb 1])] [expr int([lindex $rgb 2])]]} ! proc random_txt {n} { ! set i 0 ! set text "" ! while {$i < $n} { ! set int [expr "int(floor(rand()*62))"] ! if {$int < 10} {incr int 48} elseif {$int < 36} {incr int 55} else {incr int 61} ! set text "$text[format %c $int]" ! incr i ! } ! return $text ! } proc mat_note {p t item} { variable _ *************** *** 41,45 **** 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 green -fillopacity 0.8] abs 0 0 0 0}
proc mat_quant {p t y v} { --- 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} { *************** *** 57,64 **** if {[set $v] ne "-"} { switch $r { ! abs {dict set _($t) $item $v [mat_quant $p $t $v [set $v]]} ! rel {dict set _($t) $item $v [mat_quant $p $t $v [expr {[dict get $_($t) $item $v] + [set $v]}]]}}}} mat_redraw $p $t [dict get $_($t) $item ci]}
proc mat_draw {p t a x y} { variable _ --- 71,86 ---- 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} { + variable _ + 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} { variable _ *************** *** 90,95 **** 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 [expr {abs([mat_tr $p $t x id [expr {[dict get $_($t) $id xx] - [dict get $_($t) $id x]}]])}] ! set sy [expr {abs([mat_tr $p $t y id 1])}] # puts "$px $py $sx $sy" $p.m coords $item [::tkpath::coords rect $px $py $sx $sy -rx 3 -ry 3]}} --- 112,120 ---- 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 w [expr {[dict get $_($t) $id xx] - [dict get $_($t) $id x]}] ! set h [expr {[dict get $_($t) $id yy] - [dict get $_($t) $id y]}] ! if {$h < 0.01} {set h 1} ! 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]}} *************** *** 122,126 **** 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_info $p $t $_($t:sel) }
--- 147,164 ---- 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) ! } ! ! proc mat_resize_left {p t a x y} {mat_resize_object $p $t x $x $y} ! proc mat_resize_right {p t a x y} {mat_resize_object $p $t xx $x $y} ! proc mat_resize_top {p t a x y} {mat_resize_object $p $t y $x $y} ! proc mat_resize_bottom {p t a x y} {mat_resize_object $p $t yy $x $y} ! ! proc mat_resize_object {p t e x y} { ! variable _ ! 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) }
*************** *** 143,146 **** --- 181,193 ---- 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]] + set eY [mat_tr $p $t y t [dict get $_($t) $id y]] + set eYY [mat_tr $p $t y t [dict get $_($t) $id yy]] + 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 *************** *** 150,154 **** }
! proc mat_info {p t clicked} { variable _ set n 0;$p.m delete hover --- 197,201 ---- }
! proc mat_item_info {p t clicked} { variable _ set n 0;$p.m delete hover *************** *** 165,173 **** foreach item $_($t:sel) { if {[lsearch -integer $clicked $item] < 0} { ! $p.m itemconfigure $item -fill blue}} foreach item $clicked { $p.m itemconfigure $item -fill $_($t:sc) } ! mat_info $p $t $clicked set _($t:sel) $clicked
--- 212,220 ---- 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
*************** *** 211,215 **** $m add command -label "zoom to fit" -command "::ix::mat_zoom $p $t fit" $m add command -label "reset zoom" -command "::ix::mat_zoom $p $t reset" ! $m add command -label "jupas" -command {} -state disabled $m add command -label "frukas" -command {} -state disabled } else { --- 258,262 ---- $m add command -label "zoom to fit" -command "::ix::mat_zoom $p $t fit" $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 { *************** *** 266,270 ****
proc mat_mode {p t m} { ! array set cursor {draw pencil move_canvas fleur move_object dotbox object_trans box_spiral resize_canvas bogosity sel cross_reverse} $p.m itemconfigure mode -text $m $p.m configure -cursor $cursor($m) --- 313,317 ----
proc mat_mode {p t m} { ! array set cursor {draw pencil move_canvas fleur move_object dotbox object_trans box_spiral resize_canvas bogosity sel cross_reverse resize_left left_side resize_right right_side resize_top top_side resize_bottom bottom_side} $p.m itemconfigure mode -text $m $p.m configure -cursor $cursor($m) *************** *** 276,285 **** proc mat_group_new {p t grp} { variable _ dict set _($t:g) $_($t:gi) name $grp ! dict set _($t:g) $_($t:gi) color [rc] ! incr _($t:gi) }
proc mat_new {p t w h bg ln xa xb ya yb qx qy} { variable _ --- 323,350 ---- proc mat_group_new {p t grp} { variable _ + set color [rgb] + if {$grp eq "-"} {set grp [random_txt [expr "int(floor(rand() * 10 + 2))"]]} dict set _($t:g) $_($t:gi) name $grp ! dict set _($t:g) $_($t:gi) color $color ! $p.m create text [list 8.0 [expr 38.0 + 11 * $_($t:gi).0]] -fill [color $color] -justify left -anchor w -font {{bitstream vera sans mono} 10} -tags group -text $grp incr _($t:gi) }
+ proc mat_key {p t k b} { + # puts $k + switch $b { + 1 { + switch $k { + 37 {mat_mode $p $t draw} + } + } + 0 { + switch $k { + 37 {mat_mode $p $t {move_canvas}} + } + } + } + } + proc mat_new {p t w h bg ln xa xb ya yb qx qy} { variable _ *************** *** 290,297 **** 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]} ! mat_group_new $p $t default if {[winfo exists $p.m] != 1} { canvas $p.m -bg $bg -width $w -height $h pack $p.m -side left bind $p.m <Motion> "::ix::mat_hover $p $t %x %y" bind $p.m <4> "::ix::mat_scroll $p $t 1 x" --- 355,364 ---- 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} { canvas $p.m -bg $bg -width $w -height $h pack $p.m -side left + bind $p.m <Key> "::ix::mat_key $p $t %k 1" + bind $p.m <KeyRelease> "::ix::mat_key $p $t %k 0" bind $p.m <Motion> "::ix::mat_hover $p $t %x %y" bind $p.m <4> "::ix::mat_scroll $p $t 1 x" *************** *** 309,313 **** $p.m create text [list [expr {$w / 2.}] 5] -fill red -justify center -anchor n -font {{bitstream vera sans} 14} -tags q -text q $p.m create text "10 $h" -fill red -justify left -anchor sw -font {{bitstream vera sans} 12 bold} -fill purple -tags loc -text "" ! mat_gridlines $p $t}}
proc mat_gridlines {p t} { --- 376,382 ---- $p.m create text [list [expr {$w / 2.}] 5] -fill red -justify center -anchor n -font {{bitstream vera sans} 14} -tags q -text q $p.m create text "10 $h" -fill red -justify left -anchor sw -font {{bitstream vera sans} 12 bold} -fill purple -tags loc -text "" ! mat_gridlines $p $t} ! mat_group_new $p $t default ! }
proc mat_gridlines {p t} {