{"thread":{"id":"24476","subject":"[PATCH 3/3] gitk: improve dark background, select light or dark tags","startedAt":"2010-07-22T23:14:59Z","lastAt":"2010-07-22T23:14:59Z","messageCount":1,"participants":["David Fries"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"146034","messageId":"20100722231459.GA25179@spacedout.fries.net","threadId":"24476","inReplyTo":null,"subject":"[PATCH 3/3] gitk: improve dark background, select light or dark tags","fromName":"David Fries","fromEmail":"david@fries.net","sentAt":"2010-07-22T23:14:59Z","receivedAt":"2010-07-22T23:14:59Z","isPatch":true,"sender":{"key":"david@fries.net","avatar":"https://avatars.githubusercontent.com/u/2767875?v=4"},"body":"If the foreground color is dark use light tags, branches, and\nremote fill colors.  If it is light use darker versions so the\ntext is readable.\n---\n gitk-git/gitk |   29 ++++++++++++++++++++++++++---\n 1 files changed, 26 insertions(+), 3 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex a851762..ca9244f 100644\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -6233,6 +6233,7 @@ proc drawtags {id x xt y1} {\n     global idtags idheads idotherrefs mainhead\n     global linespc lthickness\n     global canv rowtextx curview fgcolor bgcolor ctxbut\n+    global tagcolor branchcolor remotecolor\n \n     set marks {}\n     set ntags 0\n@@ -6280,13 +6281,13 @@ proc drawtags {id x xt y1} {\n \t    # draw a tag\n \t    set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \\\n \t\t       $xr $yt $xr $yb $xl $yb $x [expr {$yb - $delta}] \\\n-\t\t       -width 1 -outline $fgcolor -fill yellow -tags tag.$id]\n+\t\t       -width 1 -outline $fgcolor -fill $tagcolor -tags tag.$id]\n \t    $canv bind $t <1> [list showtag $tag 1]\n \t    set rowtextx([rowofcommit $id]) [expr {$xr + $linespc}]\n \t} else {\n \t    # draw a head or other ref\n \t    if {[incr nheads -1] >= 0} {\n-\t\tset col green\n+\t\tset col $branchcolor\n \t\tif {$tag eq $mainhead} {\n \t\t    set font mainfontbold\n \t\t}\n@@ -6302,7 +6303,7 @@ proc drawtags {id x xt y1} {\n \t\tset yti [expr {$yt + 1}]\n \t\tset xri [expr {$x + $rwid}]\n \t\t$canv create polygon $xi $yti $xri $yti $xri $yb $xi $yb \\\n-\t\t\t-width 0 -fill \"#ffddaa\" -tags tag.$id\n+\t\t\t-width 0 -fill $remotecolor -tags tag.$id\n \t    }\n \t}\n \tset t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \\\n@@ -10878,6 +10879,23 @@ proc setbg {c} {\n     }\n }\n \n+proc setfill {c} {\n+    global tagcolor branchcolor remotecolor\n+\n+    set fg [winfo rgb . $c]\n+    if {[lindex $fg 0] + 1.5 * [lindex $fg 1] + 0.5 * [lindex $fg 2] > 100000} {\n+\t# dark fill to read a light foreground font\n+\tset tagcolor yellow4\n+\tset branchcolor green4\n+\tset remotecolor \"#806F55\"\n+    } else {\n+\t# light fill to read a dark foreground font\n+        set tagcolor yellow\n+        set branchcolor green\n+        set remotecolor \"#ffddaa\"\n+    }\n+}\n+\n proc setfg {c} {\n     global fglist canv\n \n@@ -10887,6 +10905,8 @@ proc setfg {c} {\n     allcanvs itemconf text -fill $c\n     $canv itemconf circle -outline $c\n     $canv itemconf markid -outline $c\n+\n+    setfill $c\n }\n \n proc prefscan {} {\n@@ -11382,11 +11402,13 @@ if {[tk windowingsystem] eq \"win32\"} {\n     set uicolor SystemButtonFace\n     set bgcolor SystemWindow\n     set fgcolor SystemButtonText\n+    setfill $fgcolor\n     set selectbgcolor SystemHighlight\n } else {\n     set uicolor grey85\n     set bgcolor white\n     set fgcolor black\n+    setfill $fgcolor\n     set selectbgcolor gray85\n }\n set diffcolors {red \"#00a000\" blue}\n@@ -11423,6 +11445,7 @@ namespace import ::msgcat::mc\n ::msgcat::mcload $gitk_msgsdir\n \n catch {source ~/.gitk}\n+setfill $fgcolor\n \n parsefont mainfont $mainfont\n eval font create mainfont [fontflags mainfont]\n-- \n1.7.1\n"}]}