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

gitk: Allow top panes to scroll horizontally with mouse button 2

Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Mar 31, 2006 at 09:55 UTC be0cd0981f1811b9e5177f1f5c8ff900c33fbdbb
1 file changed +35 -10
gitk
+35 -10
@@ -512,8 +512,8 @@ proc makewindow {rargs} {
512 #bindall <B1-Motion> {selcanvline %W %x %y}
513 bindall <ButtonRelease-4> "allcanvs yview scroll -5 units"
514 bindall <ButtonRelease-5> "allcanvs yview scroll 5 units"
515 - bindall <2> "allcanvs scan mark 0 %y"
516 - bindall <B2-Motion> "allcanvs scan dragto 0 %y"
515 + bindall <2> "canvscan mark %W %x %y"
516 + bindall <B2-Motion> "canvscan dragto %W %x %y"
517 bind . <Key-Up> "selnextline -1"
518 bind . <Key-Down> "selnextline 1"
519 bind . <Key-Right> "goforw"
@@ -568,6 +568,19 @@ proc makewindow {rargs} {
568 $rowctxmenu add command -label "Write commit to file" -command writecommit
569 }
570
571 +# mouse-2 makes all windows scan vertically, but only the one
572 +# the cursor is in scans horizontally
573 +proc canvscan {op w x y} {
574 + global canv canv2 canv3
575 + foreach c [list $canv $canv2 $canv3] {
576 + if {$c == $w} {
577 + $c scan $op $x $y
578 + } else {
579 + $c scan $op 0 $y
580 + }
581 + }
582 +}
583 +
584 proc scrollcanv {cscroll f0 f1} {
585 $cscroll set $f0 $f1
586 drawfrac $f0 $f1
@@ -833,7 +846,7 @@ proc initlayout {} {
846 global rowidlist rowoffsets displayorder
847 global rowlaidout rowoptim
848 global idinlist rowchk
836 - global commitidx numcommits
849 + global commitidx numcommits canvxmax canv
850 global nextcolor
851
852 set commitidx 0
@@ -846,6 +859,16 @@ proc initlayout {} {
859 catch {unset rowchk}
860 set rowlaidout 0
861 set rowoptim 0
862 + set canvxmax [$canv cget -width]
863 +}
864 +
865 +proc setcanvscroll {} {
866 + global canv canv2 canv3 numcommits linespc canvxmax canvy0
867 +
868 + set ymax [expr {$canvy0 + ($numcommits - 0.5) * $linespc + 2}]
869 + $canv conf -scrollregion [list 0 0 $canvxmax $ymax]
870 + $canv2 conf -scrollregion [list 0 0 0 $ymax]
871 + $canv3 conf -scrollregion [list 0 0 0 $ymax]
872 }
873
874 proc visiblerows {} {
@@ -887,7 +910,6 @@ proc layoutmore {} {
910
911 proc showstuff {canshow} {
912 global numcommits
890 - global canvy0 linespc
913 global linesegends idrowranges idrangedrawn
914
915 if {$numcommits == 0} {
@@ -897,8 +919,7 @@ proc showstuff {canshow} {
919 }
920 set row $numcommits
921 set numcommits $canshow
900 - allcanvs conf -scrollregion \
901 - [list 0 0 0 [expr {$canvy0 + ($numcommits - 0.5) * $linespc + 2}]]
922 + setcanvscroll
923 set rows [visiblerows]
924 set r0 [lindex $rows 0]
925 set r1 [lindex $rows 1]
@@ -1366,7 +1387,7 @@ proc drawcmittext {id row col rmx} {
1387 global commitlisted commitinfo rowidlist
1388 global rowtextx idpos idtags idheads idotherrefs
1389 global linehtag linentag linedtag
1369 - global mainfont namefont
1390 + global mainfont namefont canvxmax
1391
1392 set ofill [expr {[info exists commitlisted($id)]? "blue": "white"}]
1393 set x [xc $row $col]
@@ -1398,6 +1419,11 @@ proc drawcmittext {id row col rmx} {
1419 -text $name -font $namefont]
1420 set linedtag($row) [$canv3 create text 3 $y -anchor w \
1421 -text $date -font $mainfont]
1422 + set xr [expr {$xt + [font measure $mainfont $headline]}]
1423 + if {$xr > $canvxmax} {
1424 + set canvxmax $xr
1425 + setcanvscroll
1426 + }
1427 }
1428
1429 proc drawcmitrow {row} {
@@ -2757,15 +2783,14 @@ proc setcoords {} {
2783 }
2784
2785 proc redisplay {} {
2760 - global canv canvy0 linespc numcommits
2786 + global canv
2787 global selectedline
2788
2789 set ymax [lindex [$canv cget -scrollregion] 3]
2790 if {$ymax eq {} || $ymax == 0} return
2791 set span [$canv yview]
2792 clear_display
2767 - allcanvs conf -scrollregion \
2768 - [list 0 0 0 [expr {$canvy0 + ($numcommits - 0.5) * $linespc + 2}]]
2793 + setcanvscroll
2794 allcanvs yview moveto [lindex $span 0]
2795 drawvisible
2796 if {[info exists selectedline]} {