gitk: Fix a bug in drawing the selected line as a thick line
If you clicked on a line, so that it was drawn double-thickness, and then scrolled to bring on-screen a child that hadn't previously been drawn, the lines from it to the selected line were drawn single-thickness. This fixes it so they are drawn double-thickness. This also removes an unnecessary setting of phase in drawrest. Signed-off-by: Paul Mackerras <paulus@samba.org>
Paul Mackerras committed
Mar 2, 2006 at 23:00 UTC
c934a8a3a32896e44123c0a489367a1df1108c4a
1 file changed
+25
-19
gitk
+25
-19
@@ -906,7 +906,7 @@ proc showstuff {canshow} {
906
incr i
907
if {$e ne {} && $e < $numcommits && $s <= $r1 && $e >= $r0
908
&& ![info exists idrangedrawn($id,$i)]} {
909
- drawlineseg $id $i 1
909
+ drawlineseg $id $i
910
set idrangedrawn($id,$i) 1
911
}
912
}
@@ -1183,9 +1183,19 @@ proc yc {row} {
1183
return [expr {$canvy0 + $row * $linespc}]
1184
}
1185
1186
-proc drawlineseg {id i wid} {
1186
+proc linewidth {id} {
1187
+ global thickerline lthickness
1188
+
1189
+ set wid $lthickness
1190
+ if {[info exists thickerline] && $id eq $thickerline} {
1191
+ set wid [expr {2 * $lthickness}]
1192
+ }
1193
+ return $wid
1194
+}
1195
+
1196
+proc drawlineseg {id i} {
1197
global rowoffsets rowidlist idrowranges
1188
- global canv colormap lthickness
1198
+ global canv colormap
1199
1200
set startrow [lindex $idrowranges($id) [expr {2 * $i}]]
1201
set row [lindex $idrowranges($id) [expr {2 * $i + 1}]]
@@ -1216,18 +1226,17 @@ proc drawlineseg {id i wid} {
1226
set last [expr {[llength $idrowranges($id)] / 2 - 1}]
1227
set arrow [expr {2 * ($i > 0) + ($i < $last)}]
1228
set arrow [lindex {none first last both} $arrow]
1219
- set wid [expr {$wid * $lthickness}]
1229
set x [xc $row $col]
1230
set y [yc $row]
1231
lappend coords $x $y
1223
- set t [$canv create line $coords -width $wid \
1232
+ set t [$canv create line $coords -width [linewidth $id] \
1233
-fill $colormap($id) -tags lines.$id -arrow $arrow]
1234
$canv lower $t
1235
bindline $t $id
1236
}
1237
1229
-proc drawparentlinks {id row col olds wid} {
1230
- global rowidlist canv colormap lthickness
1238
+proc drawparentlinks {id row col olds} {
1239
+ global rowidlist canv colormap
1240
1241
set row2 [expr {$row + 1}]
1242
set x [xc $row $col]
@@ -1236,7 +1245,6 @@ proc drawparentlinks {id row col olds wid} {
1245
set ids [lindex $rowidlist $row2]
1246
# rmx = right-most X coord used
1247
set rmx 0
1239
- set wid [expr {$wid * $lthickness}]
1248
foreach p $olds {
1249
set i [lsearch -exact $ids $p]
1250
if {$i < 0} {
@@ -1256,7 +1264,7 @@ proc drawparentlinks {id row col olds wid} {
1264
set rmx $x2
1265
}
1266
lappend coords $x2 $y2
1259
- set t [$canv create line $coords -width $wid \
1267
+ set t [$canv create line $coords -width [linewidth $p] \
1268
-fill $colormap($p) -tags lines.$p]
1269
$canv lower $t
1270
bindline $t $p
@@ -1264,17 +1272,16 @@ proc drawparentlinks {id row col olds wid} {
1272
return $rmx
1273
}
1274
1267
-proc drawlines {id xtra} {
1275
+proc drawlines {id} {
1276
global colormap canv
1277
global idrowranges idrangedrawn
1278
global children iddrawn commitrow rowidlist
1279
1280
$canv delete lines.$id
1273
- set wid [expr {$xtra + 1}]
1281
set nr [expr {[llength $idrowranges($id)] / 2}]
1282
for {set i 0} {$i < $nr} {incr i} {
1283
if {[info exists idrangedrawn($id,$i)]} {
1277
- drawlineseg $id $i $wid
1284
+ drawlineseg $id $i
1285
}
1286
}
1287
if {[info exists children($id)]} {
@@ -1283,7 +1290,7 @@ proc drawlines {id xtra} {
1290
set row $commitrow($child)
1291
set col [lsearch -exact [lindex $rowidlist $row] $child]
1292
if {$col >= 0} {
1286
- drawparentlinks $child $row $col [list $id] $wid
1293
+ drawparentlinks $child $row $col [list $id]
1294
}
1295
}
1296
}
@@ -1345,7 +1352,7 @@ proc drawcmitrow {row} {
1352
if {$e eq {}} break
1353
if {$row <= $e} {
1354
if {$e < $numcommits && ![info exists idrangedrawn($id,$i)]} {
1348
- drawlineseg $id $i 1
1355
+ drawlineseg $id $i
1356
set idrangedrawn($id,$i) 1
1357
}
1358
break
@@ -1366,7 +1373,7 @@ proc drawcmitrow {row} {
1373
assigncolor $id
1374
if {[info exists commitlisted($id)] && [info exists parents($id)]
1375
&& $parents($id) ne {}} {
1369
- set rmx [drawparentlinks $id $row $col $parents($id) 1]
1376
+ set rmx [drawparentlinks $id $row $col $parents($id)]
1377
} else {
1378
set rmx 0
1379
}
@@ -1644,7 +1651,6 @@ proc settextcursor {c} {
1651
}
1652
1653
proc drawrest {} {
1647
- global phase
1654
global numcommits
1655
global startmsecs
1656
global canvy0 numcommits linespc
@@ -1656,7 +1662,6 @@ proc drawrest {} {
1662
optimize_rows $row 0 $commitidx
1663
showstuff $commitidx
1664
1659
- set phase {}
1665
set drawmsecs [expr {[clock clicks -milliseconds] - $startmsecs}]
1666
#puts "overall $drawmsecs ms for $numcommits commits"
1667
}
@@ -2884,8 +2889,8 @@ proc lineclick {x y id isnew} {
2889
normalline
2890
$canv delete hover
2891
# draw this line thicker than normal
2887
- drawlines $id 1
2892
set thickerline $id
2893
+ drawlines $id
2894
if {$isnew} {
2895
set ymax [lindex [$canv cget -scrollregion] 3]
2896
if {$ymax eq {}} return
@@ -2939,8 +2944,9 @@ proc lineclick {x y id isnew} {
2944
proc normalline {} {
2945
global thickerline
2946
if {[info exists thickerline]} {
2942
- drawlines $thickerline 0
2947
+ set id $thickerline
2948
unset thickerline
2949
+ drawlines $id
2950
}
2951
}
2952