[PD-cvs] pd/src pd.tk, 1.1.2.2, 1.1.2.3 pd_objects.tk, 1.1.2.2, 1.1.2.3

carmen rocco ix9 at users.sourceforge.net
Thu Aug 4 22:32:40 CEST 2005


Update of /cvsroot/pure-data/pd/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8684

Modified Files:
      Tag: devel_0_39
	pd.tk pd_objects.tk 
Log Message:
switching _ to ""  (thanks matju)

Index: pd.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/pd.tk,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** pd.tk	3 Aug 2005 03:56:51 -0000	1.1.2.2
--- pd.tk	4 Aug 2005 20:32:37 -0000	1.1.2.3
***************
*** 2,6 ****
  
  if {[catch {package require snack}]} {set has_snack 0} {set has_snack 1}
! if {[catch {package require tkdnd}]} {set has_tkdnd 0} {set has_tkdnd 1}
  
  namespace eval ::pd {
--- 2,6 ----
  
  if {[catch {package require snack}]} {set has_snack 0} {set has_snack 1}
! if {[catch {package require tkdnd}]} {set has_dnd 0} {set has_dnd 1}
  
  namespace eval ::pd {
***************
*** 18,54 ****
              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 sel {p t a x y} {
! 	variable _
  	switch $a {
  	    first {
! 		foreach xy {x y}  {set _($t:c$xy) [set $xy];set _($t:f$xy) [set $xy]}
! 		$p create polygon $_($t:cx) $_($t:cy) $_($t:cx) $_($t:cy) \
! 		    -tags sel -fill "" -outline $_($t:sc) -width 12}
  	    release {$p delete sel}
  	    motion {
! 		updatesel $p $t [cleansel $p $t [$p find overlapping $_($t:fx) $_($t:fy) $x $y]]
! 		if {$x >= $_($t:cx)} {set xa $_($t:fx);set xb $x} else {set xa $x;set xb $_($t:fx)}
! 		if {$y >= $_($t:cy)} {set ya $_($t:fy);set yb $y} else {set ya $y;set yb $_($t:fy)}
! 		$p coords sel $xa $ya $xb $ya $xb $yb $xa $yb $xa $ya}}}
  
      proc item_new {p t id d} {
! 	variable _
  	variable obj
  	if {$id eq "-"} {
! 	    if {[dict keys $_($t)] eq ""} {set id 0} else {
  		set id -1
! 		while true {if {[lsearch -integer [dict keys $_($t)] [incr id]] == -1} {break}}
  	    }
  	}
! 	set _($t:ci) $id
  	set type [dict get $d type]
  
! 	set x [tr $p $t x i $_($t:hx)]
! 	set y [tr $p $t y i $_($t:hy)]
  	item_ua $p $t $id abs [dict create x $x xx $x y $y yy $y color {128 128 128} v 1] 0
  
--- 18,50 ----
              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 sel {p t a x y} {
! 	variable ""
  	switch $a {
  	    first {
! 		foreach xy {x y}  {set ($t:c$xy) [set $xy];set ($t:f$xy) [set $xy]}
! 		$p create rect $($t:cx) $($t:cy) $($t:cx) $($t:cy) \
! 		    -tags sel -fill "" -outline $($t:sc) -width 12}
  	    release {$p delete sel}
  	    motion {
! 		updatesel $p $t [cleansel $p $t [$p find overlapping $($t:fx) $($t:fy) $x $y]]
! 		$p coords sel $($t:fx) $($t:fy) $x $y}}}
  
      proc item_new {p t id d} {
! 	variable ""
  	variable obj
  	if {$id eq "-"} {
! 	    if {[dict keys $($t)] eq ""} {set id 0} else {
  		set id -1
! 		while true {if {[lsearch -integer [dict keys $($t)] [incr id]] == -1} {break}}
  	    }
  	}
! 	set ($t:ci) $id
  	set type [dict get $d type]
  
! 	set x [tr $p $t x i $($t:hx)]
! 	set y [tr $p $t y i $($t:hy)]
  	item_ua $p $t $id abs [dict create x $x xx $x y $y yy $y color {128 128 128} v 1] 0
  
***************
*** 62,72 ****
  
      proc item_draw {p t is} {
! 	variable _
  	variable obj
! 	if {$is eq "all"} {set is [dict keys $_($t)]}
  	foreach id $is {
  	    set tags [list item i$id $id]
! 	    set color [color [dict get $_($t:g) $_($t:cg) color]]
! 	    eval [dict get $obj [dict get $_($t) $id type] draw]
  	    redraw $p $t $id
  	}
--- 58,71 ----
  
      proc item_draw {p t is} {
! 	variable ""
  	variable obj
! 	if {$is eq "all"} {set is [dict keys $($t)]}
  	foreach id $is {
+ 	    set type [dict get $($t) $id type]
  	    set tags [list item i$id $id]
! 	    set color [color [dict get $($t:g) $($t:cg) color]]
! 	    foreach local [dict keys [dict get $obj $type defaults]] {
! 		set $local [dict get $obj $type defaults $local]}
! 	    eval [dict get $obj $type draw]
  	    redraw $p $t $id
  	}
***************
*** 74,84 ****
  
      proc item_delete {p t} {
! 	variable _
! 	foreach item $_($t:sel) {
  	    foreach i [$p find withtag i$item] {
  		$p delete $i
  	    }
! 	    dict unset _($t) $item
! 	    set _($t:sel) {}
  	    item_info $p $t ""
  #	    puts "$p $t delete $item"
--- 73,83 ----
  
      proc item_delete {p t} {
! 	variable ""
! 	foreach item $($t:sel) {
  	    foreach i [$p find withtag i$item] {
  		$p delete $i
  	    }
! 	    dict unset ($t) $item
! 	    set ($t:sel) {}
  	    item_info $p $t ""
  #	    puts "$p $t delete $item"
***************
*** 90,100 ****
  
      proc item_ua {p t item r u redraw} {
! 	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]}]}
  	    }
! 	    #puts [concat update $p $t $item $a [dict get $_($t) $item $a]]
  	}
  	if {$redraw == 1} {redraw $p $t $item}
--- 89,99 ----
  
      proc item_ua {p t item r u redraw} {
! 	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]}]}
  	    }
! 	    #puts [concat update $p $t $item $a [dict get $($t) $item $a]]
  	}
  	if {$redraw == 1} {redraw $p $t $item}
***************
*** 102,122 ****
  
      proc pencil {p t a x y} {
! 	variable _
  	switch $a {
  	    motion {
! 		if {$_($t:af) == 1} {
! 		    item_pos $p $t $_($t:ci) abs [tr $p $t y i $y] [tr $p $t x i $x] [tr $p $t y i $_($t:fy)] [tr $p $t x i $x]
  		} else {
! 		    item_pos $p $t $_($t:ci) abs [tr $p $t x i $x] [tr $p $t y i $y] [tr $p $t x i $_($t:fx)] [tr $p $t y i $y]
  		}
  	    }
! 	    first {item_new $p $t - [dict create type rect g $_($t:cg) x 0 y 0 xx 0 yy 0 v 1]}}}
  
      proc resize_canvas {p t a x y} {viewpoint $p $t [dict create action resize x $x y $y]}
  
      proc redraw {p t items} {
! 	variable _
  	variable obj
! 	if {$_($t:af) == 1} {
  	    array set a {x y y x xx yy yy xx}
  	} else {
--- 101,121 ----
  
      proc pencil {p t a x y} {
! 	variable ""
  	switch $a {
  	    motion {
! 		if {$($t:af) == 1} {
! 		    item_pos $p $t $($t:ci) abs [tr $p $t y i $y] [tr $p $t x i $x] [tr $p $t y i $($t:fy)] [tr $p $t x i $x]
  		} else {
! 		    item_pos $p $t $($t:ci) abs [tr $p $t x i $x] [tr $p $t y i $y] [tr $p $t x i $($t:fx)] [tr $p $t y i $y]
  		}
  	    }
! 	    first {item_new $p $t - [dict create type rect g $($t:cg) x 0 y 0 xx 0 yy 0 v 1]}}}
  
      proc resize_canvas {p t a x y} {viewpoint $p $t [dict create action resize x $x y $y]}
  
      proc redraw {p t items} {
! 	variable ""
  	variable obj
! 	if {$($t:af) == 1} {
  	    array set a {x y y x xx yy yy xx}
  	} else {
***************
*** 124,169 ****
  	}
  	switch $items {
! 	    all {set items [dict keys $_($t)]}
  	    default {}}
  	foreach id $items {
! 	    #convert to screen coordinates
! 	    set x [tr $p $t x t [dict get $_($t) $id $a(x)]]
! 	    set y [tr $p $t y t [dict get $_($t) $id $a(y)]]
! 	    set xx [tr $p $t x t [dict get $_($t) $id $a(xx)]]
! 	    set yy [tr $p $t y t [dict get $_($t) $id $a(yy)]]
  
! 	    #some widgets dont like negative/zero widths
! 	    if {$yy == $y} {set yy [expr $y + 10]}
! 	    if {$xx == $x} {set xx [expr $x + 10]}
! 	    if {$xx < $x} {lassign "$x $xx" xx x}
! 	    if {$yy < $y} {lassign "$y $yy" yy y}
  
  	    #some more pregen for convenience
  	    set sx [expr {$xx - $x}]
  	    set sy [expr {$yy - $y}]
! 	    set ro [expr {int( [set s$a(y)] / 2.0 )}]
! 	    if {[lsearch -integer $_($t:sel) $id] >= 0} {
! 		set color $_($t:sc)
  		set selected 1
  	    } else {
! 		set color [color [dict get $_($t) $id color]]
! 		set selected 0
! 	    }
! 	    if {[dict exists $_($t) $id g]} {
! 		set gcolor [color [dict get $_($t:g) [dict get $_($t) $id g] color]]}
  	    set tags [concat item && i$id && $id]
  	    set item [$p find withtag $tags]
! 	    foreach tag [dict get $obj [dict get $_($t) $id type] tags] {
  		set $tag [$p find withtag "$tags && $tag"]}
! 	    eval [dict get $obj [dict get $_($t) $id type] redraw]
  	}
      }
  
      proc item_v {p t a x y} {
! 	variable _
! 	foreach item $_($t:sel) {
! 	    item_ua $p $t $item rel [dict create v [expr {($x - $_($t:cx)) / 100.0}]] 1
  	}
! 	item_info $p $t $_($t:sel)
      }
  
--- 123,169 ----
  	}
  	switch $items {
! 	    all {set items [dict keys $($t)]}
  	    default {}}
  	foreach id $items {
! 	    set type [dict get $($t) $id type]
  
! 	    #convert to screen coordinates
! 	    set x [tr $p $t x t [dict get $($t) $id $a(x)]]
! 	    set y [tr $p $t y t [dict get $($t) $id $a(y)]]
! 	    set xx [tr $p $t x t [dict get $($t) $id $a(xx)]]
! 	    set yy [tr $p $t y t [dict get $($t) $id $a(yy)]]
  
  	    #some more pregen for convenience
  	    set sx [expr {$xx - $x}]
  	    set sy [expr {$yy - $y}]
! 	    foreach local [dict keys [dict get $obj $type defaults]] {
! 		set $local [dict get $obj $type defaults $local]}
! 	    if {[lsearch -integer $($t:sel) $id] >= 0} {
! 		set color $($t:sc)
  		set selected 1
  	    } else {
! 		set color [color [dict get $($t) $id color]]
! 		set selected 0}
! 	    if {[dict exists $($t) $id g]} {
! 		set gcolor [color [dict get $($t:g) [dict get $($t) $id g] color]]}
  	    set tags [concat item && i$id && $id]
  	    set item [$p find withtag $tags]
! 	    foreach tag [dict get $obj $type tags] {
  		set $tag [$p find withtag "$tags && $tag"]}
! 	    eval [dict get $obj $type redraw]
! 	    redraw_io $p $t $id
  	}
      }
  
+     proc redraw_io {p d id} {
+ 	
+     }
+ 
      proc item_v {p t a x y} {
! 	variable ""
! 	foreach item $($t:sel) {
! 	    item_ua $p $t $item rel [dict create v [expr {($x - $($t:cx)) / 100.0}]] 1
  	}
! 	item_info $p $t $($t:sel)
      }
  
***************
*** 171,183 ****
  
      proc move_object {p t a x y} {
! 	variable _
! 	set mx [tr $p $t x d [expr {$x - $_($t:cx)}]]
! 	set my [tr $p $t y d [expr {$y - $_($t:cy)}]]
! 	if {$_($t:af) == 1} {
! 	    foreach item $_($t:sel) {item_pos $p $t $item rel $my $mx $my $mx}
  	} else {
! 	    foreach item $_($t:sel) {item_pos $p $t $item rel $mx $my $mx $my}
  	}
! 	item_info $p $t $_($t:sel)
      }
  
--- 171,183 ----
  
      proc move_object {p t a x y} {
! 	variable ""
! 	set mx [tr $p $t x d [expr {$x - $($t:cx)}]]
! 	set my [tr $p $t y d [expr {$y - $($t:cy)}]]
! 	if {$($t:af) == 1} {
! 	    foreach item $($t:sel) {item_pos $p $t $item rel $my $mx $my $mx}
  	} else {
! 	    foreach item $($t:sel) {item_pos $p $t $item rel $mx $my $mx $my}
  	}
! 	item_info $p $t $($t:sel)
      }
  
***************
*** 192,204 ****
  
      proc resize_object {p t e x y} {
! 	variable _
! 	if {$_($t:af) == 1} {
  	    array set ax {x y xx y y x yy x}
  	} else {
  	    array set ax {x x xx x y y yy y}
  	}
! 	set m [tr $p $t $ax($e) d [expr $$ax($e) - $_($t:c$ax($e))]]
! 	foreach item $_($t:sel) {item_ua $p $t $item rel [dict create $e $m] 1}
! 	item_info $p $t $_($t:sel)
      }
  
--- 192,204 ----
  
      proc resize_object {p t e x y} {
! 	variable ""
! 	if {$($t:af) == 1} {
  	    array set ax {x y xx y y x yy x}
  	} else {
  	    array set ax {x x xx x y y yy y}
  	}
! 	set m [tr $p $t $ax($e) d [expr $$ax($e) - $($t:c$ax($e))]]
! 	foreach item $($t:sel) {item_ua $p $t $item rel [dict create $e $m] 1}
! 	item_info $p $t $($t:sel)
      }
  
***************
*** 211,216 ****
  
      proc hover {p t x y} {
! 	variable _
! 	foreach xy {x y}  {set _($t:h$xy) [set $xy]}
  	if {[$p find withtag sel] ne ""} {
  	    sel $p $t motion $x $y
--- 211,216 ----
  
      proc hover {p t x y} {
! 	variable ""
! 	foreach xy {x y}  {set ($t:h$xy) [set $xy]}
  	if {[$p find withtag sel] ne ""} {
  	    sel $p $t motion $x $y
***************
*** 219,223 ****
  	    if {$clicked ne ""} {
  		resize_modes $p $t $x $y [lindex $clicked end]
! 		if {[llength $_($t:sel)] <= 1} {updatesel $p $t [lindex $clicked end]}
  	    } else {
  		mode $p $t move_canvas
--- 219,223 ----
  	    if {$clicked ne ""} {
  		resize_modes $p $t $x $y [lindex $clicked end]
! 		if {[llength $($t:sel)] <= 1} {updatesel $p $t [lindex $clicked end]}
  	    } else {
  		mode $p $t move_canvas
***************
*** 227,235 ****
      
      proc resize_modes {p t x y id} {
! 	variable _
  	set d 3
  	set bbox [$p bbox [$p find withtag "i$id && box"]]
  	if {$bbox eq ""} {set bbox {0 0 0 0}}
- 	puts "$x $y rbx $bbox"
  	lassign $bbox bx by bxx byy
  	set dx [expr {abs($bx - $x)}]
--- 227,234 ----
      
      proc resize_modes {p t x y id} {
! 	variable ""
  	set d 3
  	set bbox [$p bbox [$p find withtag "i$id && box"]]
  	if {$bbox eq ""} {set bbox {0 0 0 0}}
  	lassign $bbox bx by bxx byy
  	set dx [expr {abs($bx - $x)}]
***************
*** 259,278 ****
  
      proc item_info {p t clicked} {
! 	variable _
  	set n 0;$p delete hover
  	foreach item $clicked {
  	    set info ""
! 	    set data  [dict get $_($t) $item] 
  	    foreach d $data {lappend info [string range $d 0 7]}
! 	    $p create text [list [expr [winfo width $p] - 8.0] [expr [winfo height $p] - 8.0 - 11 * $n.0]] -fill $_($t:sc) -justify right -anchor se -font {{bitstream vera sans mono} 10} -tags hover -text $info
  	    incr n		
! 	}}
  
      proc togglesel {p t d} {
! 	variable _
! 	if {[lsearch -integer $_($t:sel) $d] < 0} {
! 	    set _($t:sel) [concat $_($t:sel) $d]
  	} else {
! 	    set _($t:sel) [lsearch -inline -not -all -integer $_($t:sel) $d]
  	}
  	redraw $p $t $d
--- 258,279 ----
  
      proc item_info {p t clicked} {
! 	variable ""
! 	return
  	set n 0;$p delete hover
  	foreach item $clicked {
  	    set info ""
! 	    set data  [dict get $($t) $item] 
  	    foreach d $data {lappend info [string range $d 0 7]}
! 	    $p create text [list [expr [winfo width $p] - 8.0] [expr [winfo height $p] - 8.0 - 11 * $n.0]] -fill $($t:sc) -justify right -anchor se -font {{bitstream vera sans mono} 10} -tags hover -text $info
  	    incr n		
! 	}
!     }
  
      proc togglesel {p t d} {
! 	variable ""
! 	if {[lsearch -integer $($t:sel) $d] < 0} {
! 	    set ($t:sel) [concat $($t:sel) $d]
  	} else {
! 	    set ($t:sel) [lsearch -inline -not -all -integer $($t:sel) $d]
  	}
  	redraw $p $t $d
***************
*** 280,286 ****
  
      proc updatesel {p t ns} {
! 	variable _
! 	set os $_($t:sel)
! 	set _($t:sel) $ns
  	redraw $p $t  [lsort -unique -integer [concat $os $ns]]
  	item_info $p $t $ns
--- 281,287 ----
  
      proc updatesel {p t ns} {
! 	variable ""
! 	set os $($t:sel)
! 	set ($t:sel) $ns
  	redraw $p $t  [lsort -unique -integer [concat $os $ns]]
  	item_info $p $t $ns
***************
*** 288,297 ****
  
      proc click {m button action p t x y X Y} {
! 	variable _
  	set clicked [cleansel $p $t [$p find overlapping $x $y $x $y]]
  	set a [$p itemcget mode -text]
  	switch $action {
  	    first {
! 		foreach xy {x y}  {set _($t:f$xy) [set $xy]}
  		switch $button {
  		    1 {if {$m eq "control"} {
--- 289,298 ----
  
      proc click {m button action p t x y X Y} {
! 	variable ""
  	set clicked [cleansel $p $t [$p find overlapping $x $y $x $y]]
  	set a [$p itemcget mode -text]
  	switch $action {
  	    first {
! 		foreach xy {x y}  {set ($t:f$xy) [set $xy]}
  		switch $button {
  		    1 {if {$m eq "control"} {
***************
*** 306,310 ****
  		    } elseif {[$p find withtag sel] ne ""} {
  			sel $p $t release $x $y
! 		    } elseif {[llength $_($t:sel)] > 1 && [llength $clicked] > 0 && [lsearch $_($t:sel) $clicked] == -1} {
  			updatesel $p $t $clicked}}
  		    2 {mode $p $t resize_canvas}
--- 307,311 ----
  		    } elseif {[$p find withtag sel] ne ""} {
  			sel $p $t release $x $y
! 		    } elseif {[llength $($t:sel)] > 1 && [llength $clicked] > 0 && [lsearch $($t:sel) $clicked] == -1} {
  			updatesel $p $t $clicked}}
  		    2 {mode $p $t resize_canvas}
***************
*** 314,318 ****
  	    release {
  		switch $button {
! 		    1 {if {$a eq "draw" || ($a eq "sel" && [expr {abs($_($t:fx) - $x)}] >13)} {eval $a $p $t $action $x $y}}
  		    2 {mode $p $t move_canvas}
  		    3 {mode $p $t move_canvas}
--- 315,319 ----
  	    release {
  		switch $button {
! 		    1 {if {$a eq "draw" || ($a eq "sel" && [expr {abs($($t:fx) - $x)}] >13)} {eval $a $p $t $action $x $y}}
  		    2 {mode $p $t move_canvas}
  		    3 {mode $p $t move_canvas}
***************
*** 320,328 ****
  	    }
  	}
! 	foreach xy {x y}  {set _($t:c$xy) [set $xy]}
      }
      
      proc rmenu {p t x y} {
! 	variable _
  	variable obj
          destroy $p.rmenu
--- 321,329 ----
  	    }
  	}
! 	foreach xy {x y}  {set ($t:c$xy) [set $xy]}
      }
      
      proc rmenu {p t x y} {
! 	variable ""
  	variable obj
          destroy $p.rmenu
***************
*** 339,343 ****
  	    $mg add command -label "add" -command "::pd::group_new $p $t -"
  	    $mg add cascade -label "sel" -menu [set mgs [menu $mg.selto -tearoff yes]]
! 	    foreach group [dict keys $_($t:g)] {$mgs add command -label [dict get $_($t:g) $group name] -command "::pd::group_assign $p $t $group"}
  
  	    $m add cascade -label "object" -menu [set mo [menu $m.object -tearoff no]]
--- 340,344 ----
  	    $mg add command -label "add" -command "::pd::group_new $p $t -"
  	    $mg add cascade -label "sel" -menu [set mgs [menu $mg.selto -tearoff yes]]
! 	    foreach group [dict keys $($t:g)] {$mgs add command -label [dict get $($t:g) $group name] -command "::pd::group_assign $p $t $group"}
  
  	    $m add cascade -label "object" -menu [set mo [menu $m.object -tearoff no]]
***************
*** 361,378 ****
      }
  
!     proc tr {p t d inv v} {	variable _
  	array set dm {x width y height}
  	switch $inv {
! 	    t {return [expr {($v - $_($t:${d}a)) / ($_($t:${d}b) - $_($t:${d}a) + 0.0) * [winfo $dm($d) $p]}]}
! 	    i {return [expr {($_($t:${d}b) - $_($t:${d}a)) * $v /([winfo $dm($d) $p] + 0.0) + $_($t:${d}a)}]}
! 	    d {return [expr {($_($t:${d}b) - $_($t:${d}a)) * $v /([winfo $dm($d) $p] + 0.0)}]}
! 	    id {return [expr {$v / ($_($t:${d}b) - $_($t:${d}a) + 0.0) * [winfo $dm($d) $p]}]}}}
  
      proc viewpoint {p t opts} {
! 	variable _
  	switch [dict get $opts action] {
  	    fit {
  		set i 0
! 		dict for {s xy} $_($t) {
  		    dict with xy {
  			if {$i == 0} {
--- 362,380 ----
      }
  
!     proc tr {p t d inv v} {
! 	variable ""
  	array set dm {x width y height}
  	switch $inv {
! 	    t {return [expr {($v - $($t:${d}a)) / ($($t:${d}b) - $($t:${d}a) + 0.0) * [winfo $dm($d) $p]}]}
! 	    i {return [expr {($($t:${d}b) - $($t:${d}a)) * $v /([winfo $dm($d) $p] + 0.0) + $($t:${d}a)}]}
! 	    d {return [expr {($($t:${d}b) - $($t:${d}a)) * $v /([winfo $dm($d) $p] + 0.0)}]}
! 	    id {return [expr {$v / ($($t:${d}b) - $($t:${d}a) + 0.0) * [winfo $dm($d) $p]}]}}}
  
      proc viewpoint {p t opts} {
! 	variable ""
  	switch [dict get $opts action] {
  	    fit {
  		set i 0
! 		dict for {s xy} $($t) {
  		    dict with xy {
  			if {$i == 0} {
***************
*** 393,428 ****
  		    }
  		}
! 		set _($t:xa) $xa
! 		set _($t:xb) $xb
! 		set _($t:ya) $ya
! 		set _($t:yb) $yb
  	    }
  	    reset {
! 		set _($t:ya) $_($t:yao);set _($t:yb) $_($t:ybo);set _($t:xa) $_($t:xao);set _($t:xb) $_($t:xbo)
  	    }
  	    move {
  		foreach xy {x y} {
! 		    set mvt [tr $p $t $xy d [expr {[dict get $opts $xy] - $_($t:c$xy)}]]
! 		    foreach ab {a b} {set _($t:${xy}$ab) [expr {$_($t:${xy}$ab) - $mvt}]}}
  	    }
  	    zoom {
  		array set dir {in 0.5 out 1.5}
  		foreach xy [dict get $opts axe] {
! 		    set radius  [expr {($_($t:${xy}b) - $_($t:${xy}a)) / 2. * $dir([dict get $opts dir])}]
  		    set center [tr $p $t $xy i [dict get $opts $xy]]
! 		    set _($t:${xy}a) [expr {$center - $radius}]
! 		    set _($t:${xy}b) [expr {$center + $radius}]
  		}
  	    }
  	    resize {
  		foreach xy {x y} {
! 		    set mvt [tr $p $t $xy d [expr {[dict get $opts $xy] - $_($t:c$xy)}]]
! 		    set _($t:${xy}a) [expr {$_($t:${xy}a) - $mvt}]
! 		    set _($t:${xy}b) [expr {$_($t:${xy}b) + $mvt}]}
  	    }
  	    scroll {
  		set xy [dict get $opts axis]
! 		set mv [expr {($_($t:${xy}b) - $_($t:${xy}a)) / 4.0}]
! 		foreach ab {a b} {set _($t:${xy}$ab) [expr {[dict get $opts units] > 0 ? $_($t:${xy}$ab) + $mv : $_($t:${xy}$ab) - $mv }]}
  	    }
  	}
--- 395,430 ----
  		    }
  		}
! 		set ($t:xa) $xa
! 		set ($t:xb) $xb
! 		set ($t:ya) $ya
! 		set ($t:yb) $yb
  	    }
  	    reset {
! 		set ($t:ya) $($t:yao);set ($t:yb) $($t:ybo);set ($t:xa) $($t:xao);set ($t:xb) $($t:xbo)
  	    }
  	    move {
  		foreach xy {x y} {
! 		    set mvt [tr $p $t $xy d [expr {[dict get $opts $xy] - $($t:c$xy)}]]
! 		    foreach ab {a b} {set ($t:${xy}$ab) [expr {$($t:${xy}$ab) - $mvt}]}}
  	    }
  	    zoom {
  		array set dir {in 0.5 out 1.5}
  		foreach xy [dict get $opts axe] {
! 		    set radius  [expr {($($t:${xy}b) - $($t:${xy}a)) / 2. * $dir([dict get $opts dir])}]
  		    set center [tr $p $t $xy i [dict get $opts $xy]]
! 		    set ($t:${xy}a) [expr {$center - $radius}]
! 		    set ($t:${xy}b) [expr {$center + $radius}]
  		}
  	    }
  	    resize {
  		foreach xy {x y} {
! 		    set mvt [tr $p $t $xy d [expr {[dict get $opts $xy] - $($t:c$xy)}]]
! 		    set ($t:${xy}a) [expr {$($t:${xy}a) - $mvt}]
! 		    set ($t:${xy}b) [expr {$($t:${xy}b) + $mvt}]}
  	    }
  	    scroll {
  		set xy [dict get $opts axis]
! 		set mv [expr {($($t:${xy}b) - $($t:${xy}a)) / 4.0}]
! 		foreach ab {a b} {set ($t:${xy}$ab) [expr {[dict get $opts units] > 0 ? $($t:${xy}$ab) + $mv : $($t:${xy}$ab) - $mv }]}
  	    }
  	}
***************
*** 432,438 ****
  
      proc flipaxe {p t} {
! 	variable _
! 	set _($t:af) [expr $_($t:af) == 1 ? 0 : 1]
! 	lassign "$_($t:xa) $_($t:ya) $_($t:xb) $_($t:yb) $_($t:qx) $_($t:qy) $_($t:mx) $_($t:my)" _($t:ya) _($t:xa) _($t:yb) _($t:xb) _($t:qy) _($t:qx) _($t:my) _($t:mx
  		gridlines $p $t
  	redraw $p $t all
--- 434,440 ----
  
      proc flipaxe {p t} {
! 	variable ""
! 	set ($t:af) [expr $($t:af) == 1 ? 0 : 1]
! 	lassign "$($t:xa) $($t:ya) $($t:xb) $($t:yb) $($t:qx) $($t:qy) $($t:mx) $($t:my)" ($t:ya) ($t:xa) ($t:yb) ($t:xb) ($t:qy) ($t:qx) ($t:my) ($t:mx
  		gridlines $p $t
  	redraw $p $t all
***************
*** 440,453 ****
  
      proc clip {p t action} {
! 	variable _
  	switch $action {
  	    selecta {
! 		updatesel $p $t [dict keys $_($t)]
  	    }
  	    cut {
! 		set _($t:c) [dict create]
  		set i 0
! 		foreach item $_($t:sel) {
! 		    dict set _($t:c) $i [dict get $_($t) $item]
  		    incr i
  		}
--- 442,455 ----
  
      proc clip {p t action} {
! 	variable ""
  	switch $action {
  	    selecta {
! 		updatesel $p $t [dict keys $($t)]
  	    }
  	    cut {
! 		set ($t:c) [dict create]
  		set i 0
! 		foreach item $($t:sel) {
! 		    dict set ($t:c) $i [dict get $($t) $item]
  		    incr i
  		}
***************
*** 455,462 ****
  	    }
  	    copy {
! 		set _($t:c) [dict create]
  		set i 0
! 		foreach item $_($t:sel) {
! 		    dict set _($t:c) $i [dict get $_($t) $item]
  		    incr i
  		}
--- 457,464 ----
  	    }
  	    copy {
! 		set ($t:c) [dict create]
  		set i 0
! 		foreach item $($t:sel) {
! 		    dict set ($t:c) $i [dict get $($t) $item]
  		    incr i
  		}
***************
*** 464,469 ****
  	    paste {
  		set pasted {}
! 		foreach item [dict keys $_($t:c)] {
! 		    item_new $p $t - [dict get $_($t:c) $item]
  		}
  	    }
--- 466,471 ----
  	    paste {
  		set pasted {}
! 		foreach item [dict keys $($t:c)] {
! 		    item_new $p $t - [dict get $($t:c) $item]
  		}
  	    }
***************
*** 478,491 ****
  
     proc group_new {p t grp} {
!         variable _
          set exists 0
!         dict for {key val} $_($t:g) {if {[dict get $val name] eq $grp} {set exists 1}}
          if {$exists == 0} {
              if {$grp eq "-"} {set grp [random_txt [expr "int(floor(rand() * 10 + 2))"]]}
              set n -1
!             while true { if {[lsearch -integer [dict keys $_($t:g)] [incr n]] == -1} {break}}
!             dict set _($t:g) $n name $grp
!             dict set _($t:g) $n color [rgb]
!             set _($t:cg) $n
          }
      }
--- 480,493 ----
  
     proc group_new {p t grp} {
!         variable ""
          set exists 0
!         dict for {key val} $($t:g) {if {[dict get $val name] eq $grp} {set exists 1}}
          if {$exists == 0} {
              if {$grp eq "-"} {set grp [random_txt [expr "int(floor(rand() * 10 + 2))"]]}
              set n -1
!             while true { if {[lsearch -integer [dict keys $($t:g)] [incr n]] == -1} {break}}
!             dict set ($t:g) $n name $grp
!             dict set ($t:g) $n color [rgb]
!             set ($t:cg) $n
          }
      }
***************
*** 493,498 ****
  
      proc group_assign {p t group} {
! 	variable _
! 	foreach item $_($t:sel) {
  	    item_ua $p $t $item abs [dict create g $group] 1
  	}
--- 495,500 ----
  
      proc group_assign {p t group} {
! 	variable ""
! 	foreach item $($t:sel) {
  	    item_ua $p $t $item abs [dict create g $group] 1
  	}
***************
*** 500,517 ****
  
      proc mode_flip {p t} {
! 	variable _
! 	if {$_($t:mode) eq "edit"} {
  	    array set m {bg white ln gray86 mode forward}
  	} else {
  	   array set m {bg gray86 ln white mode edit}
  	}
! 	set _($t:mode) $m(mode)
  	$p configure -bg $m(bg)
! 	set _($t:ln) $m(ln)
  	gridlines $p $t
      }
  
      proc key {p t k b} {
! 	puts $k
  	switch $b {
  	    1 {
--- 502,519 ----
  
      proc mode_flip {p t} {
! 	variable ""
! 	if {$($t:mode) eq "edit"} {
  	    array set m {bg white ln gray86 mode forward}
  	} else {
  	   array set m {bg gray86 ln white mode edit}
  	}
! 	set ($t:mode) $m(mode)
  	$p configure -bg $m(bg)
! 	set ($t:ln) $m(ln)
  	gridlines $p $t
      }
  
      proc key {p t k b} {
! #	puts $k
  	switch $b {
  	    1 {
***************
*** 543,549 ****
  
      proc new {p t opts} {
! 	variable _
! 	foreach xy {x y} {foreach ab {a b} {set _($t:${xy}${ab}o) [dict get $opts ${xy}${ab}]}}
! 	foreach a {sc ln mode xa xb ya yb qx qy mx my samplerate} {set _($t:$a) [dict get $opts $a]}
  	if {[winfo exists $p] != 1} {
  	    canvas $p -bg [dict get $opts bg]
--- 545,552 ----
  
      proc new {p t opts} {
! 	variable ""
! 	variable obj
! 	foreach xy {x y} {foreach ab {a b} {set ($t:${xy}${ab}o) [dict get $opts ${xy}${ab}]}}
! 	foreach a {sc ln mode xa xb ya yb qx qy mx my samplerate} {set ($t:$a) [dict get $opts $a]}
  	if {[winfo exists $p] != 1} {
  	    canvas $p -bg [dict get $opts bg]
***************
*** 553,557 ****
  	    bind $p <Key> "::pd::key $p $t %k 1"
  	    bind $p <KeyRelease> "::pd::key $p $t %k 0"
! 	    dnd bindtarget $p text/plain <Drop> "::pd::drop $p $t %D %x %y"
  	    bind $p <Motion> "::pd::hover $p $t %x %y"
  	    bind $p <4> "::pd::viewpoint $p $t {action scroll units 1 axis x}"
--- 556,564 ----
  	    bind $p <Key> "::pd::key $p $t %k 1"
  	    bind $p <KeyRelease> "::pd::key $p $t %k 0"
! 	    if {$::has_dnd == 1} {
! 		dnd bindtarget $p text/plain <Drop> "::pd::drop $p $t %D %x %y"
! 	    } else {
! 		dict unset obj sound
! 	    }
  	    bind $p <Motion> "::pd::hover $p $t %x %y"
  	    bind $p <4> "::pd::viewpoint $p $t {action scroll units 1 axis x}"
***************
*** 573,581 ****
  	    $p configure -bg gray -width [expr {[winfo width $p] + $bd}] -height [expr {[winfo height $p] + $bd}]
  	    $p create text {20 20} -fill blue -justify left -anchor w -font {{bitstream vera sans} 18} -tags mode -text move_canvas
! 	    if {[info exists _($t)] != 1} {
! 		set _($t) {}
! 		set _($t:g) {}
  		set af 0; set i -1; set sel {}
! 		foreach a {af i sel} {set _($t:$a) [set $a]}
  		group_new $p $t default
  	    }
--- 580,588 ----
  	    $p configure -bg gray -width [expr {[winfo width $p] + $bd}] -height [expr {[winfo height $p] + $bd}]
  	    $p create text {20 20} -fill blue -justify left -anchor w -font {{bitstream vera sans} 18} -tags mode -text move_canvas
! 	    if {[info exists ($t)] != 1} {
! 		set ($t) {}
! 		set ($t:g) {}
  		set af 0; set i -1; set sel {}
! 		foreach a {af i sel} {set ($t:$a) [set $a]}
  		group_new $p $t default
  	    }
***************
*** 586,590 ****
  
      proc gridlines {p t} {
! 	variable _
  	foreach item [$p find withtag gridline] {$p delete $item}
  	foreach xy {x y} {
--- 593,597 ----
  
      proc gridlines {p t} {
! 	variable ""
  	foreach item [$p find withtag gridline] {$p delete $item}
  	foreach xy {x y} {
***************
*** 592,602 ****
  	    array set tj {x center y left}
  	    array set igx {y width x height}
! 	    set range [expr {abs($_($t:${xy}b) - $_($t:${xy}a))}]
! 	    set nSlices [expr {$range / $_($t:q$xy)}]
! 	    if {$nSlices > $_($t:m${xy})} {set factor [expr {int($nSlices / ($_($t:m${xy}) + 0.0) + 1)}]} else {
! 		set factor [expr {1. / (int(1./($nSlices / ($_($t:m${xy}) + 0.0) + 0.0)) + 0.0)}]
  	    }
! 	    set increment [expr {$_($t:q${xy}) * $factor}]
! 	    for {set x [expr {int($_($t:${xy}a) / ($increment + 0.0) + 1)*($increment + 0.0)}]} {[expr {$_($t:${xy}a) > $_($t:${xy}b) ? $x >=  $_($t:${xy}b) : $x <=  $_($t:${xy}b)}]} {set x [expr {$_($t:${xy}a) > $_($t:${xy}b) ? $x - $increment : $x + $increment}]} {
  		set og [tr $p $t $xy t $x]
  		set invgeo [winfo $igx($xy) $p]
--- 599,609 ----
  	    array set tj {x center y left}
  	    array set igx {y width x height}
! 	    set range [expr {abs($($t:${xy}b) - $($t:${xy}a))}]
! 	    set nSlices [expr {$range / $($t:q$xy)}]
! 	    if {$nSlices > $($t:m${xy})} {set factor [expr {int($nSlices / ($($t:m${xy}) + 0.0) + 1)}]} else {
! 		set factor [expr {1. / (int(1./($nSlices / ($($t:m${xy}) + 0.0) + 0.0)) + 0.0)}]
  	    }
! 	    set increment [expr {$($t:q${xy}) * $factor}]
! 	    for {set x [expr {int($($t:${xy}a) / ($increment + 0.0) + 1)*($increment + 0.0)}]} {[expr {$($t:${xy}a) > $($t:${xy}b) ? $x >=  $($t:${xy}b) : $x <=  $($t:${xy}b)}]} {set x [expr {$($t:${xy}a) > $($t:${xy}b) ? $x - $increment : $x + $increment}]} {
  		set og [tr $p $t $xy t $x]
  		set invgeo [winfo $igx($xy) $p]
***************
*** 605,609 ****
  		    x {set coords [concat $og 0 $og $invgeo]}}
  		$p lower [$p create text [lrange $coords 0 1] -font {{Bitstream Vera Sans} 8} -fill [rc] -anchor $ta($xy) -text [string range $x 0 7] -justify $tj($xy) -tags gridline]
! 		$p lower [$p create line $coords -fill $_($t:ln) -stipple gray50 -tags gridline]
  	    }}}
  
--- 612,616 ----
  		    x {set coords [concat $og 0 $og $invgeo]}}
  		$p lower [$p create text [lrange $coords 0 1] -font {{Bitstream Vera Sans} 8} -fill [rc] -anchor $ta($xy) -text [string range $x 0 7] -justify $tj($xy) -tags gridline]
! 		$p lower [$p create line $coords -fill $($t:ln) -stipple gray50 -tags gridline]
  	    }}}
  

Index: pd_objects.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/pd_objects.tk,v
retrieving revision 1.1.2.2
retrieving revision 1.1.2.3
diff -C2 -d -r1.1.2.2 -r1.1.2.3
*** pd_objects.tk	3 Aug 2005 03:56:51 -0000	1.1.2.2
--- pd_objects.tk	4 Aug 2005 20:32:37 -0000	1.1.2.3
***************
*** 9,12 ****
--- 9,16 ----
  	    ins 0
  	    outs 0
+ 	    zero_x 0
+ 	    zero_y 1
+ 	    zs_x 0.5
+ 	    zs_y 0.5
  	}
  	draw {
***************
*** 14,18 ****
--- 18,25 ----
  	}
  	redraw {
+ 	    if {$zero_x} {set zs_x [tr $p $t x id $zs_x]; set xx [expr $x + $zs_x]; set x [expr $x - $zs_x]}
+ 	    if {$zero_y} {set zs_y [tr $p $t y id $zs_y]; set yy [expr $y + $zs_y]; set y [expr $y - $zs_y]}
  	    $p coords $box $x $y $xx $yy
+ 
  	    $p itemconfigure $box -fill $gcolor -outline $color -width [expr $selected + 1]
  	}
***************
*** 116,121 ****
  	    set orient [expr ($xx - $x) > ($yy - $y) ? "h" : "v"]
  	    switch $orient {
! 		v {set coords [concat $x [expr $y + ($yy - $y) * [dict get $_($t) $id v]] [expr $xx - $x] 3]}
! 		h {set coords [concat [expr $x + ($xx - $x) * [dict get $_($t) $id v]] $y 3 [expr $yy - $y]]}}
  	    $p coords $pos $coords
  	}
--- 123,128 ----
  	    set orient [expr ($xx - $x) > ($yy - $y) ? "h" : "v"]
  	    switch $orient {
! 		v {set coords [concat $x [expr $y + ($yy - $y) * [dict get $($t) $id v]] [expr $xx - $x] 3]}
! 		h {set coords [concat [expr $x + ($xx - $x) * [dict get $($t) $id v]] $y 3 [expr $yy - $y]]}}
  	    $p coords $pos $coords
  	}
***************
*** 132,141 ****
  	draw {
  	    snack:::sound s$id
! 	    set filename [dict get $_($t) $id filename]
  	    s$id read $filename
  	    $p create path [::tkpath::coords rect 0 0 0 0 -rx 3 -ry 3] -tags [concat $tags r] -strokewidth 0 -fill $color -fillopacity 0.08
  	    $p create waveform 0 0 -tags [concat $tags w] -sound s$id -fill white
! 	    set length [expr [s$id length] / ($_($t:samplerate) + 0.0) * 1000]
! 	    mat_item_ua $p $t $id abs [dict create xx [expr [dict get $_($t) $id x] + $length]] 0
  	    $p create text 0 0 -tags [concat $tags tl] -font {{bitstream vera sans} 8} -fill HotPink -anchor nw -justify left -text "[string range $length 0 10] s"
  	    $p create rectangle 0 0 0 0 -tags [concat $tags tlr] -fill LightGreen -width 0
--- 139,148 ----
  	draw {
  	    snack:::sound s$id
! 	    set filename [dict get $($t) $id filename]
  	    s$id read $filename
  	    $p create path [::tkpath::coords rect 0 0 0 0 -rx 3 -ry 3] -tags [concat $tags r] -strokewidth 0 -fill $color -fillopacity 0.08
  	    $p create waveform 0 0 -tags [concat $tags w] -sound s$id -fill white
! 	    set length [expr [s$id length] / ($($t:samplerate) + 0.0) * 1000]
! 	    mat_item_ua $p $t $id abs [dict create xx [expr [dict get $($t) $id x] + $length]] 0
  	    $p create text 0 0 -tags [concat $tags tl] -font {{bitstream vera sans} 8} -fill HotPink -anchor nw -justify left -text "[string range $length 0 10] s"
  	    $p create rectangle 0 0 0 0 -tags [concat $tags tlr] -fill LightGreen -width 0
***************
*** 148,152 ****
  	    set ro 6
  	    $p coords $r [::tkpath::coords rect $x $y $sx $sy -rx $ro -ry $ro]
! 	    $p itemconfigure $r -fillopacity [dict get $_($t) $id v] -fill $color
  	    $p coords $w $x $y
  	    $p itemconfigure $w -width $sx -height [expr int($sy)]
--- 155,159 ----
  	    set ro 6
  	    $p coords $r [::tkpath::coords rect $x $y $sx $sy -rx $ro -ry $ro]
! 	    $p itemconfigure $r -fillopacity [dict get $($t) $id v] -fill $color
  	    $p coords $w $x $y
  	    $p itemconfigure $w -width $sx -height [expr int($sy)]





More information about the Pd-cvs mailing list