Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9815
Modified Files: Tag: desiredata desire.tk defaults.ddrc Log Message: new feature: background grid in edit mode
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.600.2.265 retrieving revision 1.1.2.600.2.266 diff -C2 -d -r1.1.2.600.2.265 -r1.1.2.600.2.266 *** desire.tk 2 Aug 2007 03:08:54 -0000 1.1.2.600.2.265 --- desire.tk 2 Aug 2007 18:01:21 -0000 1.1.2.600.2.266 *************** *** 1548,1551 **** --- 1548,1554 ---- [$self window].bbar.edit configure -image $im if {[$self look hairstate] && !$@editmode} {$@crosshair erase} + if {[$self look gridstate]} { + if {$@editmode} {$@grid draw} else {$@grid erase} + } } # comment's look depends on the value of @editmode *************** *** 1625,1628 **** --- 1628,1632 ---- set @xmargin 0 set @ymargin 0 + #set @grid 1 }
*************** *** 1762,1765 **** --- 1766,1771 ---- set @active [Active new $self] set @sense [Sense new $self] + set @grid [Grid new $self] + #if {[info exists @grid]} {$@grid draw} }
*************** *** 1938,1941 **** --- 1944,1955 ---- $self bind <Unmap> unmap $self bind <Leave> leave + $self bind <Configure> configure %h %w + } + + def Canvas configure {h w} { + if {[$self look gridstate]} { + $@grid update $h $w + if {$@editmode} {$@grid draw} else {$@grid erase} + } }
*************** *** 2226,2229 **** --- 2240,2244 ---- } } + def Canvas popup_properties {} {CanvasPropertiesDialog new $self}
*************** *** 6424,6428 **** def Crosshair draw {} { set c [$@canvas widget] ! set z [$@canvas zoom] mset {type id detail} $@target mset {cx1 cy1 cx2 cy2} [$@canvas get_bbox] --- 6439,6443 ---- def Crosshair draw {} { set c [$@canvas widget] ! set z $@[$@canvas zoom] mset {type id detail} $@target mset {cx1 cy1 cx2 cy2} [$@canvas get_bbox] *************** *** 6482,6485 **** --- 6497,6545 ---- }
+ class_new Grid {View} + + def Grid init {canvas} { + super + set @canvas $canvas + set c [$@canvas widget] + set @width [winfo width $c] + set @height [winfo height $c] + set @size [$@canvas look grid_size] + set @col [$@canvas look grid] + } + + def Grid update {h w} {set @width $w; set @height $h} + def Grid size= {size} {set @size $size} + + def Grid draw {} { + set c [$@canvas widget] + set lowest [$@canvas lowest_item] + for {set i 1} {$i < $@width} {incr i} { + if {![expr $i % $@size]} { + set line [list $i 0 $i $@height] + $self item HL$i line $line -fill $@col -width 0.1 -dash {2 2 2 2} + } + } + for {set i 1} {$i < $@height} {incr i} { + if {![expr $i % $@size]} { + set line [list 0 $i $@width $i] + $self item VL$i line $line -fill $@col -width 0.1 -dash {2 2 2 2} + } + } + $c lower $self $lowest + } + + def Canvas lowest_item {} { + set c [$self widget] + set all [$c find all] + set lowest [lindex [$c gettags [lindex $all 0]] 0] + return $lowest + } + + #def Canvas grid_size {} {return [$self look grid_size]} + def Canvas grid_size= {size} { + set ::look(Canvas:grid_size) $size + if {[$self editmode]} {$@grid size= $size; $@grid erase; after 0 $@grid draw} + } ############ tooltips (only those that are drawn as canvas items)
*************** *** 7677,7680 **** --- 7737,7741 ---- color Canvas bgedit color Canvas bgrun + color Canvas grid subsection Client object_color color View bg *************** *** 7747,7750 **** --- 7808,7813 ---- toggle Canvas hairstate toggle Canvas hairsnap + toggle Canvas gridstate + integer Canvas grid_size toggle Canvas buttonbar toggle Canvas statusbar *************** *** 7890,7893 **** --- 7953,7957 ---- console {set @$name $look(Client:console)} pointer_sense {set @$name $look(Canvas:pointer_sense)} + grid_size {set @$name $look(Canvas:grid_size)} default {} }
Index: defaults.ddrc =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/defaults.ddrc,v retrieving revision 1.1.2.10.2.14 retrieving revision 1.1.2.10.2.15 diff -C2 -d -r1.1.2.10.2.14 -r1.1.2.10.2.15 *** defaults.ddrc 15 Jul 2007 13:16:25 -0000 1.1.2.10.2.14 --- defaults.ddrc 2 Aug 2007 18:01:24 -0000 1.1.2.10.2.15 *************** *** 16,19 **** --- 16,20 ---- bgedit #dddddd bgrun #ffffff + grid #ffffff buttonbar 1 compbg #ffffff *************** *** 24,27 **** --- 25,30 ---- hairsnap 1 hairstate 1 + gridstate 1 + grid_size 10 showcomp 10 statusbar 1