git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [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 3/3] gitk: improve dark background, select light or dark tags
@ 2010-07-22 23:14 David Fries
  0 siblings, 0 replies; 7+ messages in thread
From: David Fries @ 2010-07-22 23:14 UTC (permalink / raw)
  To: git

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.
---
 gitk-git/gitk |   29 ++++++++++++++++++++++++++---
 1 files changed, 26 insertions(+), 3 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index a851762..ca9244f 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,13 +6281,13 @@ 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 tag.$id]
 	    $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
 		if {$tag eq $mainhead} {
 		    set font mainfontbold
 		}
@@ -6302,7 +6303,7 @@ proc drawtags {id x xt y1} {
 		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 tag.$id
 	    }
 	}
 	set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
@@ -10878,6 +10879,23 @@ proc setbg {c} {
     }
 }
 
+proc setfill {c} {
+    global tagcolor branchcolor remotecolor
+
+    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"
+    }
+}
+
 proc setfg {c} {
     global fglist canv
 
@@ -10887,6 +10905,8 @@ proc setfg {c} {
     allcanvs itemconf text -fill $c
     $canv itemconf circle -outline $c
     $canv itemconf markid -outline $c
+
+    setfill $c
 }
 
 proc prefscan {} {
@@ -11382,11 +11402,13 @@ if {[tk windowingsystem] eq "win32"} {
     set uicolor SystemButtonFace
     set bgcolor SystemWindow
     set fgcolor SystemButtonText
+    setfill $fgcolor
     set selectbgcolor SystemHighlight
 } else {
     set uicolor grey85
     set bgcolor white
     set fgcolor black
+    setfill $fgcolor
     set selectbgcolor gray85
 }
 set diffcolors {red "#00a000" blue}
@@ -11423,6 +11445,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.1

^ permalink raw reply related	[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:14 [PATCH 3/3] gitk: improve dark background, select light or dark tags 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).