@matheusbsbs / matheus-bagliano / commits / f634248052
Fork 0

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>

Paul Mackerras committed Feb 28, 2006 at 10:02 UTC f634248052d3b9bd58d2d28e06ffde0ba46bad8d
1 file changed +13 -54
gitk
+13 -54
@@ -2918,65 +2918,26 @@ proc linehover {} {
2918 }
2919
2920 proc clickisonarrow {id y} {
2921 - global mainline mainlinearrow sidelines lthickness
2921 + global lthickness idrowranges
2922
2923 set thresh [expr {2 * $lthickness + 6}]
2924 - if {[info exists mainline($id)]} {
2925 - if {$mainlinearrow($id) ne "none"} {
2926 - if {abs([lindex $mainline($id) 1] - $y) < $thresh} {
2927 - return "up"
2928 - }
2929 - }
2930 - }
2931 - if {[info exists sidelines($id)]} {
2932 - foreach ls $sidelines($id) {
2933 - set coords [lindex $ls 0]
2934 - set arrow [lindex $ls 2]
2935 - if {$arrow eq "first" || $arrow eq "both"} {
2936 - if {abs([lindex $coords 1] - $y) < $thresh} {
2937 - return "up"
2938 - }
2939 - }
2940 - if {$arrow eq "last" || $arrow eq "both"} {
2941 - if {abs([lindex $coords end] - $y) < $thresh} {
2942 - return "down"
2943 - }
2944 - }
2924 + set n [expr {[llength $idrowranges($id)] - 1}]
2925 + for {set i 1} {$i < $n} {incr i} {
2926 + set row [lindex $idrowranges($id) $i]
2927 + if {abs([yc $row] - $y) < $thresh} {
2928 + return $i
2929 }
2930 }
2931 return {}
2932 }
2933
2950 -proc arrowjump {id dirn y} {
2951 - global mainline sidelines canv canv2 canv3
2934 +proc arrowjump {id n y} {
2935 + global idrowranges canv
2936
2953 - set yt {}
2954 - if {$dirn eq "down"} {
2955 - if {[info exists mainline($id)]} {
2956 - set y1 [lindex $mainline($id) 1]
2957 - if {$y1 > $y} {
2958 - set yt $y1
2959 - }
2960 - }
2961 - if {[info exists sidelines($id)]} {
2962 - foreach ls $sidelines($id) {
2963 - set y1 [lindex $ls 0 1]
2964 - if {$y1 > $y && ($yt eq {} || $y1 < $yt)} {
2965 - set yt $y1
2966 - }
2967 - }
2968 - }
2969 - } else {
2970 - if {[info exists sidelines($id)]} {
2971 - foreach ls $sidelines($id) {
2972 - set y1 [lindex $ls 0 end]
2973 - if {$y1 < $y && ($yt eq {} || $y1 > $yt)} {
2974 - set yt $y1
2975 - }
2976 - }
2977 - }
2978 - }
2979 - if {$yt eq {}} return
2937 + # 1 <-> 2, 3 <-> 4, etc...
2938 + set n [expr {(($n - 1) ^ 1) + 1}]
2939 + set row [lindex $idrowranges($id) $n]
2940 + set yt [yc $row]
2941 set ymax [lindex [$canv cget -scrollregion] 3]
2942 if {$ymax eq {} || $ymax <= 0} return
2943 set view [$canv yview]
@@ -2985,9 +2946,7 @@ proc arrowjump {id dirn y} {
2946 if {$yfrac < 0} {
2947 set yfrac 0
2948 }
2988 - $canv yview moveto $yfrac
2989 - $canv2 yview moveto $yfrac
2990 - $canv3 yview moveto $yfrac
2949 + allcanvs yview moveto $yfrac
2950 }
2951
2952 proc lineclick {x y id isnew} {