[PD-cvs] extensions/gui/ix mat.wid,1.14,1.15

carmen rocco ix9 at users.sourceforge.net
Tue Jul 5 13:02:03 CEST 2005


Update of /cvsroot/pure-data/extensions/gui/ix
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15897

Modified Files:
	mat.wid 
Log Message:
root     10786 13.5  4.0 115888 84324 pts/5    S+   11:00   1:01 


Index: mat.wid
===================================================================
RCS file: /cvsroot/pure-data/extensions/gui/ix/mat.wid,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** mat.wid	5 Jul 2005 07:52:23 -0000	1.14
--- mat.wid	5 Jul 2005 11:02:00 -0000	1.15
***************
*** 14,31 ****
  	foreach xy $axis {
  	    set mv [expr {($_($t:${xy}b) - $_($t:${xy}a)) / 4.0}]
! 	    foreach ab {a b} {set _($t:${xy}$ab) [expr { $d > 0 ? $_($t:${xy}$ab) + $mv : $_($t:${xy}$ab) - $mv }]}}
  	mat_redraw $p $t all
  	mat_gridlines $p $t} 
  
!     proc mat_sel {a p t x y} {
  	variable _
  	set _($t:sc) [rc]
  	switch $a {
! 	    start {
  		foreach xy {x y}  {set _($t:c$xy) [set $xy];set _($t:f$xy) [set $xy]}
  		$p.m create path [::tkpath::coords rect $_($t:cx) $_($t:cy) 0 0 -rx 12 -ry 12] \
  		    -tags sel -stroke $_($t:sc) -strokewidth 12 -strokeopacity 0.3}
! 	    close {$p.m delete sel}
  	    motion {
  		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)}
--- 14,34 ----
  	foreach xy $axis {
  	    set mv [expr {($_($t:${xy}b) - $_($t:${xy}a)) / 4.0}]
! 	    foreach ab {a b} {set _($t:${xy}$ab) [expr {$d > 0 ? $_($t:${xy}$ab) + $mv : $_($t:${xy}$ab) - $mv }]}}
  	mat_redraw $p $t all
  	mat_gridlines $p $t} 
  
!     proc mat_sel {p t a x y} {
  	variable _
  	set _($t:sc) [rc]
  	switch $a {
! 	    first {
  		foreach xy {x y}  {set _($t:c$xy) [set $xy];set _($t:f$xy) [set $xy]}
  		$p.m create path [::tkpath::coords rect $_($t:cx) $_($t:cy) 0 0 -rx 12 -ry 12] \
  		    -tags sel -stroke $_($t:sc) -strokewidth 12 -strokeopacity 0.3}
! 	    release {$p.m delete sel; set _($t:hover) 0}
  	    motion {
+ 		if {$_($t:hover) != 1} {
+ 		    mat_updatesel $p $t [mat_cleansel $p $t [$p.m 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)}
***************
*** 39,42 ****
--- 42,54 ----
  	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} {
+ 	variable _
+ 	if {$y eq "xx"} {set y x}; if {$y eq "yy"} {set y y}
+ 	if {$y eq "x" || $y eq "y"} {
+ 	    set v [expr {int( ($v + $_($t:q$y) / 2.0 ) / ($_($t:q$y) + 0.0))*$_($t:q$y)}]
+ 	}
+ 	return $v
+     }
      
      proc mat_item_update {p t item ci r x y xx yy} {
***************
*** 45,50 ****
  	    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]}
  
--- 57,62 ----
  	    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]}
  
***************
*** 109,113 ****
  	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}}
  
      proc mat_cleansel {p t sel} {
--- 121,127 ----
  	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_info $p $t $_($t:sel)
!     }
  
      proc mat_cleansel {p t sel} {
***************
*** 120,145 ****
  	mat_loc $p $t $x $y
  	if {[$p.m find withtag sel] ne ""} {
  	    set clicked [$p.m find overlapping $_($t:fx) $_($t:fy) $x $y] 
! 	    mat_sel motion $p $t $x $y
  	} else {
  	    set clicked [$p.m find overlapping $x $y $x $y]
  	}
- 	set n 0
- 	$p.m delete hover
  	set clicked [mat_cleansel $p $t $clicked]
  	if {$clicked ne ""} {
  	    mat_mode $p $t move_object
  	    if {[$p.m find withtag sel] eq "" && [llength $_($t:sel)] > 1} {return}
! 	    foreach item $_($t:sel) {
! 		if {[lsearch -integer $clicked $item] < 0} {
! 		    $p.m itemconfigure $item -fill blue}}
! 	    foreach item $clicked {
! 		set id [lindex [$p.m itemcget $item -tags] 1]
! 		$p.m itemconfigure $item -fill $_($t:sc)
! 		$p.m create text [list [expr [winfo width $p.m] - 8.0] [expr [winfo height $p.m] - 8.0 - 11 * $n.0]] -fill "#ff0022" -justify right -anchor se -font {{bitstream vera sans} 10} -tags hover -text [dict get $_($t) $id] 
! 		incr n		
! 	    }
! 	    set _($t:sel) $clicked
! 
  	} else {
  	    mat_mode $p $t move_canvas
--- 134,148 ----
  	mat_loc $p $t $x $y
  	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
  	    if {[$p.m find withtag sel] eq "" && [llength $_($t:sel)] > 1} {return}
! 	    mat_updatesel $p $t $clicked
  	} else {
  	    mat_mode $p $t move_canvas
***************
*** 147,153 ****
      }
  
      proc mat_click {m button action p t x y X Y} {
  	variable _
! 	set clicked [$p.m find overlapping $x $y $x $y]
  	set a [$p.m itemcget mode -text]
  	switch $action {
--- 150,180 ----
      }
  
+     proc mat_info {p t clicked} {
+ 	variable _
+ 	set n 0;$p.m delete hover
+ 	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
+ 	    incr n		
+ 	}}
+ 
+     proc mat_updatesel {p t clicked} {
+ 	variable _
+ 	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
+ 
+     }
+ 
      proc mat_click {m button action p t x y X Y} {
  	variable _
! 	set clicked [mat_cleansel $p $t [$p.m find overlapping $x $y $x $y]]
  	set a [$p.m itemcget mode -text]
  	switch $action {
***************
*** 157,173 ****
  		    1 {if {$m eq "control"} {
  			mat_mode $p $t draw; mat_draw $p $t $action $x $y
! 		    } elseif {$m eq "double"} {
! 			mat_sel start $p $t $x $y
  		    } elseif {[$p.m find withtag sel] ne ""} {
! 			mat_sel close $p $t $x $y}}
  		    2 {mat_mode $p $t resize_canvas}
! 		    3 {if {$clicked ne "" && [lindex [$p.m itemcget [lindex $clicked 0] -tags] 0] eq "item"} {
  			mat_mode $p $t object_trans } else {mat_rmenu $p $t $X $Y}}}}
  	    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}
--- 184,201 ----
  		    1 {if {$m eq "control"} {
  			mat_mode $p $t draw; mat_draw $p $t $action $x $y
! 		    } elseif {$m eq "double" || $m eq "shift"} {
! 			mat_sel $p $t first $x $y
! 			mat_mode $p $t sel
  		    } elseif {[$p.m find withtag sel] ne ""} {
! 			mat_sel $p $t release $x $y
! 		    } elseif {[llength $_($t:sel)] > 1 && [llength $clicked] > 0 && [lsearch $_($t:sel) $clicked] == -1} {
! 			mat_updatesel $p $t $clicked}}
  		    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 {
  		switch $button {
! 		    1 {if {$a eq "draw" || ($a eq "sel" && [expr {abs($_($t:fx) - $x)}] >13)} {eval mat_$a $p $t $action $x $y}}
  		    2 {mat_mode $p $t move_canvas}
  		    3 {mat_mode $p $t move_canvas}
***************
*** 238,242 ****
  
      proc mat_mode {p t m} {
! 	array set cursor {draw pencil move_canvas fleur move_object dotbox object_trans box_spiral resize_canvas bogosity}
  	$p.m itemconfigure mode -text $m
  	$p.m configure -cursor $cursor($m)
--- 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)
***************
*** 246,257 ****
      }
  
      proc mat_new {p t w h bg ln xa xb ya yb qx qy} {
  	variable _
- 	set i -1
  	set _($t) {}
! 	set _($t:sel) -1
! 	set _($t:sc) white
  	foreach xy {x y} {foreach ab {a b} {set ${xy}${ab}o [set ${xy}${ab}]}}
! 	foreach a {i 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
--- 274,294 ----
      }
  
+     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 _
  	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]}
! 	mat_group_new $p $t default
  	if {[winfo exists $p.m] != 1} {
  	    canvas $p.m -bg $bg -width $w -height $h
***************
*** 270,273 ****
--- 307,311 ----
              $p configure -bg gray -width [expr {[winfo width $p.m] + $bd}] -height [expr {[winfo height $p.m] + $bd}]
  	    $p.m create text {20 20} -fill blue -justify left -anchor w -font {{bitstream vera sans} 18} -tags mode -text move_canvas
+ 	    $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}}





More information about the Pd-cvs mailing list