diff options
author | Jiang Xin <worldhello.net@gmail.com> | 2020-12-21 07:10:19 +0800 |
---|---|---|
committer | Jiang Xin <worldhello.net@gmail.com> | 2020-12-21 07:10:19 +0800 |
commit | 3104153d5ea3bd0e68166e02ec847a895f9a76e6 (patch) | |
tree | 8b65383c203c550fab3f6ffea51cd474168ac34b /git-gui/lib/themed.tcl | |
parent | l10n: Update Catalan translation (diff) | |
parent | Git 2.30-rc1 (diff) | |
download | tgif-3104153d5ea3bd0e68166e02ec847a895f9a76e6.tar.xz |
Merge remote-tracking branch 'github/master' into git-po-master
* github/master: (42 commits)
Git 2.30-rc1
git-gui: use gray background for inactive text widgets
Another batch before 2.30-rc1
git-gui: Fix selected text colors
Makefile: conditionally include GIT-VERSION-FILE
git-gui: fix colored label backgrounds when using themed widgets
config.mak.uname: remove old NonStop compatibility settings
diff: correct interaction between --exit-code and -I<pattern>
t/perf: fix test_export() failure with BSD `sed`
style: do not "break" in switch() after "return"
compat-util: pretend that stub setitimer() always succeeds
strmap: make callers of strmap_remove() to call it in void context
doc: mention Python 3.x supports
index-format.txt: document v2 format of file system monitor extension
docs: multi-pack-index: remove note about future 'verify' work
init: provide useful advice about init.defaultBranch
get_default_branch_name(): prepare for showing some advice
branch -m: allow renaming a yet-unborn branch
init: document `init.defaultBranch` better
t7900: use --fixed-value in git-maintenance tests
...
Diffstat (limited to 'git-gui/lib/themed.tcl')
-rw-r--r-- | git-gui/lib/themed.tcl | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/git-gui/lib/themed.tcl b/git-gui/lib/themed.tcl index 83e3ac795f..f43d84e54f 100644 --- a/git-gui/lib/themed.tcl +++ b/git-gui/lib/themed.tcl @@ -6,19 +6,25 @@ namespace eval color { # Variable colors # Preffered way to set widget colors is using add_option. # In some cases, like with tags in_diff/in_sel, we use these colors. - variable select_bg lightgray - variable select_fg black + variable select_bg lightgray + variable select_fg black + variable inactive_select_bg lightgray + variable inactive_select_fg black proc sync_with_theme {} { - set base_bg [ttk::style lookup . -background] - set base_fg [ttk::style lookup . -foreground] - set text_bg [ttk::style lookup Treeview -background] - set text_fg [ttk::style lookup Treeview -foreground] - set select_bg [ttk::style lookup Default -selectbackground] - set select_fg [ttk::style lookup Default -selectforeground] + set base_bg [ttk::style lookup . -background] + set base_fg [ttk::style lookup . -foreground] + set text_bg [ttk::style lookup Treeview -background] + set text_fg [ttk::style lookup Treeview -foreground] + set select_bg [ttk::style lookup Default -selectbackground] + set select_fg [ttk::style lookup Default -selectforeground] + set inactive_select_bg [convert_rgb_to_gray $select_bg] + set inactive_select_fg $select_fg set color::select_bg $select_bg set color::select_fg $select_fg + set color::inactive_select_bg $inactive_select_bg + set color::inactive_select_fg $inactive_select_fg proc add_option {key val} { option add $key $val widgetDefault @@ -34,11 +40,22 @@ namespace eval color { } add_option *Text.Background $text_bg add_option *Text.Foreground $text_fg - add_option *Text.HighlightBackground $base_bg - add_option *Text.HighlightColor $select_bg + add_option *Text.selectBackground $select_bg + add_option *Text.selectForeground $select_fg + add_option *Text.inactiveSelectBackground $inactive_select_bg + add_option *Text.inactiveSelectForeground $inactive_select_fg } } +proc convert_rgb_to_gray {rgb} { + # Simply take the average of red, green and blue. This wouldn't be good + # enough for, say, converting a photo to grayscale, but for this simple + # purpose of approximating the brightness of a color it's good enough. + lassign [winfo rgb . $rgb] r g b + set gray [expr {($r / 256 + $g / 256 + $b / 256) / 3}] + return [format "#%2.2X%2.2X%2.2X" $gray $gray $gray] +} + proc ttk_get_current_theme {} { # Handle either current Tk or older versions of 8.5 if {[catch {set theme [ttk::style theme use]}]} { @@ -174,7 +191,7 @@ proc InitEntryFrame {} { proc gold_frame {w args} { global use_ttk - if {$use_ttk} { + if {$use_ttk && ![is_MacOSX]} { eval [linsert $args 0 ttk::frame $w -style Gold.TFrame] } else { eval [linsert $args 0 frame $w -background gold] @@ -183,7 +200,7 @@ proc gold_frame {w args} { proc tlabel {w args} { global use_ttk - if {$use_ttk} { + if {$use_ttk && ![is_MacOSX]} { set cmd [list ttk::label $w -style Color.TLabel] foreach {k v} $args { switch -glob -- $k { |