Bug 449833 - Need a platform color for chrome background on Mac OS X. r=josh, sr=roc.

This commit is contained in:
Markus Stange 2008-08-27 18:07:36 +02:00
Родитель 008015242b
Коммит 89f9b4f8ce
8 изменённых файлов: 92 добавлений и 19 удалений

Просмотреть файл

@ -139,6 +139,8 @@ CSS_KEY(-moz-mac-accentlightshadow, _moz_mac_accentlightshadow)
CSS_KEY(-moz-mac-accentregularhighlight, _moz_mac_accentregularhighlight)
CSS_KEY(-moz-mac-accentregularshadow, _moz_mac_accentregularshadow)
CSS_KEY(-moz-mac-alternateprimaryhighlight, _moz_mac_alternateprimaryhighlight)
CSS_KEY(-moz-mac-chrome-active, _moz_mac_chrome_active)
CSS_KEY(-moz-mac-chrome-inactive, _moz_mac_chrome_inactive)
CSS_KEY(-moz-mac-focusring, _moz_mac_focusring)
CSS_KEY(-moz-mac-menuselect, _moz_mac_menuselect)
CSS_KEY(-moz-mac-menushadow, _moz_mac_menushadow)

Просмотреть файл

@ -513,6 +513,8 @@ const PRInt32 nsCSSProps::kColorKTable[] = {
eCSSKeyword__moz_hyperlinktext, NS_COLOR_MOZ_HYPERLINKTEXT,
eCSSKeyword__moz_html_cellhighlight, nsILookAndFeel::eColor__moz_html_cellhighlight,
eCSSKeyword__moz_html_cellhighlighttext, nsILookAndFeel::eColor__moz_html_cellhighlighttext,
eCSSKeyword__moz_mac_chrome_active, nsILookAndFeel::eColor__moz_mac_chrome_active,
eCSSKeyword__moz_mac_chrome_inactive, nsILookAndFeel::eColor__moz_mac_chrome_inactive,
eCSSKeyword__moz_mac_focusring, nsILookAndFeel::eColor__moz_mac_focusring,
eCSSKeyword__moz_mac_menuselect, nsILookAndFeel::eColor__moz_mac_menuselect,
eCSSKeyword__moz_mac_menushadow, nsILookAndFeel::eColor__moz_mac_menushadow,

Просмотреть файл

@ -142,7 +142,9 @@ public:
eColor__moz_eventreerow,
eColor__moz_oddtreerow,
//colours needed by Mac Classic skin
// colors needed by the Mac OS X theme
eColor__moz_mac_chrome_active, // background color of chrome toolbars in active windows
eColor__moz_mac_chrome_inactive, // background color of chrome toolbars in inactive windows
eColor__moz_mac_focusring, //ring around text fields and lists
eColor__moz_mac_menuselect, //colour used when mouse is over a menu item
eColor__moz_mac_menushadow, //colour used to do shadows on menu items

Просмотреть файл

@ -47,6 +47,7 @@
#include "nsBaseWidget.h"
#include "nsPIWidgetCocoa.h"
#include "nsAutoPtr.h"
#include "nsNativeThemeColors.h"
class nsCocoaWindow;
class nsChildView;
@ -118,16 +119,6 @@ typedef struct _nsCocoaWindowList {
- (void)sendToplevelDeactivateEvents;
@end
// These are the start and end greys for the unified titlebar and toolbar gradient.
static const float sLeopardHeaderStartGrey = 197/255.0f;
static const float sLeopardHeaderEndGrey = 150/255.0f;
static const float sLeopardHeaderBackgroundStartGrey = 233/255.0f;
static const float sLeopardHeaderBackgroundEndGrey = 207/255.0f;
// This is the grey for the border at the bottom of the titlebar / toolbar.
static const float sLeopardTitlebarBorderGrey = 64/255.0f;
static const float sLeopardTitlebarBackgroundBorderGrey = 135/255.0f;
struct UnifiedGradientInfo {
float titlebarHeight;
float toolbarHeight;
@ -142,8 +133,8 @@ static void unifiedShading(void* aInfo, const float* aIn, float* aOut)
UnifiedGradientInfo* info = (UnifiedGradientInfo*)aInfo;
// The gradient percentage at the bottom of the titlebar / top of the toolbar
float start = info->titlebarHeight / (info->titlebarHeight + info->toolbarHeight - 1);
const float startGrey = info->windowIsMain ? sLeopardHeaderStartGrey : sLeopardHeaderBackgroundStartGrey;
const float endGrey = info->windowIsMain ? sLeopardHeaderEndGrey : sLeopardHeaderBackgroundEndGrey;
const float startGrey = NativeGreyColorAsFloat(headerStartGrey, info->windowIsMain);
const float endGrey = NativeGreyColorAsFloat(headerEndGrey, info->windowIsMain);
// *aIn is the gradient percentage of the titlebar or toolbar gradient,
// a is the gradient percentage of the whole unified gradient.
float a = info->drawTitlebar ? *aIn * start : start + *aIn * (1 - start);

Просмотреть файл

@ -1951,9 +1951,7 @@ void patternDraw(void* aInfo, CGContextRef aContext)
// Draw the one pixel border at the bottom of the titlebar.
if ([window unifiedToolbarHeight] == 0) {
float borderGrey = isMain ? sLeopardTitlebarBorderGrey :
sLeopardTitlebarBackgroundBorderGrey;
[[NSColor colorWithDeviceWhite:borderGrey alpha:1.0f] set];
[NativeGreyColorAsNSColor(headerBorderGrey, isMain) set];
NSRectFill(NSMakeRect(0.0f, titlebarOrigin, sPatternWidth, 1.0f));
}
} else {

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsObjCExceptions.h"
#include "nsIInternetConfigService.h"
#include "nsIServiceManager.h"
#include "nsNativeThemeColors.h"
#import <Carbon/Carbon.h>
@ -285,6 +286,12 @@ nsresult nsLookAndFeel::NativeGetColor(const nsColorID aID, nscolor &aColor)
//default to lavender if not available
res = GetMacBrushColor(kThemeBrushDragHilite, aColor, NS_RGB(0x63,0x63,0xCE));
break;
case eColor__moz_mac_chrome_active:
case eColor__moz_mac_chrome_inactive: {
int grey = NativeGreyColorAsInt(headerEndGrey, (aID == eColor__moz_mac_chrome_active));
aColor = NS_RGB(grey, grey, grey);
}
break;
case eColor__moz_mac_focusring:
//default to lavender if not available
res = GetMacBrushColor(kThemeBrushFocusHighlight, aColor, NS_RGB(0x63,0x63,0xCE));

Просмотреть файл

@ -1035,9 +1035,7 @@ nsNativeThemeCocoa::DrawUnifiedToolbar(CGContextRef cgContext, const HIRect& inB
CGShadingRelease(shading);
// Draw the border at the bottom of the toolbar.
float borderGrey = isMain ? sLeopardTitlebarBorderGrey :
sLeopardTitlebarBackgroundBorderGrey;
[[NSColor colorWithDeviceWhite:borderGrey alpha:1.0f] set];
[NativeGreyColorAsNSColor(headerBorderGrey, isMain) set];
NSRectFill(NSMakeRect(inBoxRect.origin.x, inBoxRect.origin.y +
inBoxRect.size.height - 1.0f, inBoxRect.size.width, 1.0f));

Просмотреть файл

@ -0,0 +1,73 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is mozilla.org code.
*
* The Initial Developer of the Original Code is
* Markus Stange.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef nsNativeThemeColors_h_
#define nsNativeThemeColors_h_
#import <Cocoa/Cocoa.h>
enum ColorName {
headerStartGrey,
headerEndGrey,
headerBorderGrey
};
static const int sLeopardThemeColors[][2] = {
/* { active window, inactive window } */
// unified titlebar and toolbar gradient:
{ 0xC5, 0xE9 }, // start grey
{ 0x96, 0xCA }, // end grey
{ 0x42, 0x89 } // separator line
};
static int NativeGreyColorAsInt(ColorName name, BOOL isMain)
{
return sLeopardThemeColors[name][isMain ? 0 : 1];
}
static float NativeGreyColorAsFloat(ColorName name, BOOL isMain)
{
return NativeGreyColorAsInt(name, isMain) / 255.0f;
}
static NSColor* NativeGreyColorAsNSColor(ColorName name, BOOL isMain)
{
return [NSColor colorWithDeviceWhite:NativeGreyColorAsFloat(name, isMain) alpha:1.0f];
}
#endif // nsNativeThemeColors_h_