[PD-cvs] extensions/gui/ix mat.wid,1.17,1.18
carmen rocco
ix9 at users.sourceforge.net
Sat Jul 9 23:30:22 CEST 2005
Update of /cvsroot/pure-data/extensions/gui/ix
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22533
Modified Files:
mat.wid
Log Message:
T1/2 - #sour on EFNet
Index: mat.wid
===================================================================
RCS file: /cvsroot/pure-data/extensions/gui/ix/mat.wid,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** mat.wid 9 Jul 2005 17:30:22 -0000 1.17
--- mat.wid 9 Jul 2005 21:30:19 -0000 1.18
***************
*** 1,3 ****
! package require tkpath
namespace eval ::ix {
proc rc {} {return [format "\#%06x" [expr "int(floor(rand() * 16777216))"]]}
--- 1,3 ----
! foreach package {snack tkdnd tkpath} {package require $package}
namespace eval ::ix {
proc rc {} {return [format "\#%06x" [expr "int(floor(rand() * 16777216))"]]}
***************
*** 17,26 ****
return $text
}
- proc mat_note {p t item} {
- variable _
- set id [lindex [$p.m itemcget $item -tags] 1]
- set len [expr {[dict get $_($t) $id xx] - [dict get $_($t) $id x]}]
- set vel [$p.m itemcget $item -fillopacity]
- pd [concat $t.rp _cb note [dict get $_($t) $id y] $vel $len \;]}
proc mat_scroll {p t d axis} {
--- 17,20 ----
***************
*** 52,60 ****
$p.m itemconfigure sel -stroke $_($t:sc)}}}
! proc mat_item_new {p t} {
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} {
--- 46,65 ----
$p.m itemconfigure sel -stroke $_($t:sc)}}}
! proc mat_item_new {p t d} {
variable _
incr _($t:i)
! set tags [list item i$_($t:i) $_($t:i)]
! switch [dict get $d type] {
! note {
! $p.m create path [::tkpath::coords rect 0 0 0 0 -rx 3 -ry 3] -tags $tags -fill [color [dict get $_($t:g) 0 color]] -stroke [color [darken [dict get $_($t:g) 0 color] 0.5]] -fillopacity 0.8
! }
! sound {
! snack:::sound s$_($t:i)
! s$_($t:i) read [dict get $d filename]
! $p.m create waveform 0 0 -tags $tags -sound s$_($t:i)
! }
! }
! mat_item_ua $p $t $_($t:i) abs $d 1
! }
proc mat_item_delete {p t} {
***************
*** 72,78 ****
}
! 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 {
--- 77,83 ----
}
! proc mat_item_pos {p t item r x y xx yy} {
variable _
! foreach v {x xx y yy} {
if {[set $v] ne "-"} {
switch $r {
***************
*** 81,85 ****
mat_redraw $p $t $item}
! proc mat_item_ua {p t item r u} {
variable _
foreach a [dict keys $u] {
--- 86,90 ----
mat_redraw $p $t $item}
! proc mat_item_ua {p t item r u redraw} {
variable _
foreach a [dict keys $u] {
***************
*** 88,92 ****
}
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} {
--- 93,98 ----
}
rel {dict set _($t) $item $a [expr {[dict get $_($t) $item $a] + [dict get $u $a]}]}}}
! if {$redraw == 1} {mat_redraw $p $t $item}
! }
proc mat_draw {p t a x y} {
***************
*** 95,100 ****
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}}}
proc mat_resize_canvas {p t a x y} {
--- 101,106 ----
motion {
if {$x >= $_($t:cx)} {set xa $_($t:fx);set xb $x} else {set xa $x;set xb $_($t:fx)}
! mat_item_pos $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 [dict create type note g 0 x 0 y 0 xx 0 yy 0 v 1]}}}
proc mat_resize_canvas {p t a x y} {
***************
*** 116,140 ****
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]]
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])}]
! $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]}}
!
! proc mat_object_trans {p t a x y} {
variable _
- 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
}
}
--- 122,149 ----
default {}}
foreach id $items {
! set cid [$p.m find withtag i$id]
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]}]
! switch [dict get $_($t) $id type] {
! note {
! 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])}]
! $p.m coords $cid [::tkpath::coords rect $px $py $sx $sy -rx 3 -ry 3]
! $p.m itemconfigure $cid -fillopacity [dict get $_($t) $id v]
! }
! sound {
! $p.m coords $cid $px $py
! }
! }
! }
! }
!
! proc mat_item_v {p t a x y} {
variable _
foreach item $_($t:sel) {
! mat_item_ua $p $t $item rel [dict create v [expr {($x - $_($t:cx)) / 100.0}]] 1
}
}
***************
*** 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)
}
--- 164,168 ----
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_pos $p $t $item rel $mx $my $mx $my}
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)
}
--- 177,181 ----
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] 1}
mat_item_info $p $t $_($t:sel)
}
***************
*** 249,253 ****
2 {mat_mode $p $t resize_canvas}
3 {if {$clicked ne ""} {
! mat_mode $p $t object_trans } else {mat_rmenu $p $t $X $Y}}}}
motion {eval mat_$a $p $t $action $x $y}
release {
--- 258,262 ----
2 {mat_mode $p $t resize_canvas}
3 {if {$clicked ne ""} {
! mat_mode $p $t item_v } else {mat_rmenu $p $t $X $Y}}}}
motion {eval mat_$a $p $t $action $x $y}
release {
***************
*** 330,334 ****
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)
--- 339,343 ----
proc mat_mode {p t m} {
! array set cursor {draw pencil move_canvas fleur move_object dotbox item_v 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)
***************
*** 341,345 ****
variable _
foreach item $_($t:sel) {
! mat_item_ua $p $t $item abs [dict create g $group]
}
}
--- 350,354 ----
variable _
foreach item $_($t:sel) {
! mat_item_ua $p $t $item abs [dict create g $group] 0
}
}
***************
*** 372,375 ****
--- 381,393 ----
}
}
+
+ proc mat_drop {p t dropped x y} {
+ # foreach d $dropped {
+ foreach d [split $dropped "\n"] {
+ set x [mat_tr $p $t x i $x]
+ set y [mat_tr $p $t y i $y]
+ mat_item_new $p $t [dict create type sound g 1 v 1 x $x y $y xx [expr $x + 10] yy [expr $y + 10] filename [regsub -- {^file:[/]+} $d "/"]]
+ }
+ }
proc mat_new {p t w h bg ln xa xb ya yb qx qy} {
***************
*** 389,392 ****
--- 407,412 ----
bind $p.m <Key> "::ix::mat_key $p $t %k 1"
bind $p.m <KeyRelease> "::ix::mat_key $p $t %k 0"
+ # dnd bindtarget $p.m text/uri-list <Drop> "::ix::mat_drop $p $t %D %x %y"
+ dnd bindtarget $p.m text/plain <Drop> "::ix::mat_drop $p $t %D %x %y"
bind $p.m <Motion> "::ix::mat_hover $p $t %x %y"
bind $p.m <4> "::ix::mat_scroll $p $t 1 x"
***************
*** 406,409 ****
--- 426,430 ----
mat_gridlines $p $t}
mat_group_new $p $t default
+ mat_group_new $p $t wavs
}
More information about the Pd-cvs
mailing list