| 8 | ) |
| 9 | |
| 10 | func (w *Window) UpdateTheme() { |
| 11 | |
| 12 | // Don't redraw theme if nothing has changed |
| 13 | if !w.themeChanged { |
| 14 | return |
| 15 | } |
| 16 | w.themeChanged = false |
| 17 | |
| 18 | if win32.IsCurrentlyHighContrastMode() { |
| 19 | return |
| 20 | } |
| 21 | |
| 22 | if !win32.SupportsThemes() { |
| 23 | return |
| 24 | } |
| 25 | |
| 26 | var isDarkMode bool |
| 27 | switch w.theme { |
| 28 | case windows.SystemDefault: |
| 29 | isDarkMode = win32.IsCurrentlyDarkMode() |
| 30 | case windows.Dark: |
| 31 | isDarkMode = true |
| 32 | case windows.Light: |
| 33 | isDarkMode = false |
| 34 | } |
| 35 | win32.SetTheme(w.Handle(), isDarkMode) |
| 36 | |
| 37 | // Custom theme processing |
| 38 | winOptions := w.frontendOptions.Windows |
| 39 | var customTheme *windows.ThemeSettings |
| 40 | if winOptions != nil { |
| 41 | customTheme = winOptions.CustomTheme |
| 42 | } |
| 43 | // Custom theme |
| 44 | if win32.SupportsCustomThemes() && customTheme != nil { |
| 45 | if w.isActive { |
| 46 | if isDarkMode { |
| 47 | win32.SetTitleBarColour(w.Handle(), customTheme.DarkModeTitleBar) |
| 48 | win32.SetTitleTextColour(w.Handle(), customTheme.DarkModeTitleText) |
| 49 | win32.SetBorderColour(w.Handle(), customTheme.DarkModeBorder) |
| 50 | } else { |
| 51 | win32.SetTitleBarColour(w.Handle(), customTheme.LightModeTitleBar) |
| 52 | win32.SetTitleTextColour(w.Handle(), customTheme.LightModeTitleText) |
| 53 | win32.SetBorderColour(w.Handle(), customTheme.LightModeBorder) |
| 54 | } |
| 55 | } else { |
| 56 | if isDarkMode { |
| 57 | win32.SetTitleBarColour(w.Handle(), customTheme.DarkModeTitleBarInactive) |
| 58 | win32.SetTitleTextColour(w.Handle(), customTheme.DarkModeTitleTextInactive) |
| 59 | win32.SetBorderColour(w.Handle(), customTheme.DarkModeBorderInactive) |
| 60 | } else { |
| 61 | win32.SetTitleBarColour(w.Handle(), customTheme.LightModeTitleBarInactive) |
| 62 | win32.SetTitleTextColour(w.Handle(), customTheme.LightModeTitleTextInactive) |
| 63 | win32.SetBorderColour(w.Handle(), customTheme.LightModeBorderInactive) |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | } |