feat: add {get|set}AccentColor
on Windows (#47741)
* feat: add setAccentColor on Windows * refactor: unify GetSystemAccentColor * refactor: remove redundant parsing * chore: fixup documentation * Update docs/api/browser-window.md Co-authored-by: Will Anderson <andersonw@dropbox.com> * Update docs/api/base-window.md Co-authored-by: Will Anderson <andersonw@dropbox.com> --------- Co-authored-by: Will Anderson <andersonw@dropbox.com>
This commit is contained in:
parent
2cfccac074
commit
5c98e3609f
13 changed files with 265 additions and 24 deletions
|
@ -1260,6 +1260,43 @@ Sets the properties for the window's taskbar button.
|
|||
> `relaunchCommand` and `relaunchDisplayName` must always be set
|
||||
> together. If one of those properties is not set, then neither will be used.
|
||||
|
||||
#### `win.setAccentColor(accentColor)` _Windows_
|
||||
|
||||
* `accentColor` boolean | string - The accent color for the window. By default, follows user preference in System Settings.
|
||||
|
||||
Sets the system accent color and highlighting of active window border.
|
||||
|
||||
The `accentColor` parameter accepts the following values:
|
||||
|
||||
* **Color string** - Sets a custom accent color using standard CSS color formats (Hex, RGB, RGBA, HSL, HSLA, or named colors). Alpha values in RGBA/HSLA formats are ignored and the color is treated as fully opaque.
|
||||
* **`true`** - Uses the system's default accent color from user preferences in System Settings.
|
||||
* **`false`** - Explicitly disables accent color highlighting for the window.
|
||||
|
||||
Examples:
|
||||
|
||||
```js
|
||||
const win = new BrowserWindow({ frame: false })
|
||||
|
||||
// Set red accent color.
|
||||
win.setAccentColor('#ff0000')
|
||||
|
||||
// RGB format (alpha ignored if present).
|
||||
win.setAccentColor('rgba(255,0,0,0.5)')
|
||||
|
||||
// Use system accent color.
|
||||
win.setAccentColor(true)
|
||||
|
||||
// Disable accent color.
|
||||
win.setAccentColor(false)
|
||||
```
|
||||
|
||||
#### `win.getAccentColor()` _Windows_
|
||||
|
||||
Returns `string | boolean` - the system accent color and highlighting of active window border in Hex RGB format.
|
||||
|
||||
If a color has been set for the window that differs from the system accent color, the window accent color will
|
||||
be returned. Otherwise, a boolean will be returned, with `true` indicating that the window uses the global system accent color, and `false` indicating that accent color highlighting is disabled for this window.
|
||||
|
||||
#### `win.setIcon(icon)` _Windows_ _Linux_
|
||||
|
||||
* `icon` [NativeImage](native-image.md) | string
|
||||
|
|
|
@ -1440,6 +1440,43 @@ Sets the properties for the window's taskbar button.
|
|||
> `relaunchCommand` and `relaunchDisplayName` must always be set
|
||||
> together. If one of those properties is not set, then neither will be used.
|
||||
|
||||
#### `win.setAccentColor(accentColor)` _Windows_
|
||||
|
||||
* `accentColor` boolean | string - The accent color for the window. By default, follows user preference in System Settings.
|
||||
|
||||
Sets the system accent color and highlighting of active window border.
|
||||
|
||||
The `accentColor` parameter accepts the following values:
|
||||
|
||||
* **Color string** - Sets a custom accent color using standard CSS color formats (Hex, RGB, RGBA, HSL, HSLA, or named colors). Alpha values in RGBA/HSLA formats are ignored and the color is treated as fully opaque.
|
||||
* **`true`** - Uses the system's default accent color from user preferences in System Settings.
|
||||
* **`false`** - Explicitly disables accent color highlighting for the window.
|
||||
|
||||
Examples:
|
||||
|
||||
```js
|
||||
const win = new BrowserWindow({ frame: false })
|
||||
|
||||
// Set red accent color.
|
||||
win.setAccentColor('#ff0000')
|
||||
|
||||
// RGB format (alpha ignored if present).
|
||||
win.setAccentColor('rgba(255,0,0,0.5)')
|
||||
|
||||
// Use system accent color.
|
||||
win.setAccentColor(true)
|
||||
|
||||
// Disable accent color.
|
||||
win.setAccentColor(false)
|
||||
```
|
||||
|
||||
#### `win.getAccentColor()` _Windows_
|
||||
|
||||
Returns `string | boolean` - the system accent color and highlighting of active window border in Hex RGB format.
|
||||
|
||||
If a color has been set for the window that differs from the system accent color, the window accent color will
|
||||
be returned. Otherwise, a boolean will be returned, with `true` indicating that the window uses the global system accent color, and `false` indicating that accent color highlighting is disabled for this window.
|
||||
|
||||
#### `win.showDefinitionForSelection()` _macOS_
|
||||
|
||||
Same as `webContents.showDefinitionForSelection()`.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue