diff options
| author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-25 21:43:25 +0000 |
|---|---|---|
| committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-25 21:43:25 +0000 |
| commit | e9210915326b600a7efc8aa6d1befba549347fe5 (patch) | |
| tree | 93b86527830652c00a602d1c324b3078257c1372 /chrome/browser/cocoa/gradient_button_cell.mm | |
| parent | f9fc33227ea65b9b199a1fc7cc1055d362e5594a (diff) | |
| download | chromium_src-e9210915326b600a7efc8aa6d1befba549347fe5.zip chromium_src-e9210915326b600a7efc8aa6d1befba549347fe5.tar.gz chromium_src-e9210915326b600a7efc8aa6d1befba549347fe5.tar.bz2 | |
Removal of GTMTheme gradient use. Unthemed incognito windows now are fully drawn as they should be.
BUG=http://crbug.com/35554 ; http://crbug.com/26983
TEST=no visible change in normal mode; themed incognito windows should look almost correct (missing theme header)
Review URL: http://codereview.chromium.org/661097
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40050 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/gradient_button_cell.mm')
| -rw-r--r-- | chrome/browser/cocoa/gradient_button_cell.mm | 56 |
1 files changed, 36 insertions, 20 deletions
diff --git a/chrome/browser/cocoa/gradient_button_cell.mm b/chrome/browser/cocoa/gradient_button_cell.mm index e0c90c6..ae4ab2b 100644 --- a/chrome/browser/cocoa/gradient_button_cell.mm +++ b/chrome/browser/cocoa/gradient_button_cell.mm @@ -2,10 +2,13 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "chrome/browser/cocoa/gradient_button_cell.h" + #include "base/logging.h" #import "base/scoped_nsobject.h" -#include "chrome/browser/cocoa/gradient_button_cell.h" -#import "chrome/browser/cocoa/GTMTheme.h" +#import "chrome/browser/browser_theme_provider.h" +#import "chrome/browser/cocoa/themed_window.h" +#include "grit/theme_resources.h" #import "third_party/GTM/AppKit/GTMNSColor+Luminance.h" @interface GradientButtonCell (Private) @@ -173,7 +176,7 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; } // TODO(viettrungluu): clean up/reorganize. -- (void)drawBorderAndFillForTheme:(GTMTheme*)theme +- (void)drawBorderAndFillForTheme:(ThemeProvider*)themeProvider controlView:(NSView*)controlView innerPath:(NSBezierPath*)innerPath showClickedGradient:(BOOL)showClickedGradient @@ -196,8 +199,10 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; if (!showClickedGradient) hoverAlpha *= 0.6; } else { - backgroundImage = [theme backgroundImageForStyle:GTMThemeStyleToolBarButton - state:YES]; + backgroundImage = + themeProvider ? + themeProvider->GetNSImageNamed(IDR_THEME_BUTTON_BACKGROUND, false) : + nil; useThemeGradient = backgroundImage ? YES : NO; } @@ -228,9 +233,11 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; if (isFlatButton) { clickedGradient = gradient; } else { - clickedGradient = - [theme gradientForStyle:GTMThemeStyleToolBarButtonPressed - state:active]; + clickedGradient = themeProvider ? themeProvider->GetNSGradient( + active ? + BrowserThemeProvider::GRADIENT_TOOLBAR_BUTTON_PRESSED : + BrowserThemeProvider::GRADIENT_TOOLBAR_BUTTON_PRESSED_INACTIVE) : + nil; } [clickedGradient drawInBezierPath:innerPath angle:90.0]; } @@ -263,9 +270,15 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; } // Draw the outer stroke. - NSColor* strokeColor = showClickedGradient ? - [NSColor colorWithCalibratedWhite:0.0 alpha:0.3] : - [theme strokeColorForStyle:GTMThemeStyleToolBarButton state:active]; + NSColor* strokeColor = nil; + if (showClickedGradient) { + strokeColor = [NSColor colorWithCalibratedWhite:0.0 alpha:0.3]; + } else { + strokeColor = themeProvider ? themeProvider->GetNSColor( + active ? BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE : + BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + true) : [NSColor blackColor]; + } [strokeColor setStroke]; [innerPath setLineWidth:1]; @@ -335,17 +348,16 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; BOOL pressed = [self isHighlighted]; NSWindow* window = [controlView window]; + ThemeProvider* themeProvider = [window themeProvider]; BOOL active = [window isKeyWindow] || [window isMainWindow]; - GTMTheme* theme = [controlView gtm_theme]; - // Stroke the borders and appropriate fill gradient. If we're borderless, // the only time we want to draw the inner gradient is if we're highlighted. if (([self isBordered] && ![self showsBorderOnlyWhileMouseInside]) || pressed || [self isMouseInside]) { - [self drawBorderAndFillForTheme:theme + [self drawBorderAndFillForTheme:themeProvider controlView:controlView innerPath:innerPath showClickedGradient:pressed @@ -361,8 +373,11 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; if (type == kLeftButtonWithShadowType) { NSRect borderRect, contentRect; NSDivideRect(cellFrame, &borderRect, &contentRect, 1.0, NSMaxXEdge); - NSColor* stroke = [theme strokeColorForStyle:GTMThemeStyleToolBarButton - state:active]; + NSColor* stroke = themeProvider ? themeProvider->GetNSColor( + active ? BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE : + BrowserThemeProvider::COLOR_TOOLBAR_BUTTON_STROKE_INACTIVE, + true) : [NSColor blackColor]; + [[stroke colorWithAlphaComponent:0.2] set]; NSRectFillUsingOperation(NSInsetRect(borderRect, 0, 2), NSCompositeSourceOver); @@ -371,8 +386,6 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; } - (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView*)controlView { - GTMTheme* theme = [controlView gtm_theme]; - if (shouldTheme_) { BOOL isTemplate = [[self image] isTemplate]; @@ -381,8 +394,11 @@ static const NSTimeInterval kAnimationHideDuration = 0.4; CGContextRef context = (CGContextRef)([[NSGraphicsContext currentContext] graphicsPort]); - NSColor* color = [theme iconColorForStyle:GTMThemeStyleToolBarButton - state:YES]; + ThemeProvider* themeProvider = [[controlView window] themeProvider]; + NSColor* color = themeProvider ? + themeProvider->GetNSColorTint(BrowserThemeProvider::TINT_BUTTONS, + true) : + [NSColor blackColor]; if (isTemplate) { scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); |
