@matheusbsbs / matheus-bagliano / commits / 513a54dc21
Fork 0

gitk: Improve the drawing of links to parent lines

The way gitk used to draw the lines joining a commit to the lines representing its parents was sometimes visually ambiguous, especially when the line to the parent had a corner that coincided with a corner on another line. This improves things by using a smaller slanting section on the line joining a commit to a parent line if the parent line is vertical where it joins on. It also optimizes the drawing a little in the case where the parent line slants towards this commit already. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Aug 1, 2007 at 22:27 UTC 513a54dc212044596d932dcc9468e0774c1ee2c1
1 file changed +27 -7
gitk
+27 -7
@@ -3363,7 +3363,7 @@ proc drawlineseg {id row endrow arrowlow} {
3363
3364 proc drawparentlinks {id row} {
3365 global rowidlist canv colormap curview parentlist
3366 - global idpos
3366 + global idpos linespc
3367
3368 set rowids [lindex $rowidlist $row]
3369 set col [lsearch -exact $rowids $id]
@@ -3373,6 +3373,8 @@ proc drawparentlinks {id row} {
3373 set x [xc $row $col]
3374 set y [yc $row]
3375 set y2 [yc $row2]
3376 + set d [expr {int(0.4 * $linespc)}]
3377 + set ymid [expr {$y + $d}]
3378 set ids [lindex $rowidlist $row2]
3379 # rmx = right-most X coord used
3380 set rmx 0
@@ -3386,19 +3388,37 @@ proc drawparentlinks {id row} {
3388 if {$x2 > $rmx} {
3389 set rmx $x2
3390 }
3389 - if {[lsearch -exact $rowids $p] < 0} {
3391 + set j [lsearch -exact $rowids $p]
3392 + if {$j < 0} {
3393 # drawlineseg will do this one for us
3394 continue
3395 }
3396 assigncolor $p
3397 # should handle duplicated parents here...
3398 set coords [list $x $y]
3396 - if {$i < $col - 1} {
3397 - lappend coords [xc $row [expr {$i + 1}]] $y
3398 - } elseif {$i > $col + 1} {
3399 - lappend coords [xc $row [expr {$i - 1}]] $y
3399 + if {$i != $col} {
3400 + # if attaching to a vertical segment, draw a smaller
3401 + # slant for visual distinctness
3402 + if {$i == $j} {
3403 + if {$i < $col} {
3404 + lappend coords [expr {$x2 + $d}] $y $x2 $ymid
3405 + } else {
3406 + lappend coords [expr {$x2 - $d}] $y $x2 $ymid
3407 + }
3408 + } elseif {$i < $col && $i < $j} {
3409 + # segment slants towards us already
3410 + lappend coords [xc $row $j] $y
3411 + } else {
3412 + if {$i < $col - 1} {
3413 + lappend coords [expr {$x2 + $linespc}] $y
3414 + } elseif {$i > $col + 1} {
3415 + lappend coords [expr {$x2 - $linespc}] $y
3416 + }
3417 + lappend coords $x2 $y2
3418 + }
3419 + } else {
3420 + lappend coords $x2 $y2
3421 }
3401 - lappend coords $x2 $y2
3422 set t [$canv create line $coords -width [linewidth $p] \
3423 -fill $colormap($p) -tags lines.$p]
3424 $canv lower $t