Update of /cvsroot/pure-data/pd/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9755
Modified Files: Tag: desiredata desire.tk Log Message: first step in inlet/outlet approximate highlighting
Index: desire.tk =================================================================== RCS file: /cvsroot/pure-data/pd/src/Attic/desire.tk,v retrieving revision 1.1.2.600.2.180 retrieving revision 1.1.2.600.2.181 diff -C2 -d -r1.1.2.600.2.180 -r1.1.2.600.2.181 *** desire.tk 16 Apr 2007 14:24:02 -0000 1.1.2.600.2.180 --- desire.tk 9 May 2007 00:53:10 -0000 1.1.2.600.2.181 *************** *** 1537,1540 **** --- 1537,1541 ---- set @cmd_hist {} set @cmd_histi 0 + set @motion_watch 0 }
*************** *** 2676,2681 **** --- 2677,2700 ---- default {$@action motion $x $y $f $target} } + if {$@editmode} {$self motion_iohilite2 $x $y $f} if {$id == ""} {return} $self motion_iohilite $target $x $y + + } + + def Canvas motion_watch {} { + if {$@oldpos != $@curpos2} { + after 100 $self motion_watch + if {$@anchorx != [lindex $@curpos2 0] && $@anchory != [lindex $@curpos2 1]} { + $@approx data= $@anchorx $@anchory [lindex $@curpos2 0] [lindex $@curpos2 1] + $@approx draw + puts "approx::: $@approx" + } + puts "watching.... from $@anchorx , $@anchory" + } else { + puts "end watching" + set @motion_watch 0 + } + set @oldpos $@curpos2 }
*************** *** 2779,2782 **** --- 2798,2826 ---- }
+ def Canvas motion_iohilite2 {x y f} { + set c [$self widget] + set obj [$self identify_closestobj $x $y $f] + if {$obj < 0} {return} + mset {cx cy} [rect_centre [$obj bbox]] + if {$y < $cy} {set io i} else {set io o} + switch $io { + i {set ports [$obj ninlets]} + o {set ports [$obj noutlets]} + } + if {!$ports} {set io i; set ports [$obj ninlets]} + set mindist 66666 + set idx 0 + for {set i 0} {$i < $ports} {incr i} { + set point2 [rect_centre [$c bbox ${obj}$io${i}]] + set point1 [list $x $y] + set dist [distance $point1 $point2] + if {$dist < $mindist} {set mindist $dist; set idx $i; mset {iox ioy} $point2} + } + $obj hilite_io $io $iox $ioy + set @dehighlight [list $c delete ${obj}$io${idx}b] + #puts "obj:: $obj :: [$obj text] :: hilite $io :: $idx" + + } + def Canvas motion_iohilite {target x y} { set c [$self widget] *************** *** 2870,2873 **** --- 2914,2951 ---- }
+ def Canvas identify_closestobj {x y f} { + set c [$self widget] + set cx [expr $x*$@zoom] + set cy [expr $y*$@zoom] + set offset 100 + set stack [$c find overlapping [expr $cx-$offset] [expr $cy-$offset] [expr $cx+$offset] [expr $cy+$offset]] + set stack [lreverse $stack] + set objs {} + foreach tag $stack { + set tags [$c gettags $tag] + if {[regexp {^[xo][0-9a-f]{6,8}} $tags id]} { + set class [$id class] + switch $class { + Wire {} Crosshair {} Tooltip {} Comment {} SelRect {} + default {lappend objs $id} + } + } + } + set objs [lsort -unique $objs] + if {![llength $objs]} {return -1} + set mindist 66666 + set idx 0; set i 0 + foreach obj $objs { + set point2 [rect_centre [$obj bbox]] + set point1 [list $x $y] + set dist [distance $point2 $point1] + if {$dist < $mindist} {set mindist $dist; set idx $i} + incr i; + } + return [lindex $objs $idx] + #puts " mindist:: $mindist || idx:: $idx || [[lindex $objs $idx] text]" + } + + #-----------------------------------------------------------------------------------# class_new StatusBar {View} ;# no, using View is wrong here. View is for tk canvas item collections. *************** *** 6241,6245 **** }
- #def Crosshair erase {} {$self item_delete VHAIR1; $self item_delete HHAIR1}
--- 6319,6322 ----