gitk: Fix clicks on arrows on line ends

With the new representation of the graph lines, this turns out
much simpler now.

Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
Paul Mackerras 2006-02-28 10:02:03 +11:00
parent 9f1afe05c3
commit f634248052

67
gitk
View File

@ -2918,65 +2918,26 @@ proc linehover {} {
} }
proc clickisonarrow {id y} { proc clickisonarrow {id y} {
global mainline mainlinearrow sidelines lthickness global lthickness idrowranges
set thresh [expr {2 * $lthickness + 6}] set thresh [expr {2 * $lthickness + 6}]
if {[info exists mainline($id)]} { set n [expr {[llength $idrowranges($id)] - 1}]
if {$mainlinearrow($id) ne "none"} { for {set i 1} {$i < $n} {incr i} {
if {abs([lindex $mainline($id) 1] - $y) < $thresh} { set row [lindex $idrowranges($id) $i]
return "up" if {abs([yc $row] - $y) < $thresh} {
} return $i
}
}
if {[info exists sidelines($id)]} {
foreach ls $sidelines($id) {
set coords [lindex $ls 0]
set arrow [lindex $ls 2]
if {$arrow eq "first" || $arrow eq "both"} {
if {abs([lindex $coords 1] - $y) < $thresh} {
return "up"
}
}
if {$arrow eq "last" || $arrow eq "both"} {
if {abs([lindex $coords end] - $y) < $thresh} {
return "down"
}
}
} }
} }
return {} return {}
} }
proc arrowjump {id dirn y} { proc arrowjump {id n y} {
global mainline sidelines canv canv2 canv3 global idrowranges canv
set yt {} # 1 <-> 2, 3 <-> 4, etc...
if {$dirn eq "down"} { set n [expr {(($n - 1) ^ 1) + 1}]
if {[info exists mainline($id)]} { set row [lindex $idrowranges($id) $n]
set y1 [lindex $mainline($id) 1] set yt [yc $row]
if {$y1 > $y} {
set yt $y1
}
}
if {[info exists sidelines($id)]} {
foreach ls $sidelines($id) {
set y1 [lindex $ls 0 1]
if {$y1 > $y && ($yt eq {} || $y1 < $yt)} {
set yt $y1
}
}
}
} else {
if {[info exists sidelines($id)]} {
foreach ls $sidelines($id) {
set y1 [lindex $ls 0 end]
if {$y1 < $y && ($yt eq {} || $y1 > $yt)} {
set yt $y1
}
}
}
}
if {$yt eq {}} return
set ymax [lindex [$canv cget -scrollregion] 3] set ymax [lindex [$canv cget -scrollregion] 3]
if {$ymax eq {} || $ymax <= 0} return if {$ymax eq {} || $ymax <= 0} return
set view [$canv yview] set view [$canv yview]
@ -2985,9 +2946,7 @@ proc arrowjump {id dirn y} {
if {$yfrac < 0} { if {$yfrac < 0} {
set yfrac 0 set yfrac 0
} }
$canv yview moveto $yfrac allcanvs yview moveto $yfrac
$canv2 yview moveto $yfrac
$canv3 yview moveto $yfrac
} }
proc lineclick {x y id isnew} { proc lineclick {x y id isnew} {