gitk: Better workaround for arrows on diagonal line segments
Instead of adding extra padding to create a vertical line segment at the lower end of a line that has an arrow, this now just draws a very short vertical line segment at the lower end. This alternative workaround for the Tk8.4 behaviour (not drawing arrows on diagonal line segments) doesn't have the problem of making the graph very wide when people do a lot of merges in a row (hi Junio :). Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Mar 31, 2006 at 10:45 UTC
879e8b1aad021cade0a254db0a5b67f56d99902a
1 file changed
+21
-16
gitk
+21
-16
@@ -1113,17 +1113,6 @@ proc optimize_rows {row col endrow} {
1113
set idlist [lindex $rowidlist $row]
1114
set offs [lindex $rowoffsets $row]
1115
set haspad 0
1116
- set downarrowcols {}
1117
- if {[info exists linesegends($row)]} {
1118
- set downarrowcols $linesegends($row)
1119
- if {$col > 0} {
1120
- while {$downarrowcols ne {}} {
1121
- set i [lsearch -exact $idlist [lindex $downarrowcols 0]]
1122
- if {$i < 0 || $i >= $col} break
1123
- set downarrowcols [lrange $downarrowcols 1 end]
1124
- }
1125
- }
1126
- }
1116
for {} {$col < [llength $offs]} {incr col} {
1117
if {[lindex $idlist $col] eq {}} {
1118
set haspad 1
@@ -1141,10 +1130,6 @@ proc optimize_rows {row col endrow} {
1130
$y0 > [lindex $idrowranges($id) 0]} {
1131
set isarrow 1
1132
}
1144
- } elseif {$downarrowcols ne {} &&
1145
- [lindex $idlist $col] eq [lindex $downarrowcols 0]} {
1146
- set downarrowcols [lrange $downarrowcols 1 end]
1147
- set isarrow 1
1133
}
1134
if {$z < -1 || ($z < 0 && $isarrow)} {
1135
set npad [expr {-1 - $z + $isarrow}]
@@ -1258,7 +1243,7 @@ proc linewidth {id} {
1243
proc drawlineseg {id i} {
1244
global rowoffsets rowidlist idrowranges
1245
global displayorder
1261
- global canv colormap
1246
+ global canv colormap linespc
1247
1248
set startrow [lindex $idrowranges($id) [expr {2 * $i}]]
1249
set row [lindex $idrowranges($id) [expr {2 * $i + 1}]]
@@ -1306,6 +1291,26 @@ proc drawlineseg {id i} {
1291
}
1292
if {[llength $coords] < 4} return
1293
set last [expr {[llength $idrowranges($id)] / 2 - 1}]
1294
+ if {$i < $last} {
1295
+ # This line has an arrow at the lower end: check if the arrow is
1296
+ # on a diagonal segment, and if so, work around the Tk 8.4
1297
+ # refusal to draw arrows on diagonal lines.
1298
+ set x0 [lindex $coords 0]
1299
+ set x1 [lindex $coords 2]
1300
+ if {$x0 != $x1} {
1301
+ set y0 [lindex $coords 1]
1302
+ set y1 [lindex $coords 3]
1303
+ if {$y0 - $y1 <= 2 * $linespc && $x1 == [lindex $coords 4]} {
1304
+ # we have a nearby vertical segment, just trim off the diag bit
1305
+ set coords [lrange $coords 2 end]
1306
+ } else {
1307
+ set slope [expr {($x0 - $x1) / ($y0 - $y1)}]
1308
+ set xi [expr {$x0 - $slope * $linespc / 2}]
1309
+ set yi [expr {$y0 - $linespc / 2}]
1310
+ set coords [lreplace $coords 0 1 $xi $y0 $xi $yi]
1311
+ }
1312
+ }
1313
+ }
1314
set arrow [expr {2 * ($i > 0) + ($i < $last)}]
1315
set arrow [lindex {none first last both} $arrow]
1316
set t [$canv create line $coords -width [linewidth $id] \