|
4 | 4 |
|
5 | 5 | namespace eval color {
|
6 | 6 | # Variable colors
|
7 |
| - # Preffered way to set widget colors is using add_option. |
8 |
| - # In some cases, like with tags in_diff/in_sel, we use these colors. |
9 |
| - variable select_bg lightgray |
10 |
| - variable select_fg black |
11 |
| - variable inactive_select_bg lightgray |
12 |
| - variable inactive_select_fg black |
| 7 | + # Preferred way to set widget colors is using add_option. |
| 8 | + # These variables are used by set_selection_colors. |
| 9 | + variable select_bg #242470 |
| 10 | + variable select_fg #f0f0f0 |
| 11 | + variable inactive_select_bg #404080 |
| 12 | + variable inactive_select_fg #f0f0f0 |
13 | 13 |
|
14 | 14 | proc sync_with_theme {} {
|
15 |
| - set base_bg [ttk::style lookup . -background] |
16 |
| - set base_fg [ttk::style lookup . -foreground] |
17 |
| - set text_bg [ttk::style lookup Treeview -background] |
18 |
| - set text_fg [ttk::style lookup Treeview -foreground] |
19 |
| - set select_bg [ttk::style lookup Default -selectbackground] |
20 |
| - set select_fg [ttk::style lookup Default -selectforeground] |
21 |
| - set inactive_select_bg [convert_rgb_to_gray $select_bg] |
22 |
| - set inactive_select_fg $select_fg |
23 |
| - |
24 |
| - set color::select_bg $select_bg |
25 |
| - set color::select_fg $select_fg |
26 |
| - set color::inactive_select_bg $inactive_select_bg |
27 |
| - set color::inactive_select_fg $inactive_select_fg |
| 15 | + # TODO: only override these if a dark-mode setting is in effect. |
| 16 | + |
| 17 | + set darkest #101010 |
| 18 | + set darker #242424 |
| 19 | + set dark #303030 |
| 20 | + set darkish #404040 |
| 21 | + set lightish #484848 |
| 22 | + set light #585858 |
| 23 | + set lighter #686868 |
| 24 | + set lightest #808080 |
| 25 | + set white #e0e0e0 |
| 26 | + set whiter #f0f0f0 |
| 27 | + set whitest #ffffff |
| 28 | + |
| 29 | + set scale 18 |
| 30 | + |
| 31 | + set base_bg $dark |
| 32 | + set unfocused $base_bg |
| 33 | + set focused $whiter |
| 34 | + |
| 35 | + set text_bg $darker |
| 36 | + set text_fg $white |
| 37 | + set text_disabled $light |
| 38 | + set text_highlight $whitest |
| 39 | + |
| 40 | + set menu_bg $text_bg |
| 41 | + set menu_fg $text_fg |
| 42 | + set menu_select_bg $darkish |
| 43 | + set menu_select_fg $text_highlight |
| 44 | + |
| 45 | + set field_bg $lightish |
| 46 | + set field_fg $whiter |
| 47 | + |
| 48 | + set control_resting $lighter |
| 49 | + set control_active $lightest |
| 50 | + set control_disabled $darkest |
| 51 | + set control_readonly $dark |
| 52 | + set control_border $base_bg |
| 53 | + |
| 54 | + set button_bg $darker |
| 55 | + set button_text $text_fg |
| 56 | + set button_text_disabled $lightest |
| 57 | + set button_text_active $text_highlight |
| 58 | + |
| 59 | + set indicator_color $darkish |
| 60 | + set indicator_active $control_active |
| 61 | + |
| 62 | + set scroll_resting $control_resting |
| 63 | + set scroll_active $control_active |
| 64 | + set scroll_disabled $control_disabled |
| 65 | + set scroll_border $control_border |
| 66 | + set scroll_trough $dark |
| 67 | + set scroll_arrow $whiter |
| 68 | + |
| 69 | + set arrow_size $scale |
| 70 | + |
| 71 | + ttk::style theme use alt |
| 72 | + |
| 73 | + ttk::style configure TFrame -background $base_bg \ |
| 74 | + -highlightthickness 1 -highlightcolor $focused -highlightbackground $unfocused |
| 75 | + |
| 76 | + ttk::style configure TLabel -background $base_bg -foreground $text_fg \ |
| 77 | + -highlightthickness 1 -highlightcolor $focused -highlightbackground $unfocused |
| 78 | + ttk::style configure TLabelframe -background $base_bg |
| 79 | + ttk::style configure TLabelframe.Label -background $base_bg -foreground $text_highlight |
| 80 | + |
| 81 | + ttk::style configure TPanedwindow -background $base_bg -foreground $text_fg \ |
| 82 | + -highlightthickness 1 -highlightcolor $focused -highlightbackground $unfocused |
| 83 | + |
| 84 | + ttk::style configure TScrollbar -background $scroll_resting -bordercolor $scroll_border \ |
| 85 | + -troughcolor $scroll_trough -arrowcolor $scroll_arrow -arrowsize $arrow_size |
| 86 | + ttk::style map TScrollbar -background [list active $scroll_active disabled $scroll_disabled] |
| 87 | + |
| 88 | + ttk::style configure TButton -background $button_bg -foreground $button_text -borderwidth 3 -bordercolor $control_border \ |
| 89 | + -highlightthickness 1 -highlightcolor $focused -highlightbackground $unfocused |
| 90 | + ttk::style map TButton -background [list active $control_active disabled $control_disabled readonly $control_readonly] |
| 91 | + ttk::style map TButton -foreground [list active $button_text_active disabled $button_text_disabled readonly $button_text] |
| 92 | + |
| 93 | + ttk::style configure TEntry -fieldbackground $field_bg -background $base_bg -foreground $field_fg \ |
| 94 | + -selectbackground $color::select_bg -selectforeground $color::select_fg \ |
| 95 | + -highlightthickness 1 -highlightcolor $focused -highlightbackground $unfocused |
| 96 | + ttk::style configure EntryFrame -background $control_border \ |
| 97 | + -highlightthickness 1 -highlightcolor $focused -highlightbackground $unfocused |
| 98 | + |
| 99 | + ttk::style configure TSpinbox -selectbackground $color::select_bg -selectforeground $color::select_fg \ |
| 100 | + -fieldbackground $field_bg -arrowcolor $scroll_arrow -arrowsize $arrow_size \ |
| 101 | + -highlightthickness 1 -highlightcolor $focused -highlightbackground $unfocused \ |
| 102 | + .vpane.lower.commarea.buffer.frame.t configure -background $base_bg -foreground $text_fg \ |
| 103 | + .vpane.lower.diff.body.t configure -background $base_bg -foreground $button_text \ |
| 104 | + .vpane.files.workdir.list configure -background $base_bg -foreground $button_text \ |
| 105 | + .vpane.files.index.list configure -background $base_bg -foreground $button_text \ |
| 106 | + .about_dialog.git_logo configure -background $base_bg -foreground $button_text |
| 107 | + ttk::style map TSpinbox -background [list active $control_active disabled $base_bg readonly $control_readonly] |
| 108 | + ttk::style map TCheckbutton -foreground [list active $text_highlight disabled $text_disabled readonly $text_fg] |
| 109 | + |
| 110 | + ttk::style configure TCombobox -selectbackground $color::select_bg -selectforeground $color::select_fg \ |
| 111 | + -foreground $field_fg -arrowcolor $scroll_arrow -arrowsize $arrow_size \ |
| 112 | + -highlightthickness 1 -highlightcolor $focused -highlightbackground $unfocused |
| 113 | + ttk::style map TCombobox -background [list active $control_active disabled $base_bg readonly $control_readonly] |
| 114 | + ttk::style map TCombobox -fieldbackground [list active $field_bg disabled $field_bg readonly $field_bg] |
| 115 | + |
| 116 | + ttk::style configure TCheckbutton -background $base_bg -foreground $button_text -indicatorcolor $indicator_color \ |
| 117 | + -highlightthickness 1 -highlightcolor $focused -highlightbackground $unfocused |
| 118 | + ttk::style map TCheckbutton -background [list active $control_active disabled $base_bg readonly $control_readonly] |
| 119 | + ttk::style map TCheckbutton -foreground [list active $text_highlight disabled $text_disabled readonly $text_fg] |
| 120 | + |
| 121 | + ttk::style configure TRadiobutton -background $base_bg -foreground $button_text -indicatorcolor $indicator_color \ |
| 122 | + -highlightthickness 1 -highlightcolor $focused -highlightbackground $unfocused |
| 123 | + ttk::style map TRadiobutton -background [list active $control_active disabled $base_bg readonly $control_readonly] |
| 124 | + ttk::style map TRadiobutton -foreground [list active $text_highlight disabled $text_disabled readonly $text_fg] |
28 | 125 |
|
29 | 126 | proc add_option {key val} {
|
30 | 127 | option add $key $val widgetDefault
|
31 | 128 | }
|
| 129 | + |
32 | 130 | # Add options for plain Tk widgets
|
33 | 131 | # Using `option add` instead of tk_setPalette to avoid unintended
|
34 | 132 | # consequences.
|
35 | 133 | if {![is_MacOSX]} {
|
36 |
| - add_option *Menu.Background $base_bg |
37 |
| - add_option *Menu.Foreground $base_fg |
38 |
| - add_option *Menu.activeBackground $select_bg |
39 |
| - add_option *Menu.activeForeground $select_fg |
| 134 | + add_option *Menu.Background $menu_bg |
| 135 | + add_option *Menu.Foreground $menu_fg |
| 136 | + add_option *Menu.activeBackground $menu_select_bg |
| 137 | + add_option *Menu.activeForeground $menu_select_fg |
40 | 138 | }
|
41 | 139 | add_option *Text.Background $text_bg
|
42 | 140 | add_option *Text.Foreground $text_fg
|
43 |
| - add_option *Text.selectBackground $select_bg |
44 |
| - add_option *Text.selectForeground $select_fg |
45 |
| - add_option *Text.inactiveSelectBackground $inactive_select_bg |
46 |
| - add_option *Text.inactiveSelectForeground $inactive_select_fg |
| 141 | + add_option *Text.selectBackground $color::select_bg |
| 142 | + add_option *Text.selectForeground $color::select_fg |
| 143 | + add_option *Text.inactiveSelectBackground $color::inactive_select_bg |
| 144 | + add_option *Text.inactiveSelectForeground $color::inactive_select_fg |
| 145 | + |
| 146 | + add_option *Listbox.Background $field_bg |
| 147 | + add_option *Listbox.Foreground $field_fg |
| 148 | + |
| 149 | + add_option *TCombobox*Listbox.background $field_bg |
| 150 | + add_option *TCombobox*Listbox.foreground $field_fg |
| 151 | + add_option *TCombobox*Listbox.selectBackground $color::select_bg |
| 152 | + add_option *TCombobox*Listbox.selectForeground $color::select_fg |
47 | 153 | }
|
48 | 154 | }
|
49 | 155 |
|
|
0 commit comments