mirror of
https://github.com/wavetermdev/wails.git
synced 2026-08-05 13:53:43 -07:00
[Feature/1149] Dark mode (#1281)
* Add Windows version helper * Initial theme support * Support custom themes * Update docs * Honour HighContrast theme. Remove import "C". Refactor * Small refactor * Support inactive theme * Update Docs
This commit is contained in:
@@ -47,6 +47,15 @@ func main() {
|
||||
DisableWindowIcon: false,
|
||||
DisableFramelessWindowDecorations: false,
|
||||
WebviewUserDataPath: "",
|
||||
Theme: windows.SystemDefault,
|
||||
CustomTheme: &windows.ThemeSettings{
|
||||
DarkModeTitleBar: windows.RGB(20, 20, 20),
|
||||
DarkModeTitleText: windows.RGB(200, 200, 200),
|
||||
DarkModeBorder: windows.RGB(20, 0, 20),
|
||||
LightModeTitleBar: windows.RGB(200, 200, 200),
|
||||
LightModeTitleText: windows.RGB(20, 20, 20),
|
||||
LightModeBorder: windows.RGB(200, 200, 200),
|
||||
},
|
||||
},
|
||||
Mac: &mac.Options{
|
||||
TitleBar: &mac.TitleBar{
|
||||
@@ -375,6 +384,78 @@ Type: string
|
||||
|
||||
This defines the path where the WebView2 stores the user data. If empty `%APPDATA%\[BinaryName.exe]` will be used.
|
||||
|
||||
### Theme
|
||||
|
||||
Name: Theme
|
||||
|
||||
Type: `windows.Theme`
|
||||
|
||||
Minimum Windows Version: Windows 10 2004/20H1
|
||||
|
||||
This defines the theme that the application should use:
|
||||
|
||||
| Value | Description |
|
||||
| --------------- | ----------- |
|
||||
| SystemDefault | *Default*. The theme will be based on the system default. If the user changes their theme, the application will update to use the new setting |
|
||||
| Dark | The application will use a dark theme exclusively |
|
||||
| Light | The application will use a light theme exclusively |
|
||||
|
||||
|
||||
### CustomTheme
|
||||
|
||||
Name: CustomTheme
|
||||
|
||||
Type: `windows.CustomTheme`
|
||||
|
||||
Minimum Windows Version: Windows 10/11 2009/21H2 Build 22000
|
||||
|
||||
Allows you to specify custom colours for TitleBar, TitleText and Border for both light and dark mode, as well as
|
||||
when the window is active or inactive.
|
||||
|
||||
#### CustomTheme
|
||||
|
||||
The CustomTheme struct uses `int32` to specify the colour values. These are in the standard(!) Windows format of:
|
||||
`0x00BBGGAA`. A helper function is provided to do RGB conversions into this format: `windows.RGB(r,g,b uint8)`.
|
||||
|
||||
NOTE: Any value not provided will default to black.
|
||||
|
||||
```go
|
||||
type ThemeSettings struct {
|
||||
DarkModeTitleBar int32
|
||||
DarkModeTitleBarInactive int32
|
||||
DarkModeTitleText int32
|
||||
DarkModeTitleTextInactive int32
|
||||
DarkModeBorder int32
|
||||
DarkModeBorderInactive int32
|
||||
LightModeTitleBar int32
|
||||
LightModeTitleBarInactive int32
|
||||
LightModeTitleText int32
|
||||
LightModeTitleTextInactive int32
|
||||
LightModeBorder int32
|
||||
LightModeBorderInactive int32
|
||||
}
|
||||
```
|
||||
|
||||
Example:
|
||||
```go
|
||||
CustomTheme: &windows.ThemeSettings{
|
||||
// Theme to use when window is active
|
||||
DarkModeTitleBar: windows.RGB(255, 0, 0), // Red
|
||||
DarkModeTitleText: windows.RGB(0, 255, 0), // Green
|
||||
DarkModeBorder: windows.RGB(0, 0, 255), // Blue
|
||||
LightModeTitleBar: windows.RGB(200, 200, 200),
|
||||
LightModeTitleText: windows.RGB(20, 20, 20),
|
||||
LightModeBorder: windows.RGB(200, 200, 200),
|
||||
// Theme to use when window is inactive
|
||||
DarkModeTitleBarInactive: windows.RGB(128, 0, 0),
|
||||
DarkModeTitleTextInactive: windows.RGB(0, 128, 0),
|
||||
DarkModeBorderInactive: windows.RGB(0, 0, 128),
|
||||
LightModeTitleBarInactive: windows.RGB(100, 100, 100),
|
||||
LightModeTitleTextInactive: windows.RGB(10, 10, 10),
|
||||
LightModeBorderInactive: windows.RGB(100, 100, 100),
|
||||
},
|
||||
```
|
||||
|
||||
## Mac Specific Options
|
||||
|
||||
### TitleBar
|
||||
|
||||
Reference in New Issue
Block a user