git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pekka Kaitaniemi <kaitanie@cc.helsinki.fi>
To: paulus@samba.org, newsletter@dirk.my1.cc
Cc: gitster@pobox.com, git@vger.kernel.org
Subject: [PATCH] gitk: Add horizontal scrollbar to the diff view
Date: Sat, 8 Mar 2008 14:27:23 +0200	[thread overview]
Message-ID: <20080308122723.GA11867@localdomain> (raw)

Adding horizontal scroll bar makes the scrolling feature more
discoverable to the users. The horizontal scrollbar is a bit narrower
than vertical ones so we don't make too big impact on available screen
real estate. The text and scrollbar widget layout is done using grid
geometry manager.

An interesting side effect of Tk scrollbars is that the "elevator"
size changes depending on the visible content. So the horizontal
scrollbar "elevator" changes as the user scrolls the view up and down.

Signed-off-by: Pekka Kaitaniemi <kaitanie@cc.helsinki.fi>
---
A modified version of the earlier patch that adds horizontal
scrollbar. This version uses grid layout for text and scrollbar
widgets. I have tested this patch with Tk 8.4 and 8.5 on Linux.

The width of the horizontal scrollbar (-width 10) seems to be OK with
Tk 8.5 on Linux (the default seems to be about 10 as well). I don't
know what it looks like on Windows and Mac, however.

 gitk |   20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/gitk b/gitk
index f1f21e9..429b091 100755
--- a/gitk
+++ b/gitk
@@ -827,6 +827,7 @@ proc makewindow {} {
     }
     frame .bleft.top
     frame .bleft.mid
+    frame .bleft.bottom
 
     button .bleft.top.search -text [mc "Search"] -command dosearch
     pack .bleft.top.search -side left -padx 5
@@ -854,18 +855,25 @@ proc makewindow {} {
     checkbutton .bleft.mid.ignspace -text [mc "Ignore space change"] \
 	-command changeignorespace -variable ignorespace
     pack .bleft.mid.ignspace -side left -padx 5
-    set ctext .bleft.ctext
+    set ctext .bleft.bottom.ctext
     text $ctext -background $bgcolor -foreground $fgcolor \
 	-state disabled -font textfont \
-	-yscrollcommand scrolltext -wrap none
+	-yscrollcommand scrolltext -wrap none \
+	-xscrollcommand ".bleft.bottom.sbhorizontal set"
     if {$have_tk85} {
 	$ctext conf -tabstyle wordprocessor
     }
-    scrollbar .bleft.sb -command "$ctext yview"
+    scrollbar .bleft.bottom.sb -command "$ctext yview"
+    scrollbar .bleft.bottom.sbhorizontal -command "$ctext xview" -orient h \
+	-width 10
     pack .bleft.top -side top -fill x
     pack .bleft.mid -side top -fill x
-    pack .bleft.sb -side right -fill y
-    pack $ctext -side left -fill both -expand 1
+    grid $ctext .bleft.bottom.sb -sticky nsew
+    grid .bleft.bottom.sbhorizontal -sticky ew
+    grid columnconfigure .bleft.bottom 0 -weight 1
+    grid rowconfigure .bleft.bottom 0 -weight 1
+    grid rowconfigure .bleft.bottom 1 -weight 0
+    pack .bleft.bottom -side top -fill both -expand 1
     lappend bglist $ctext
     lappend fglist $ctext
 
@@ -5604,7 +5612,7 @@ proc searchmarkvisible {doall} {
 proc scrolltext {f0 f1} {
     global searchstring
 
-    .bleft.sb set $f0 $f1
+    .bleft.bottom.sb set $f0 $f1
     if {$searchstring ne {}} {
 	searchmarkvisible 0
     }
-- 
1.5.4.3


             reply	other threads:[~2008-03-08 12:28 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-08 12:27 Pekka Kaitaniemi [this message]
  -- strict thread matches above, loose matches on Subject: below --
2008-03-05 22:51 [PATCH] gitk: Add horizontal scrollbar to the diff view Pekka Kaitaniemi
2008-03-06  6:18 ` Junio C Hamano
2008-03-06 10:30   ` Paul Mackerras
2008-03-06 11:53     ` Pekka Kaitaniemi
2008-03-08  1:53     ` Shawn O. Pearce
2008-03-08  5:41       ` Paul Mackerras
2008-03-08  5:51         ` Shawn O. Pearce

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080308122723.GA11867@localdomain \
    --to=kaitanie@cc.helsinki.fi \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=newsletter@dirk.my1.cc \
    --cc=paulus@samba.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).