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>maint
parent
6e8c870703
commit
513a54dc21
34
gitk
34
gitk
|
@ -3363,7 +3363,7 @@ proc drawlineseg {id row endrow arrowlow} {
|
||||||
|
|
||||||
proc drawparentlinks {id row} {
|
proc drawparentlinks {id row} {
|
||||||
global rowidlist canv colormap curview parentlist
|
global rowidlist canv colormap curview parentlist
|
||||||
global idpos
|
global idpos linespc
|
||||||
|
|
||||||
set rowids [lindex $rowidlist $row]
|
set rowids [lindex $rowidlist $row]
|
||||||
set col [lsearch -exact $rowids $id]
|
set col [lsearch -exact $rowids $id]
|
||||||
|
@ -3373,6 +3373,8 @@ proc drawparentlinks {id row} {
|
||||||
set x [xc $row $col]
|
set x [xc $row $col]
|
||||||
set y [yc $row]
|
set y [yc $row]
|
||||||
set y2 [yc $row2]
|
set y2 [yc $row2]
|
||||||
|
set d [expr {int(0.4 * $linespc)}]
|
||||||
|
set ymid [expr {$y + $d}]
|
||||||
set ids [lindex $rowidlist $row2]
|
set ids [lindex $rowidlist $row2]
|
||||||
# rmx = right-most X coord used
|
# rmx = right-most X coord used
|
||||||
set rmx 0
|
set rmx 0
|
||||||
|
@ -3386,19 +3388,37 @@ proc drawparentlinks {id row} {
|
||||||
if {$x2 > $rmx} {
|
if {$x2 > $rmx} {
|
||||||
set rmx $x2
|
set rmx $x2
|
||||||
}
|
}
|
||||||
if {[lsearch -exact $rowids $p] < 0} {
|
set j [lsearch -exact $rowids $p]
|
||||||
|
if {$j < 0} {
|
||||||
# drawlineseg will do this one for us
|
# drawlineseg will do this one for us
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
assigncolor $p
|
assigncolor $p
|
||||||
# should handle duplicated parents here...
|
# should handle duplicated parents here...
|
||||||
set coords [list $x $y]
|
set coords [list $x $y]
|
||||||
if {$i < $col - 1} {
|
if {$i != $col} {
|
||||||
lappend coords [xc $row [expr {$i + 1}]] $y
|
# if attaching to a vertical segment, draw a smaller
|
||||||
} elseif {$i > $col + 1} {
|
# slant for visual distinctness
|
||||||
lappend coords [xc $row [expr {$i - 1}]] $y
|
if {$i == $j} {
|
||||||
|
if {$i < $col} {
|
||||||
|
lappend coords [expr {$x2 + $d}] $y $x2 $ymid
|
||||||
|
} else {
|
||||||
|
lappend coords [expr {$x2 - $d}] $y $x2 $ymid
|
||||||
|
}
|
||||||
|
} elseif {$i < $col && $i < $j} {
|
||||||
|
# segment slants towards us already
|
||||||
|
lappend coords [xc $row $j] $y
|
||||||
|
} else {
|
||||||
|
if {$i < $col - 1} {
|
||||||
|
lappend coords [expr {$x2 + $linespc}] $y
|
||||||
|
} elseif {$i > $col + 1} {
|
||||||
|
lappend coords [expr {$x2 - $linespc}] $y
|
||||||
|
}
|
||||||
|
lappend coords $x2 $y2
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
lappend coords $x2 $y2
|
||||||
}
|
}
|
||||||
lappend coords $x2 $y2
|
|
||||||
set t [$canv create line $coords -width [linewidth $p] \
|
set t [$canv create line $coords -width [linewidth $p] \
|
||||||
-fill $colormap($p) -tags lines.$p]
|
-fill $colormap($p) -tags lines.$p]
|
||||||
$canv lower $t
|
$canv lower $t
|
||||||
|
|
Loading…
Reference in New Issue