mirror of
https://github.com/electron/electron.git
synced 2026-04-10 03:01:51 -04:00
feat: add nativeTheme.shouldDifferentiateWithoutColor on macOS Adds nativeTheme.shouldDifferentiateWithoutColor on macOS that maps to NSWorkspace.accessibilityDisplayShouldDifferentiateWithoutColor. If true, the user has indicated that they prefer UI that differentiates items with something other than color alone. This is useful for users with color vision deficiency. Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Robert Böhnke <robb@robb.is>
35 lines
1.1 KiB
Plaintext
35 lines
1.1 KiB
Plaintext
// Copyright (c) 2019 Slack Technologies, Inc.
|
|
// Use of this source code is governed by the MIT license that can be
|
|
// found in the LICENSE file.
|
|
|
|
#include "shell/browser/api/electron_api_native_theme.h"
|
|
|
|
#include "shell/browser/mac/electron_application.h"
|
|
|
|
namespace electron::api {
|
|
|
|
void NativeTheme::UpdateMacOSAppearanceForOverrideValue(
|
|
ui::NativeTheme::ThemeSource override) {
|
|
NSAppearance* new_appearance;
|
|
switch (override) {
|
|
case ui::NativeTheme::ThemeSource::kForcedDark:
|
|
new_appearance = [NSAppearance appearanceNamed:NSAppearanceNameDarkAqua];
|
|
break;
|
|
case ui::NativeTheme::ThemeSource::kForcedLight:
|
|
new_appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua];
|
|
break;
|
|
case ui::NativeTheme::ThemeSource::kSystem:
|
|
default:
|
|
new_appearance = nil;
|
|
break;
|
|
}
|
|
[[NSApplication sharedApplication] setAppearance:new_appearance];
|
|
}
|
|
|
|
bool NativeTheme::ShouldDifferentiateWithoutColor() {
|
|
return [[NSWorkspace sharedWorkspace]
|
|
accessibilityDisplayShouldDifferentiateWithoutColor];
|
|
}
|
|
|
|
} // namespace electron::api
|