[PD-cvs] pd/src desire.tk,1.1.2.600.2.385,1.1.2.600.2.386

chunlee chunlee at users.sourceforge.net
Fri Aug 17 06:16:09 CEST 2007


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

Modified Files:
      Tag: desiredata
	desire.tk 
Log Message:
improved grid and corsshair draw


Index: desire.tk
===================================================================
RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v
retrieving revision 1.1.2.600.2.385
retrieving revision 1.1.2.600.2.386
diff -C2 -d -r1.1.2.600.2.385 -r1.1.2.600.2.386
*** desire.tk	17 Aug 2007 00:28:45 -0000	1.1.2.600.2.385
--- desire.tk	17 Aug 2007 04:16:04 -0000	1.1.2.600.2.386
***************
*** 2011,2015 ****
  
  def Canvas configure {h w} {
! 	if {[$self look gridstate]} {$@grid update $h $w}
  }
  
--- 2011,2019 ----
  
  def Canvas configure {h w} {
! 	if {[$self look gridstate]} {
! 		$@grid update $h $w
! 		if {[winfo exists .$self.yscroll]} {return}; # scrollbar will update grid already
! 		$@grid draw
! 	}
  }
  
***************
*** 6718,6734 ****
  
  def Crosshair draw {} {
- 	set c [$@canvas widget]
- 	set z [$@canvas zoom]
  	mset {type id detail} $@target
! 	mset {cx1 cy1 cx2 cy2} [$@canvas get_bbox]
! 	set x $@x
! 	set y $@y
  	if {[$@canvas look hairsnap]} {
  		switch -regexp -- $type {^object|outlet|inlet$ {mset {x y x3 y3} [$id bbox]}}
  	}
! 	set width [winfo width $c]; set height [winfo height $c]
! 	set x1 [$c canvasx 0]; set y1 [$c canvasy 0]
! 	set h1 [list -1000 $y [expr ($x1+$width)*(1/$z)] $y]
! 	set v1 [list $x -1000 $x [expr ($y1+$height)*(1/$z)]]
  	$self item VHAIR1 line $v1 -fill [$@canvas look crosshair] -width 0.5 -dash {4 4 4 4}
  	$self item HHAIR1 line $h1 -fill [$@canvas look crosshair] -width 0.5 -dash {4 4 4 4}
--- 6722,6733 ----
  
  def Crosshair draw {} {
  	mset {type id detail} $@target
! 	set x $@x; set y $@y
  	if {[$@canvas look hairsnap]} {
  		switch -regexp -- $type {^object|outlet|inlet$ {mset {x y x3 y3} [$id bbox]}}
  	}
! 	mset {x1 y1 x2 y2} [$self display_area]
! 	set h1 [list $x1 $y $x2 $y]
! 	set v1 [list $x $y1 $x $y2]
  	$self item VHAIR1 line $v1 -fill [$@canvas look crosshair] -width 0.5 -dash {4 4 4 4}
  	$self item HHAIR1 line $h1 -fill [$@canvas look crosshair] -width 0.5 -dash {4 4 4 4}
***************
*** 6764,6767 ****
--- 6763,6777 ----
  }
  
+ def View display_area {} {
+ 	set c [$@canvas widget]; set z [$@canvas zoom]
+ 	set win_w [winfo width $c]; set win_h [winfo height $c]
+ 	set edge 10
+ 	set x1 [expr int([$c canvasx $edge]/$z)]
+ 	set y1 [expr int([$c canvasy $edge]/$z)]
+ 	set x2 [expr int(([$c canvasx $win_w]-$edge)/$z)]
+ 	set y2 [expr int(([$c canvasy $win_h]-$edge)/$z)]
+ 	return [list $x1 $y1 $x2 $y2]
+ }
+ 
  class_new Grid {View}
  
***************
*** 6796,6817 ****
  
  def Grid draw {} {
  	set c [$@canvas widget]
  	set lowest [$@canvas lowest_item]
! 	set x1 [$c canvasx 0]; set y1 [$c canvasy 0]
! 	set x2 [expr $x1+$@width]; set y2 [expr $y1+$@height]
! 	set zoom [$@canvas zoom]
! 	$self draw_lines $x1 $x2 $y2 HL
! 	$self draw_lines $y1 $y2 $x2 VL
  	$c lower $self $lowest
  }
  
! def Grid draw_lines {v1 v2 v3 tag} {
! 	set z [expr 1/[$@canvas zoom]]; set l 0; set g $@gap
! 	for {set i [expr int($v1*$z)]} {$i < $v2*$z} {incr i} {
  		if {$l%$g == 0} {set width 1;set dash [list 7 1]} {set width 1;set dash [list 1 4 1 4]}
  		if {![expr $i % int($@size)]} {
  			switch $tag {
! 				HL {set line [list $i -1000 $i [expr $v3*$z]]}
! 				VL {set line [list -1000 $i [expr $v3*$z] $i]}
  			}
  			$self item ${tag}$i line $line -fill $@col -width $width -dash $dash
--- 6806,6825 ----
  
  def Grid draw {} {
+ 	mset {x1 y1 x2 y2} [$self display_area]
  	set c [$@canvas widget]
  	set lowest [$@canvas lowest_item]
! 	$self draw_lines $x1 $x2 $y1 $y2 VL
! 	$self draw_lines $y1 $y2 $x1 $x2 HL
  	$c lower $self $lowest
  }
  
! def Grid draw_lines {v1 v2 v3 v4 tag} {
! 	set l 0; set g $@gap
! 	for {set i $v1} {$i < $v2} {incr i} {
  		if {$l%$g == 0} {set width 1;set dash [list 7 1]} {set width 1;set dash [list 1 4 1 4]}
  		if {![expr $i % int($@size)]} {
  			switch $tag {
! 				VL {set line [list $i $v3 $i $v4]}
! 				HL {set line [list $v3 $i $v4 $i]}
  			}
  			$self item ${tag}$i line $line -fill $@col -width $width -dash $dash
***************
*** 6819,6823 ****
  		}
  	}
- 
  }
  
--- 6827,6830 ----





More information about the Pd-cvs mailing list