aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Mackerras <paulus@samba.org>2009-11-14 21:15:01 +1100
committerPaul Mackerras <paulus@samba.org>2009-11-14 21:15:01 +1100
commit51a7e8b654a0f06dde6f66ae89a35297cea09168 (patch)
treeb3383a1a979cb87e6144f0ed260d0faa146872c7
parent8d849957d81fc0480a52570d66cc3c2a688ecb1b (diff)
downloadgit-51a7e8b654a0f06dde6f66ae89a35297cea09168.tar.gz
git-51a7e8b654a0f06dde6f66ae89a35297cea09168.tar.xz
gitk: Improve appearance of radiobuttons and checkbuttons
Commit 5497f7a23ac11f9b230892220d5ed80263eedd1f ("gitk: Add configuration for UI colour scheme") added a call to tk_setPalette at startup. Unfortunately, tk_setPalette always chooses a dark red color for the selectColor value if none is given explicitly, and this makes checkbuttons and radiobuttons look rather bad. This restores the previous appearance by specifying selectColor explicitly. For light backgrounds we use white for selectColor, and for dark backgrounds we use black. The formula and threshold for distinguishing light from dark are the same as used in tk_setPalette for choosing the foreground color. Signed-off-by: Paul Mackerras <paulus@samba.org>
-rwxr-xr-xgitk14
1 files changed, 12 insertions, 2 deletions
diff --git a/gitk b/gitk
index db5ec54be..61771bd05 100755
--- a/gitk
+++ b/gitk
@@ -10596,8 +10596,18 @@ proc setselbg {c} {
allcanvs itemconf secsel -fill $c
}
+# This sets the background color and the color scheme for the whole UI.
+# For some reason, tk_setPalette chooses a nasty dark red for selectColor
+# if we don't specify one ourselves, which makes the checkbuttons and
+# radiobuttons look bad. This chooses white for selectColor if the
+# background color is light, or black if it is dark.
proc setui {c} {
- tk_setPalette $c
+ set bg [winfo rgb . $c]
+ set selc black
+ if {[lindex $bg 0] + 1.5 * [lindex $bg 1] + 0.5 * [lindex $bg 2] > 100000} {
+ set selc white
+ }
+ tk_setPalette background $c selectColor $selc
}
proc setbg {c} {
@@ -11159,7 +11169,7 @@ eval font create textfontbold [fontflags textfont 1]
parsefont uifont $uifont
eval font create uifont [fontflags uifont]
-tk_setPalette $uicolor
+setui $uicolor
setoptions