1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* This Source Code Form is subject to the terms of the Mozilla Public
3 * License, v. 2.0. If a copy of the MPL was not distributed with this
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 #ifndef nsNativeThemeColors_h_
7 #define nsNativeThemeColors_h_
9 #include "nsCocoaFeatures.h"
10 #import <Cocoa/Cocoa.h>
15 toolbarBottomBorderGrey
,
18 static const int sLionThemeColors
[][2] = {
19 /* { active window, inactive window } */
21 {0xD0, 0xF0}, // top separator line
22 {0xB2, 0xE1}, // fill color
23 {0x59, 0x87}, // bottom separator line
26 static const int sYosemiteThemeColors
[][2] = {
27 /* { active window, inactive window } */
29 {0xBD, 0xDF}, // top separator line
30 {0xD3, 0xF6}, // fill color
31 {0xB3, 0xD1}, // bottom separator line
34 inline int NativeGreyColorAsInt(ColorName name
, BOOL isMain
) {
35 if (nsCocoaFeatures::OnYosemiteOrLater()) return sYosemiteThemeColors
[name
][isMain
? 0 : 1];
36 return sLionThemeColors
[name
][isMain
? 0 : 1];
39 inline float NativeGreyColorAsFloat(ColorName name
, BOOL isMain
) {
40 return NativeGreyColorAsInt(name
, isMain
) / 255.0f
;
43 inline void DrawNativeGreyColorInRect(CGContextRef context
, ColorName name
, CGRect rect
,
45 float grey
= NativeGreyColorAsFloat(name
, isMain
);
46 CGContextSetRGBFillColor(context
, grey
, grey
, grey
, 1.0f
);
47 CGContextFillRect(context
, rect
);
50 #if !defined(MAC_OS_X_VERSION_10_14) || MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_14
51 @interface
NSColor (NSColorControlAccentColor
)
52 @
property(class, strong
, readonly
) NSColor
* controlAccentColor
NS_AVAILABLE_MAC(10_14
);
56 inline NSColor
* ControlAccentColor() {
57 if (@
available(macOS
10.14, *)) {
58 return [NSColor controlAccentColor
];
61 // Pre-10.14, use hardcoded colors.
62 return [NSColor currentControlTint
] == NSGraphiteControlTint
63 ? [NSColor colorWithSRGBRed
:0.635 green
:0.635 blue
:0.655 alpha
:1.0]
64 : [NSColor colorWithSRGBRed
:0.247 green
:0.584 blue
:0.965 alpha
:1.0];
67 #endif // nsNativeThemeColors_h_