All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] gitk: Add a horizontal scrollbar for commit history
@ 2013-10-30 10:58 Nicolas Cornu
  2013-10-30 12:01 ` Johannes Sixt
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Cornu @ 2013-10-30 10:58 UTC (permalink / raw)
  To: git; +Cc: paulus

This scrollbar is not optional and is useful if there is a lot of tags or
branches.

Signed-off-by: Nicolas Cornu <ncornu@aldebaran-robotics.com>
---
 gitk | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/gitk b/gitk
index 5cd00d8..62563b1 100755
--- a/gitk
+++ b/gitk
@@ -2120,11 +2120,17 @@ proc makewindow {} {
     # create three canvases
     set cscroll .tf.histframe.csb
     set canv .tf.histframe.pwclist.canv
+    set cscrollhl .tf.histframe.pwclist.canv.csb
     canvas $canv \
 	-selectbackground $selectbgcolor \
 	-background $bgcolor -bd 0 \
-	-yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll"
+	-yscrollincr $linespc -yscrollcommand "scrollcanv $cscroll" \
+	-xscrollcommand "scrollcanv $cscrollhl"
     .tf.histframe.pwclist add $canv
+    ${NS}::scrollbar $cscrollhl -command {$canv xview} -orient horizontal
+    if {!$use_ttk} {$cscrollhl configure -highlightthickness 0}
+    pack $cscrollhl -fill x -side bottom
+
     set canv2 .tf.histframe.pwclist.canv2
     canvas $canv2 \
 	-selectbackground $selectbgcolor \
--
1.8.4.2

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history
  2013-10-30 10:58 [PATCH v2] gitk: Add a horizontal scrollbar for commit history Nicolas Cornu
@ 2013-10-30 12:01 ` Johannes Sixt
  2013-10-30 12:47   ` Nicolas Cornu
  0 siblings, 1 reply; 9+ messages in thread
From: Johannes Sixt @ 2013-10-30 12:01 UTC (permalink / raw)
  To: Nicolas Cornu, git; +Cc: paulus

Am 10/30/2013 11:58, schrieb Nicolas Cornu:
> This scrollbar is not optional and is useful if there is a lot of tags or
> branches.

If this is the "only" case where the scrollbar is useful, i.e., it would
be handy only once every other week, then it is better to remember that
you can pan around in the window by moving the mouse with the middle mouse
button held down. Vertical screen estate in the commit history pane is too
precious to waste for a scrollbar that is useless most of the time.

-- Hannes

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history
  2013-10-30 12:01 ` Johannes Sixt
@ 2013-10-30 12:47   ` Nicolas Cornu
  2013-10-30 14:46     ` Marc Branchaud
  2013-10-31  9:05     ` Paul Mackerras
  0 siblings, 2 replies; 9+ messages in thread
From: Nicolas Cornu @ 2013-10-30 12:47 UTC (permalink / raw)
  To: Johannes Sixt; +Cc: git, paulus

This is useful on all our repos, every times, as we put a tag per day.
If the HEAD didn't move during 150 days, we got 150 tags.
So, it depends, maybe can I put it as an option in Edit > Preferences?

2013/10/30 Johannes Sixt <j.sixt@viscovery.net>:
> Am 10/30/2013 11:58, schrieb Nicolas Cornu:
>> This scrollbar is not optional and is useful if there is a lot of tags or
>> branches.
>
> If this is the "only" case where the scrollbar is useful, i.e., it would
> be handy only once every other week, then it is better to remember that
> you can pan around in the window by moving the mouse with the middle mouse
> button held down. Vertical screen estate in the commit history pane is too
> precious to waste for a scrollbar that is useless most of the time.
>
> -- Hannes

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history
  2013-10-30 12:47   ` Nicolas Cornu
@ 2013-10-30 14:46     ` Marc Branchaud
  2013-10-30 14:49       ` Nicolas Cornu
  2013-10-31  9:05     ` Paul Mackerras
  1 sibling, 1 reply; 9+ messages in thread
From: Marc Branchaud @ 2013-10-30 14:46 UTC (permalink / raw)
  To: Nicolas Cornu, Johannes Sixt; +Cc: git, paulus

On 13-10-30 08:47 AM, Nicolas Cornu wrote:
> This is useful on all our repos, every times, as we put a tag per day.
> If the HEAD didn't move during 150 days, we got 150 tags.
> So, it depends, maybe can I put it as an option in Edit > Preferences?

Eek, even with a scrollbar, 150 tags seems like a lot to pan over.

I've often thought it would be good for gitk to combine multiple ref names
into some kind of dropdown or view-on-hover list.  (I don't know anything
about Tcl/Tk, so I don't know what's feasible.)  So if a commit has more than
a couple of branches (and/or tags), only show the first branch name along
with a glyph indicating that there are more, and let the user click on (or
hover over) that glyph to see all the branches (or tags -- that is, still
keep the tags and branches displayed separately).

		M.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history
  2013-10-30 14:46     ` Marc Branchaud
@ 2013-10-30 14:49       ` Nicolas Cornu
  2013-10-30 15:04         ` Marc Branchaud
  0 siblings, 1 reply; 9+ messages in thread
From: Nicolas Cornu @ 2013-10-30 14:49 UTC (permalink / raw)
  To: Marc Branchaud; +Cc: Johannes Sixt, git, paulus

2013/10/30 Marc Branchaud <marcnarc@xiplink.com>:
> On 13-10-30 08:47 AM, Nicolas Cornu wrote:
>> This is useful on all our repos, every times, as we put a tag per day.
>> If the HEAD didn't move during 150 days, we got 150 tags.
>> So, it depends, maybe can I put it as an option in Edit > Preferences?
>
> Eek, even with a scrollbar, 150 tags seems like a lot to pan over.
Now, it works pretty well and is easier than mouse middle-click which
acts strangely for me.
>
> I've often thought it would be good for gitk to combine multiple ref names
> into some kind of dropdown or view-on-hover list.  (I don't know anything
> about Tcl/Tk, so I don't know what's feasible.)  So if a commit has more than
> a couple of branches (and/or tags), only show the first branch name along
> with a glyph indicating that there are more, and let the user click on (or
> hover over) that glyph to see all the branches (or tags -- that is, still
> keep the tags and branches displayed separately).
It doesn't change that if you got 150 tags, when you will show them
up, you will need to scroll.
>
>                 M.
>

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history
  2013-10-30 14:49       ` Nicolas Cornu
@ 2013-10-30 15:04         ` Marc Branchaud
  0 siblings, 0 replies; 9+ messages in thread
From: Marc Branchaud @ 2013-10-30 15:04 UTC (permalink / raw)
  To: Nicolas Cornu; +Cc: Johannes Sixt, git, paulus

On 13-10-30 10:49 AM, Nicolas Cornu wrote:
> 2013/10/30 Marc Branchaud <marcnarc@xiplink.com>:
>> On 13-10-30 08:47 AM, Nicolas Cornu wrote:
>>> This is useful on all our repos, every times, as we put a tag per day.
>>> If the HEAD didn't move during 150 days, we got 150 tags.
>>> So, it depends, maybe can I put it as an option in Edit > Preferences?
>>
>> Eek, even with a scrollbar, 150 tags seems like a lot to pan over.
>
> Now, it works pretty well and is easier than mouse middle-click which
> acts strangely for me.

Yes, it's a bit weird for me too.  I think it's because the
middle-button-dragging can only be horizontal *xor* vertical.

>> I've often thought it would be good for gitk to combine multiple ref names
>> into some kind of dropdown or view-on-hover list.  (I don't know anything
>> about Tcl/Tk, so I don't know what's feasible.)  So if a commit has more than
>> a couple of branches (and/or tags), only show the first branch name along
>> with a glyph indicating that there are more, and let the user click on (or
>> hover over) that glyph to see all the branches (or tags -- that is, still
>> keep the tags and branches displayed separately).
>
> It doesn't change that if you got 150 tags, when you will show them
> up, you will need to scroll.

True, but it would mean that there's no horizontal scroll bar taking up space
in the main display.  The scrolling would also vertically oriented, which is
mousewheel-friendly.  Also, the display would be a lot less cluttered.

		M.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history
  2013-10-30 12:47   ` Nicolas Cornu
  2013-10-30 14:46     ` Marc Branchaud
@ 2013-10-31  9:05     ` Paul Mackerras
  2013-11-02  9:40       ` Heiko Voigt
  2013-11-04 15:50       ` Marc Branchaud
  1 sibling, 2 replies; 9+ messages in thread
From: Paul Mackerras @ 2013-10-31  9:05 UTC (permalink / raw)
  To: Nicolas Cornu; +Cc: git

On Wed, Oct 30, 2013 at 01:47:08PM +0100, Nicolas Cornu wrote:
> This is useful on all our repos, every times, as we put a tag per day.
> If the HEAD didn't move during 150 days, we got 150 tags.

Here is a patch that I did some time ago but have never pushed out.
Do you think it is an improvement when using gitk on a repo with lots
of tags?

Paul.

[PATCH] gitk: Tag display improvements

When a commit has many tags, the tag icons in the graph display can
easily become so wide as to push the commit message off the right-hand
edge of the graph display pane.  This changes the display so that if
there are more than 3 tags or they would take up more than a quarter
of the width of the pane, we instead display a single tag icon with
a legend inside it like "4 tags...".  If the user clicks on the tag
icon, gitk then displays all the tags in the diff display pane.

Signed-off-by: Paul Mackerras <paulus@samba.org>
---
 gitk | 96 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 83 insertions(+), 13 deletions(-)

diff --git a/gitk b/gitk
index 5cd00d8..0bdb146 100755
--- a/gitk
+++ b/gitk
@@ -2385,6 +2385,7 @@ proc makewindow {} {
     $ctext tag conf found -back $foundbgcolor
     $ctext tag conf currentsearchhit -back $currentsearchhitbgcolor
     $ctext tag conf wwrap -wrap word
+    $ctext tag conf bold -font textfontbold
 
     .pwbottom add .bleft
     if {!$use_ttk} {
@@ -6387,6 +6388,25 @@ proc bindline {t id} {
     $canv bind $t <Button-1> "lineclick %x %y $id 1"
 }
 
+proc graph_pane_width {} {
+    global use_ttk
+
+    if {$use_ttk} {
+	set g [.tf.histframe.pwclist sashpos 0]
+    } else {
+	set g [.tf.histframe.pwclist sash coord 0]
+    }
+    return [lindex $g 0]
+}
+
+proc totalwidth {l font extra} {
+    set tot 0
+    foreach str $l {
+	set tot [expr {$tot + [font measure $font $str] + $extra}]
+    }
+    return $tot
+}
+
 proc drawtags {id x xt y1} {
     global idtags idheads idotherrefs mainhead
     global linespc lthickness
@@ -6398,9 +6418,27 @@ proc drawtags {id x xt y1} {
     set marks {}
     set ntags 0
     set nheads 0
+    set singletag 0
+    set maxtags 3
+    set maxtagpct 25
+    set maxwidth [expr {[graph_pane_width] * $maxtagpct / 100}]
+    set delta [expr {int(0.5 * ($linespc - $lthickness))}]
+    set extra [expr {$delta + $lthickness + $linespc}]
+
     if {[info exists idtags($id)]} {
 	set marks $idtags($id)
 	set ntags [llength $marks]
+	if {$ntags > $maxtags ||
+	    [totalwidth $marks mainfont $extra] > $maxwidth} {
+	    # show just a single "n tags..." tag
+	    set singletag 1
+	    if {$ntags == 1} {
+		set marks [list "tag..."]
+	    } else {
+		set marks [list [format "%d tags..." $ntags]]
+	    }
+	    set ntags 1
+	}
     }
     if {[info exists idheads($id)]} {
 	set marks [concat $marks $idheads($id)]
@@ -6413,7 +6451,6 @@ proc drawtags {id x xt y1} {
 	return $xt
     }
 
-    set delta [expr {int(0.5 * ($linespc - $lthickness))}]
     set yt [expr {$y1 - 0.5 * $linespc}]
     set yb [expr {$yt + $linespc - 1}]
     set xvals {}
@@ -6428,7 +6465,7 @@ proc drawtags {id x xt y1} {
 	}
 	lappend xvals $xt
 	lappend wvals $wid
-	set xt [expr {$xt + $delta + $wid + $lthickness + $linespc}]
+	set xt [expr {$xt + $wid + $extra}]
     }
     set t [$canv create line $x $y1 [lindex $xvals end] $y1 \
 	       -width $lthickness -fill $reflinecolor -tags tag.$id]
@@ -6444,7 +6481,12 @@ proc drawtags {id x xt y1} {
 		       $xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
 		       -width 1 -outline $tagoutlinecolor -fill $tagbgcolor \
 		       -tags tag.$id]
-	    $canv bind $t <1> [list showtag $tag_quoted 1]
+	    if {$singletag} {
+		set tagclick [list showtags $id 1]
+	    } else {
+		set tagclick [list showtag $tag_quoted 1]
+	    }
+	    $canv bind $t <1> $tagclick
 	    set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
 	} else {
 	    # draw a head or other ref
@@ -6471,7 +6513,7 @@ proc drawtags {id x xt y1} {
 	set t [$canv create text $xl $y1 -anchor w -text $tag -fill $headfgcolor \
 		   -font $font -tags [list tag.$id text]]
 	if {$ntags >= 0} {
-	    $canv bind $t <1> [list showtag $tag_quoted 1]
+	    $canv bind $t <1> $tagclick
 	} elseif {$nheads >= 0} {
 	    $canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted]
 	}
@@ -10878,6 +10920,23 @@ proc listrefs {id} {
     return [list $x $y $z]
 }
 
+proc add_tag_ctext {tag} {
+    global ctext cached_tagcontent tagids
+
+    if {![info exists cached_tagcontent($tag)]} {
+	catch {
+	    set cached_tagcontent($tag) [exec git cat-file -p $tag]
+	}
+    }
+    $ctext insert end "[mc "Tag"]: $tag\n" bold
+    if {[info exists cached_tagcontent($tag)]} {
+	set text $cached_tagcontent($tag)
+    } else {
+	set text "[mc "Id"]:  $tagids($tag)"
+    }
+    appendwithlinks $text {}
+}
+
 proc showtag {tag isnew} {
     global ctext cached_tagcontent tagids linknum tagobjid
 
@@ -10888,17 +10947,28 @@ proc showtag {tag isnew} {
     clear_ctext
     settabs 0
     set linknum 0
-    if {![info exists cached_tagcontent($tag)]} {
-	catch {
-           set cached_tagcontent($tag) [exec git cat-file -p $tag]
-	}
+    add_tag_ctext $tag
+    maybe_scroll_ctext 1
+    $ctext conf -state disabled
+    init_flist {}
+}
+
+proc showtags {id isnew} {
+    global idtags ctext linknum
+
+    if {$isnew} {
+	addtohistory [list showtags $id 0] savectextpos
     }
-    if {[info exists cached_tagcontent($tag)]} {
-	set text $cached_tagcontent($tag)
-    } else {
-	set text "[mc "Tag"]: $tag\n[mc "Id"]:  $tagids($tag)"
+    $ctext conf -state normal
+    clear_ctext
+    settabs 0
+    set linknum 0
+    set sep {}
+    foreach tag $idtags($id) {
+	$ctext insert end $sep
+	add_tag_ctext $tag
+	set sep "\n\n"
     }
-    appendwithlinks $text {}
     maybe_scroll_ctext 1
     $ctext conf -state disabled
     init_flist {}
-- 
1.8.4.rc3

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history
  2013-10-31  9:05     ` Paul Mackerras
@ 2013-11-02  9:40       ` Heiko Voigt
  2013-11-04 15:50       ` Marc Branchaud
  1 sibling, 0 replies; 9+ messages in thread
From: Heiko Voigt @ 2013-11-02  9:40 UTC (permalink / raw)
  To: Paul Mackerras, Nicolas Cornu; +Cc: git

Hi,

Am 31.10.2013 10:05, schrieb Paul Mackerras:
> On Wed, Oct 30, 2013 at 01:47:08PM +0100, Nicolas Cornu wrote:
>> This is useful on all our repos, every times, as we put a tag per day.
>> If the HEAD didn't move during 150 days, we got 150 tags.
>
> Here is a patch that I did some time ago but have never pushed out.
> Do you think it is an improvement when using gitk on a repo with lots
> of tags?
>
> Paul.
>
> [PATCH] gitk: Tag display improvements
>
> When a commit has many tags, the tag icons in the graph display can
> easily become so wide as to push the commit message off the right-hand
> edge of the graph display pane.  This changes the display so that if
> there are more than 3 tags or they would take up more than a quarter
> of the width of the pane, we instead display a single tag icon with
> a legend inside it like "4 tags...".  If the user clicks on the tag
> icon, gitk then displays all the tags in the diff display pane.
>
> Signed-off-by: Paul Mackerras <paulus@samba.org>

Yes please. I have not tried it but the description sounds great. Will 
try to give it a testdrive next week.

Cheers Heiko

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v2] gitk: Add a horizontal scrollbar for commit history
  2013-10-31  9:05     ` Paul Mackerras
  2013-11-02  9:40       ` Heiko Voigt
@ 2013-11-04 15:50       ` Marc Branchaud
  1 sibling, 0 replies; 9+ messages in thread
From: Marc Branchaud @ 2013-11-04 15:50 UTC (permalink / raw)
  To: Paul Mackerras, Nicolas Cornu; +Cc: git

On 13-10-31 05:05 AM, Paul Mackerras wrote:
> On Wed, Oct 30, 2013 at 01:47:08PM +0100, Nicolas Cornu wrote:
>> This is useful on all our repos, every times, as we put a tag per day.
>> If the HEAD didn't move during 150 days, we got 150 tags.
> 
> Here is a patch that I did some time ago but have never pushed out.
> Do you think it is an improvement when using gitk on a repo with lots
> of tags?

I like this a lot!  Thanks for putting it together.  I think it's worth
releasing this as-is.

My only wish is that it be generalized for any kind of ref:  Each refs/*
namespace should form a distinct display category.  For example, given refs
like this (note the non-standard "builds" namespace):

	refs/heads/maint
	refs/heads/master
	refs/heads/next
	refs/remotes/origin/maint
	refs/remotes/origin/master
	refs/remotes/origin/next
	refs/remotes/origin/pu
	refs/tags/v1.1.1
	refs/tags/v2.2.2
	refs/tags/v3.3.3
	refs/tags/v4.4.4
	refs/builds/1.1.1-1
	refs/builds/1.1.1-2
	refs/builds/1.1.1-3
	refs/builds/1.1.1-4
	refs/builds/1.1.1-5

And let's say that somehow all these refs refer to the same commit that's
being displayed in gitk, then I'd like to see something like:

	[3 branches...][4 remote refs...][4 tags...][5 builds...]

Gitk can be smart about how it displays standard namespaces (as it already is
for tags, heads, remote heads, etc.), but for non-standard namespaces gitk
can just display the namespace's name directly.

		M.

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2013-11-04 15:56 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-30 10:58 [PATCH v2] gitk: Add a horizontal scrollbar for commit history Nicolas Cornu
2013-10-30 12:01 ` Johannes Sixt
2013-10-30 12:47   ` Nicolas Cornu
2013-10-30 14:46     ` Marc Branchaud
2013-10-30 14:49       ` Nicolas Cornu
2013-10-30 15:04         ` Marc Branchaud
2013-10-31  9:05     ` Paul Mackerras
2013-11-02  9:40       ` Heiko Voigt
2013-11-04 15:50       ` Marc Branchaud

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.