Skip to content

Commit

Permalink
Fix menus on X11 and revert Treeview font
Browse files Browse the repository at this point in the history
  • Loading branch information
rdbende committed Dec 4, 2022
1 parent 4135dae commit b93198a
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 6 deletions.
37 changes: 34 additions & 3 deletions sv.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,43 @@ proc config_input_font {w} {
}
}

proc config_menus {w} {
if {[tk windowingsystem] == "x11"} {
set theme [ttk::style theme use]
if {$theme == "sun-valley-dark"} {
$w configure \
-relief solid \
-borderwidth 1 \
-activeborderwidth 0 \
-background "#202020" \
-activebackground "#434343" \
-activeforeground "#fafafa" \
-selectcolor "#fafafa"
} elseif {$theme == "sun-valley-light"} {
$w configure \
-relief solid \
-borderwidth 1 \
-activeborderwidth 0 \
-background "#ebebeb" \
-activebackground "#c4c4c4" \
-activeforeground "#1c1c1c" \
-selectcolor "#1c1c1c"
}

if {[[winfo toplevel $w] cget -menu] != $w} {
if {$theme == "sun-valley-dark"} {
$w configure -borderwidth 0 -background $ttk::theme::sv_dark::theme_colors(-bg)
} elseif {$theme == "sun-valley-light"} {
$w configure -borderwidth 0 -background $ttk::theme::sv_light::theme_colors(-bg)
}
}
}
}

bind TEntry <<ThemeChanged>> {config_input_font %W}
bind TCombobox <<ThemeChanged>> {config_input_font %W}
bind TSpinbox <<ThemeChanged>> {config_input_font %W}

bind Menu <<ThemeChanged>> {config_menus %W}

source [file join [file dirname [info script]] theme light.tcl]
source [file join [file dirname [info script]] theme dark.tcl]
Expand Down Expand Up @@ -60,7 +93,6 @@ proc set_theme {mode} {
ttk::style map . -foreground [list disabled $ttk::theme::sv_dark::theme_colors(-disfg)]

option add *tearOff 0
option add *Menu.selectColor $ttk::theme::sv_dark::theme_colors(-fg)

} elseif {$mode == "light"} {
ttk::style theme use "sun-valley-light"
Expand Down Expand Up @@ -91,6 +123,5 @@ proc set_theme {mode} {
ttk::style map . -foreground [list disabled $ttk::theme::sv_light::theme_colors(-disfg)]

option add *tearOff 0
option add *Menu.selectColor $ttk::theme::sv_light::theme_colors(-fg)
}
}
7 changes: 5 additions & 2 deletions theme/dark.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace eval ttk::theme::sv_dark {
-disfg "#595959"
-selfg "#ffffff"
-selbg "#2f60d8"
-accent "#61cbfc"
-accent "#57c8ff"
}

proc load_images {imgfile} {
Expand Down Expand Up @@ -432,7 +432,10 @@ namespace eval ttk::theme::sv_dark {
] -border 13 -padding {16 14 16 6} -height 32

# Treeview
ttk::style configure Treeview -background $theme_colors(-bg) -rowheight [expr {[font metrics SunValleyBodyFont -linespace] + 4}] -font SunValleyCaptionFont
ttk::style configure Treeview \
-background $theme_colors(-bg) \
-rowheight [expr {[font metrics SunValleyBodyFont -linespace] + 4}] \
-font SunValleyBodyFont
ttk::style map Treeview \
-background [list selected "#292929"] \
-foreground [list selected $theme_colors(-selfg)]
Expand Down
5 changes: 4 additions & 1 deletion theme/light.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,10 @@ namespace eval ttk::theme::sv_light {
] -border 13 -padding {16 14 16 6} -height 32

# Treeview
ttk::style configure Treeview -background $theme_colors(-bg) -rowheight [expr {[font metrics SunValleyBodyFont -linespace] + 4}] -font SunValleyCaptionFont
ttk::style configure Treeview \
-background $theme_colors(-bg) \
-rowheight [expr {[font metrics SunValleyBodyFont -linespace] + 4}] \
-font SunValleyBodyFont
ttk::style map Treeview \
-background [list selected "#e7e7e7"] \
-foreground [list selected "#191919"]
Expand Down

0 comments on commit b93198a

Please sign in to comment.