git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 2/3] gitk: improve dark background, use diffcolor 2 for link
@ 2010-07-22 23:12 David Fries
  0 siblings, 0 replies; 7+ messages in thread
From: David Fries @ 2010-07-22 23:12 UTC (permalink / raw)
  To: git

blue on a black background might as well look like dark blue on black
and is very difficult to read.  The "Diff: hunk header" keeps the
colors more consistent and both default to blue.
---
 gitk-git/gitk |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 8ca7182..a851762 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -6673,7 +6673,7 @@ proc appendwithlinks {text tags} {
 }
 
 proc setlink {id lk} {
-    global curview ctext pendinglinks
+    global curview ctext pendinglinks diffcolors
 
     set known 0
     if {[string length $id] < 40} {
@@ -6687,7 +6687,7 @@ proc setlink {id lk} {
 	set known [commitinview $id $curview]
     }
     if {$known} {
-	$ctext tag conf $lk -foreground blue -underline 1
+	$ctext tag conf $lk -foreground [lindex $diffcolors 2] -underline 1
 	$ctext tag bind $lk <1> [list selbyid $id]
 	$ctext tag bind $lk <Enter> {linkcursor %W 1}
 	$ctext tag bind $lk <Leave> {linkcursor %W -1}
-- 
1.7.1

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

* [PATCH 0/3] gitk: improve dark background
@ 2010-11-11  4:59 David Fries
  2010-11-11  5:19 ` [PATCH 1/3] gitk: improve dark background, s/black/$fgcolor/ David Fries
                   ` (3 more replies)
  0 siblings, 4 replies; 7+ messages in thread
From: David Fries @ 2010-11-11  4:59 UTC (permalink / raw)
  To: git

The gitk preferences allow for the user to select different colors.
The setui is even set to dynamically detect how light or dark the
background is and set the selection color to be the opposite, but
there are a few other color selections that don't currently work with
a dark background such as the black outlines.  This patch improves the
color selection.  In some cases it just needs to use the current
forground color, other places it is more complicated.

The gitk_colors branch can be pulled from,
git://gitorious.org/~dfries/git/dfriess-git-mainline.git

my relevant .gitk config file settings,

set mainfont {Helvetica 8}
set textfont {Courier 8}
set uifont {Helvetica 9 bold}
set uicolor grey85
set bgcolor black
set fgcolor white
set colors {green red blue magenta darkgrey brown orange}
set diffcolors {red green cyan}
set markbgcolor #404060
set selectbgcolor gray50

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

* [PATCH 1/3] gitk: improve dark background, s/black/$fgcolor/
  2010-11-11  4:59 [PATCH 0/3] gitk: improve dark background David Fries
@ 2010-11-11  5:19 ` David Fries
  2010-11-11  5:19 ` [PATCH 2/3] gitk: improve dark background, use diffcolor 2 for link David Fries
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 7+ messages in thread
From: David Fries @ 2010-11-11  5:19 UTC (permalink / raw)
  To: git; +Cc: David Fries

Replace most uses of black with $fgcolor as items such as a black
outline on the tag or tag lines with a black background doesn't show
up.  Use $fgcolor instead to make it contrast with the background.

Signed-off-by: David Fries <David@Fries.net>
---
 gitk-git/gitk |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 1b0e09a..af43353 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -6270,7 +6270,7 @@ proc drawtags {id x xt y1} {
 	set xt [expr {$xt + $delta + $wid + $lthickness + $linespc}]
     }
     set t [$canv create line $x $y1 [lindex $xvals end] $y1 \
-	       -width $lthickness -fill black -tags tag.$id]
+	       -width $lthickness -fill $fgcolor -tags [list tag.$id line]]
     $canv lower $t
     foreach tag $marks x $xvals wid $wvals {
 	set xl [expr {$x + $delta}]
@@ -6280,7 +6280,7 @@ proc drawtags {id x xt y1} {
 	    # draw a tag
 	    set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
 		       $xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
-		       -width 1 -outline black -fill yellow -tags tag.$id]
+		       -width 1 -outline $fgcolor -fill yellow -tags tag.$id]
 	    $canv bind $t <1> [list showtag $tag 1]
 	    set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
 	} else {
@@ -6295,7 +6295,7 @@ proc drawtags {id x xt y1} {
 	    }
 	    set xl [expr {$xl - $delta/2}]
 	    $canv create polygon $x $yt $xr $yt $xr $yb $x $yb \
-		-width 1 -outline black -fill $col -tags tag.$id
+		-width 1 -outline $fgcolor -fill $col -tags tag.$id
 	    if {[regexp {^(remotes/.*/|remotes/)} $tag match remoteprefix]} {
 	        set rwid [font measure mainfont $remoteprefix]
 		set xi [expr {$x + 1}]
@@ -8215,6 +8215,7 @@ proc linehover {} {
     global hoverx hovery hoverid hovertimer
     global canv linespc lthickness
     global commitinfo
+    global fgcolor
 
     set text [lindex $commitinfo($hoverid) 0]
     set ymax [lindex [$canv cget -scrollregion] 3]
@@ -8227,7 +8228,7 @@ proc linehover {} {
     set x1 [expr {$x + [font measure mainfont $text] + 2 * $lthickness}]
     set y1 [expr {$y + $linespc + 2 * $lthickness}]
     set t [$canv create rectangle $x0 $y0 $x1 $y1 \
-	       -fill \#ffff80 -outline black -width 1 -tags hover]
+	       -fill \#ffff80 -outline $fgcolor -width 1 -tags hover]
     $canv raise $t
     set t [$canv create text $x $y -anchor nw -text $text -tags hover \
 	       -font mainfont]
@@ -10886,6 +10887,7 @@ proc setfg {c} {
     allcanvs itemconf text -fill $c
     $canv itemconf circle -outline $c
     $canv itemconf markid -outline $c
+    $canv itemconf line -fill $c
 }
 
 proc prefscan {} {
-- 
1.7.2.3

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

* [PATCH 2/3] gitk: improve dark background, use diffcolor 2 for link
  2010-11-11  4:59 [PATCH 0/3] gitk: improve dark background David Fries
  2010-11-11  5:19 ` [PATCH 1/3] gitk: improve dark background, s/black/$fgcolor/ David Fries
@ 2010-11-11  5:19 ` David Fries
  2010-11-11  5:19 ` [PATCH 3/3] gitk: improve dark background, select light or dark tags David Fries
  2010-11-26 22:41 ` [PATCH 0/3] gitk: improve dark background David Fries
  3 siblings, 0 replies; 7+ messages in thread
From: David Fries @ 2010-11-11  5:19 UTC (permalink / raw)
  To: git; +Cc: David Fries

blue on a black background might as well look like dark blue on black
and is very difficult to read.  The "Diff: hunk header" keeps the
colors more consistent and both default to blue.

Signed-off-by: David Fries <David@Fries.net>
---
 gitk-git/gitk |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index af43353..bef2e53 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -6673,7 +6673,7 @@ proc appendwithlinks {text tags} {
 }
 
 proc setlink {id lk} {
-    global curview ctext pendinglinks
+    global curview ctext pendinglinks diffcolors
 
     set known 0
     if {[string length $id] < 40} {
@@ -6687,7 +6687,7 @@ proc setlink {id lk} {
 	set known [commitinview $id $curview]
     }
     if {$known} {
-	$ctext tag conf $lk -foreground blue -underline 1
+	$ctext tag conf $lk -foreground [lindex $diffcolors 2] -underline 1
 	$ctext tag bind $lk <1> [list selbyid $id]
 	$ctext tag bind $lk <Enter> {linkcursor %W 1}
 	$ctext tag bind $lk <Leave> {linkcursor %W -1}
@@ -10792,8 +10792,7 @@ proc doprefs {} {
     label $top.hunksep -padx 40 -relief sunk -background [lindex $diffcolors 2]
     ${NS}::button $top.hunksepbut -text [mc "Diff: hunk header"] \
 	-command [list choosecolor diffcolors 2 $top.hunksep \
-		      [mc "diff hunk header"] \
-		      [list $ctext tag conf hunksep -foreground]]
+		      [mc "diff hunk header"] sethunksep ]
     grid x $top.hunksepbut $top.hunksep -sticky w
     label $top.markbgsep -padx 40 -relief sunk -background $markbgcolor
     ${NS}::button $top.markbgbut -text [mc "Marked line bg"] \
@@ -10890,6 +10889,19 @@ proc setfg {c} {
     $canv itemconf line -fill $c
 }
 
+# update hunksep and each link foreground color
+proc sethunksep {c} {
+    global ctext linknum
+
+    $ctext tag conf hunksep -foreground $c
+    for {set i 0} {$i < $linknum} {incr i} {
+        # Use -underline to determine if it is a known link and gets this color
+        if {[$ctext tag cget link$i -underline] != ""} {
+            $ctext tag conf link$i -foreground $c
+        }
+    }
+}
+
 proc prefscan {} {
     global oldprefs prefstop
 
-- 
1.7.2.3

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

* [PATCH 3/3] gitk: improve dark background, select light or dark tags
  2010-11-11  4:59 [PATCH 0/3] gitk: improve dark background David Fries
  2010-11-11  5:19 ` [PATCH 1/3] gitk: improve dark background, s/black/$fgcolor/ David Fries
  2010-11-11  5:19 ` [PATCH 2/3] gitk: improve dark background, use diffcolor 2 for link David Fries
@ 2010-11-11  5:19 ` David Fries
  2010-11-26 22:41 ` [PATCH 0/3] gitk: improve dark background David Fries
  3 siblings, 0 replies; 7+ messages in thread
From: David Fries @ 2010-11-11  5:19 UTC (permalink / raw)
  To: git; +Cc: David Fries

If the foreground color is dark use light tags, branches, and
remote fill colors.  If it is light use darker versions so the
text is readable.

Signed-off-by: David Fries <David@Fries.net>
---
 gitk-git/gitk |   41 +++++++++++++++++++++++++++++++++++++----
 1 files changed, 37 insertions(+), 4 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index bef2e53..6342a31 100644
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -6233,6 +6233,7 @@ proc drawtags {id x xt y1} {
     global idtags idheads idotherrefs mainhead
     global linespc lthickness
     global canv rowtextx curview fgcolor bgcolor ctxbut
+    global tagcolor branchcolor remotecolor
 
     set marks {}
     set ntags 0
@@ -6280,29 +6281,32 @@ proc drawtags {id x xt y1} {
 	    # draw a tag
 	    set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
 		       $xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \
-		       -width 1 -outline $fgcolor -fill yellow -tags tag.$id]
+		       -width 1 -outline $fgcolor -fill $tagcolor -tags \
+		       [list tag.$id tagcolor]]
 	    $canv bind $t <1> [list showtag $tag 1]
 	    set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]
 	} else {
 	    # draw a head or other ref
 	    if {[incr nheads -1] >= 0} {
-		set col green
+		set col $branchcolor
+		set t [list tag.$id branchcolor]
 		if {$tag eq $mainhead} {
 		    set font mainfontbold
 		}
 	    } else {
 		set col "#ddddff"
+		set t tag.$id
 	    }
 	    set xl [expr {$xl - $delta/2}]
 	    $canv create polygon $x $yt $xr $yt $xr $yb $x $yb \
-		-width 1 -outline $fgcolor -fill $col -tags tag.$id
+		-width 1 -outline $fgcolor -fill $col -tags $t
 	    if {[regexp {^(remotes/.*/|remotes/)} $tag match remoteprefix]} {
 	        set rwid [font measure mainfont $remoteprefix]
 		set xi [expr {$x + 1}]
 		set yti [expr {$yt + 1}]
 		set xri [expr {$x + $rwid}]
 		$canv create polygon $xi $yti $xri $yti $xri $yb $xi $yb \
-			-width 0 -fill "#ffddaa" -tags tag.$id
+			-width 0 -fill $remotecolor -tags [list tag.$id remotecolor]
 	    }
 	}
 	set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
@@ -10877,6 +10881,30 @@ proc setbg {c} {
     }
 }
 
+proc setfill {c} {
+    global tagcolor branchcolor remotecolor
+    global canv;
+
+    set fg [winfo rgb . $c]
+    if {[lindex $fg 0] + 1.5 * [lindex $fg 1] + 0.5 * [lindex $fg 2] > 100000} {
+	# dark fill to read a light foreground font
+	set tagcolor yellow4
+	set branchcolor green4
+	set remotecolor "#806F55"
+    } else {
+	# light fill to read a dark foreground font
+        set tagcolor yellow
+        set branchcolor green
+        set remotecolor "#ffddaa"
+    }
+    # update tags assocated with non-text elements
+    if {[info exists canv]} {
+        $canv itemconf tagcolor -fill $tagcolor
+        $canv itemconf branchcolor -fill $branchcolor
+        $canv itemconf remotecolor -fill $remotecolor
+    }
+}
+
 proc setfg {c} {
     global fglist canv
 
@@ -10887,6 +10915,10 @@ proc setfg {c} {
     $canv itemconf circle -outline $c
     $canv itemconf markid -outline $c
     $canv itemconf line -fill $c
+    $canv itemconf tagcolor -outline $c
+    $canv itemconf branchcolor -outline $c
+
+    setfill $c
 }
 
 # update hunksep and each link foreground color
@@ -11436,6 +11468,7 @@ namespace import ::msgcat::mc
 ::msgcat::mcload $gitk_msgsdir
 
 catch {source ~/.gitk}
+setfill $fgcolor
 
 parsefont mainfont $mainfont
 eval font create mainfont [fontflags mainfont]
-- 
1.7.2.3

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

* [PATCH 0/3] gitk: improve dark background
  2010-11-11  4:59 [PATCH 0/3] gitk: improve dark background David Fries
                   ` (2 preceding siblings ...)
  2010-11-11  5:19 ` [PATCH 3/3] gitk: improve dark background, select light or dark tags David Fries
@ 2010-11-26 22:41 ` David Fries
  2010-11-27  1:34   ` Junio C Hamano
  3 siblings, 1 reply; 7+ messages in thread
From: David Fries @ 2010-11-26 22:41 UTC (permalink / raw)
  To: git; +Cc: gitster

Junio,

I submitted the 'gitk: improve dark background' patch to the list,
made improvements based on the feedback, and submitted the result two
weeks ago without any further feedback.  I put my changes off of
master, but gitk is identical in both maint and master.  Can you pull
the changes?

branch gitk_colors from
git://gitorious.org/~dfries/git/dfriess-git-mainline.git

This e-mail is also a replay to the last posting of the patches.

On Wed, Nov 10, 2010 at 10:59:54PM -0600, David Fries wrote:
> The gitk preferences allow for the user to select different colors.
> The setui is even set to dynamically detect how light or dark the
> background is and set the selection color to be the opposite, but
> there are a few other color selections that don't currently work with
> a dark background such as the black outlines.  This patch improves the
> color selection.  In some cases it just needs to use the current
> forground color, other places it is more complicated.
> 
> The gitk_colors branch can be pulled from,
> git://gitorious.org/~dfries/git/dfriess-git-mainline.git
> 
> my relevant .gitk config file settings,
> 
> set mainfont {Helvetica 8}
> set textfont {Courier 8}
> set uifont {Helvetica 9 bold}
> set uicolor grey85
> set bgcolor black
> set fgcolor white
> set colors {green red blue magenta darkgrey brown orange}
> set diffcolors {red green cyan}
> set markbgcolor #404060
> set selectbgcolor gray50

-- 
David Fries <david@fries.net>
http://fries.net/~david/ (PGP encryption key available)

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

* Re: [PATCH 0/3] gitk: improve dark background
  2010-11-26 22:41 ` [PATCH 0/3] gitk: improve dark background David Fries
@ 2010-11-27  1:34   ` Junio C Hamano
  0 siblings, 0 replies; 7+ messages in thread
From: Junio C Hamano @ 2010-11-27  1:34 UTC (permalink / raw)
  To: David Fries; +Cc: git, Paul Mackerras

David Fries <david@fries.net> writes:

> I submitted the 'gitk: improve dark background' patch to the list,
> made improvements based on the feedback, and submitted the result two
> weeks ago without any further feedback.  I put my changes off of
> master, but gitk is identical in both maint and master.  Can you pull
> the changes?

I saw the patch, but I didn't really look at it (I don't use gitk very
often, and I am an old-fashioned "darker ink on lighter sheet" user so I
wouldn't be a good judge on your change).

I don't take patches to gitk or git-gui directly to my tree.  Please Cc:
the maintainer of that part of the system (Paulus, whom I am Cc'ing this
message) the next time.

Thanks.

> branch gitk_colors from
> git://gitorious.org/~dfries/git/dfriess-git-mainline.git
>
> This e-mail is also a replay to the last posting of the patches.
>
> On Wed, Nov 10, 2010 at 10:59:54PM -0600, David Fries wrote:
>> The gitk preferences allow for the user to select different colors.
>> The setui is even set to dynamically detect how light or dark the
>> background is and set the selection color to be the opposite, but
>> there are a few other color selections that don't currently work with
>> a dark background such as the black outlines.  This patch improves the
>> color selection.  In some cases it just needs to use the current
>> forground color, other places it is more complicated.
>> ...

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

end of thread, other threads:[~2010-11-27  1:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-11  4:59 [PATCH 0/3] gitk: improve dark background David Fries
2010-11-11  5:19 ` [PATCH 1/3] gitk: improve dark background, s/black/$fgcolor/ David Fries
2010-11-11  5:19 ` [PATCH 2/3] gitk: improve dark background, use diffcolor 2 for link David Fries
2010-11-11  5:19 ` [PATCH 3/3] gitk: improve dark background, select light or dark tags David Fries
2010-11-26 22:41 ` [PATCH 0/3] gitk: improve dark background David Fries
2010-11-27  1:34   ` Junio C Hamano
  -- strict thread matches above, loose matches on Subject: below --
2010-07-22 23:12 [PATCH 2/3] gitk: improve dark background, use diffcolor 2 for link David Fries

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).