widget/cocoa/nsNativeThemeColors.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/widget/cocoa/nsNativeThemeColors.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,67 @@
     1.4 +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef nsNativeThemeColors_h_
    1.10 +#define nsNativeThemeColors_h_
    1.11 +
    1.12 +#include "nsCocoaFeatures.h"
    1.13 +#import <Cocoa/Cocoa.h>
    1.14 +
    1.15 +extern "C" {
    1.16 +  typedef CFTypeRef CUIRendererRef;
    1.17 +  void CUIDraw(CUIRendererRef r, CGRect rect, CGContextRef ctx, CFDictionaryRef options, CFDictionaryRef* result);
    1.18 +}
    1.19 +
    1.20 +@interface NSWindow(CoreUIRendererPrivate)
    1.21 ++ (CUIRendererRef)coreUIRenderer;
    1.22 +@end
    1.23 +
    1.24 +enum ColorName {
    1.25 +  toolbarTopBorderGrey,
    1.26 +  toolbarFillGrey,
    1.27 +  toolbarBottomBorderGrey,
    1.28 +};
    1.29 +
    1.30 +static const int sSnowLeopardThemeColors[][2] = {
    1.31 +  /* { active window, inactive window } */
    1.32 +  // toolbar:
    1.33 +  { 0xD0, 0xF1 }, // top separator line
    1.34 +  { 0xA7, 0xD8 }, // fill color
    1.35 +  { 0x51, 0x99 }, // bottom separator line
    1.36 +};
    1.37 +
    1.38 +static const int sLionThemeColors[][2] = {
    1.39 +  /* { active window, inactive window } */
    1.40 +  // toolbar:
    1.41 +  { 0xD0, 0xF0 }, // top separator line
    1.42 +  { 0xB2, 0xE1 }, // fill color
    1.43 +  { 0x59, 0x87 }, // bottom separator line
    1.44 +};
    1.45 +
    1.46 +__attribute__((unused))
    1.47 +static int NativeGreyColorAsInt(ColorName name, BOOL isMain)
    1.48 +{
    1.49 +  if (nsCocoaFeatures::OnLionOrLater())
    1.50 +    return sLionThemeColors[name][isMain ? 0 : 1];
    1.51 +
    1.52 +  return sSnowLeopardThemeColors[name][isMain ? 0 : 1];
    1.53 +}
    1.54 +
    1.55 +__attribute__((unused))
    1.56 +static float NativeGreyColorAsFloat(ColorName name, BOOL isMain)
    1.57 +{
    1.58 +  return NativeGreyColorAsInt(name, isMain) / 255.0f;
    1.59 +}
    1.60 +
    1.61 +__attribute__((unused))
    1.62 +static void DrawNativeGreyColorInRect(CGContextRef context, ColorName name,
    1.63 +                                      CGRect rect, BOOL isMain)
    1.64 +{
    1.65 +  float grey = NativeGreyColorAsFloat(name, isMain);
    1.66 +  CGContextSetRGBFillColor(context, grey, grey, grey, 1.0f);
    1.67 +  CGContextFillRect(context, rect);
    1.68 +}
    1.69 +
    1.70 +#endif // nsNativeThemeColors_h_

mercurial