]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitk: allow horizontal commit-graph scrolling
authorMark Levedahl <mlevedahl@gmail.com>
Tue, 27 May 2025 03:47:39 +0000 (23:47 -0400)
committerMark Levedahl <mlevedahl@gmail.com>
Thu, 17 Jul 2025 03:01:51 +0000 (23:01 -0400)
gitk commit 5fdcbb1390 ("gitk: Fixes for Mac OS X TkAqua", 2009-03-23),
adds horizontal scrolling of the commit graph pane on aqua, but not on
x11 or win32. Also, the horizontal scrolling is triggered by MouseWheel
events attached to any of the three panes, not just the commit graph
that is the only one that scrolls. It is unusual to scroll a widget that
is not under the mouse, many would consider this a bug. No horizontal
scrollbar is provided for this, so there is no real cue for the user
that horizontal scrolling is available. We removed this aqua only
feature by transitioning aqua to use the common MouseWheel bindings set.

Let's add this as a feature on all platforms, and use the same approach
for scaling scroll motion as we do elsewhere.  For horizontal scrolling,
honor only events received by the commit graph in conformance with
normal GUI design.  Vertical scrolling is unchanged, and events received
by any of the 3 panes continue to scroll all 3 in unison.

Per the ancient and long ignored CUA standards, we should add a
horizontal scrollbar to the commit-graph, but gitk's interface is
already very cluttered: adding a scrollbar to only one of these three
panes is difficult while maintaining common pane vertical size,
especially so considering the movable sash separating panes 1 & 2, and
will consume yet more space. So, leave this as a hidden feature, now
available on all platforms.

Signed-off-by: Mark Levedahl <mlevedahl@gmail.com>
gitk

diff --git a/gitk b/gitk
index bd57a55466dea5bf692289a42be340448fb43981..ba112586bed7e025f55c6ae9ee4f7e2492052900 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -2272,6 +2272,7 @@ proc bind_mousewheel {} {
     bind $ctext <Shift-MouseWheel> {$ctext xview scroll [scrollval %D 2] units}
     bind $cflist <MouseWheel> {$cflist yview scroll [scrollval %D 2] units}
     bind $cflist <Shift-MouseWheel> break
+    bind $canv <Shift-MouseWheel> {$canv xview scroll [scrollval %D] units}
 }
 
 proc bind_mousewheel_buttons {} {
@@ -2288,6 +2289,8 @@ proc bind_mousewheel_buttons {} {
         bind $cflist <ButtonRelease-5> {$cflist yview scroll  [scrollval -1 2] units}
         bind $cflist <Shift-ButtonRelease-4> break
         bind $cflist <Shift-ButtonRelease-5> break
+        bind $canv <Shift-ButtonRelease-4> {$canv xview scroll [scrollval 1] units}
+        bind $canv <Shift-ButtonRelease-5> {$canv xview scroll [scrollval -1] units}
 }
 
 proc makewindow {} {
@@ -2388,6 +2391,7 @@ proc makewindow {} {
     canvas $canv \
         -selectbackground $selectbgcolor \
         -background $bgcolor -bd 0 \
+        -xscrollincr $linespc \
         -yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll"
     .tf.histframe.pwclist add $canv
     set canv2 .tf.histframe.pwclist.canv2