Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
michael@0 | 1 | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef nsNativeThemeColors_h_ |
michael@0 | 7 | #define nsNativeThemeColors_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "nsCocoaFeatures.h" |
michael@0 | 10 | #import <Cocoa/Cocoa.h> |
michael@0 | 11 | |
michael@0 | 12 | extern "C" { |
michael@0 | 13 | typedef CFTypeRef CUIRendererRef; |
michael@0 | 14 | void CUIDraw(CUIRendererRef r, CGRect rect, CGContextRef ctx, CFDictionaryRef options, CFDictionaryRef* result); |
michael@0 | 15 | } |
michael@0 | 16 | |
michael@0 | 17 | @interface NSWindow(CoreUIRendererPrivate) |
michael@0 | 18 | + (CUIRendererRef)coreUIRenderer; |
michael@0 | 19 | @end |
michael@0 | 20 | |
michael@0 | 21 | enum ColorName { |
michael@0 | 22 | toolbarTopBorderGrey, |
michael@0 | 23 | toolbarFillGrey, |
michael@0 | 24 | toolbarBottomBorderGrey, |
michael@0 | 25 | }; |
michael@0 | 26 | |
michael@0 | 27 | static const int sSnowLeopardThemeColors[][2] = { |
michael@0 | 28 | /* { active window, inactive window } */ |
michael@0 | 29 | // toolbar: |
michael@0 | 30 | { 0xD0, 0xF1 }, // top separator line |
michael@0 | 31 | { 0xA7, 0xD8 }, // fill color |
michael@0 | 32 | { 0x51, 0x99 }, // bottom separator line |
michael@0 | 33 | }; |
michael@0 | 34 | |
michael@0 | 35 | static const int sLionThemeColors[][2] = { |
michael@0 | 36 | /* { active window, inactive window } */ |
michael@0 | 37 | // toolbar: |
michael@0 | 38 | { 0xD0, 0xF0 }, // top separator line |
michael@0 | 39 | { 0xB2, 0xE1 }, // fill color |
michael@0 | 40 | { 0x59, 0x87 }, // bottom separator line |
michael@0 | 41 | }; |
michael@0 | 42 | |
michael@0 | 43 | __attribute__((unused)) |
michael@0 | 44 | static int NativeGreyColorAsInt(ColorName name, BOOL isMain) |
michael@0 | 45 | { |
michael@0 | 46 | if (nsCocoaFeatures::OnLionOrLater()) |
michael@0 | 47 | return sLionThemeColors[name][isMain ? 0 : 1]; |
michael@0 | 48 | |
michael@0 | 49 | return sSnowLeopardThemeColors[name][isMain ? 0 : 1]; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | __attribute__((unused)) |
michael@0 | 53 | static float NativeGreyColorAsFloat(ColorName name, BOOL isMain) |
michael@0 | 54 | { |
michael@0 | 55 | return NativeGreyColorAsInt(name, isMain) / 255.0f; |
michael@0 | 56 | } |
michael@0 | 57 | |
michael@0 | 58 | __attribute__((unused)) |
michael@0 | 59 | static void DrawNativeGreyColorInRect(CGContextRef context, ColorName name, |
michael@0 | 60 | CGRect rect, BOOL isMain) |
michael@0 | 61 | { |
michael@0 | 62 | float grey = NativeGreyColorAsFloat(name, isMain); |
michael@0 | 63 | CGContextSetRGBFillColor(context, grey, grey, grey, 1.0f); |
michael@0 | 64 | CGContextFillRect(context, rect); |
michael@0 | 65 | } |
michael@0 | 66 | |
michael@0 | 67 | #endif // nsNativeThemeColors_h_ |