| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/cocoa/background_gradient_view.h" | 5 #include "chrome/browser/cocoa/background_gradient_view.h" |
| 6 | 6 |
| 7 #define kToolbarTopOffset 12 | 7 #define kToolbarTopOffset 12 |
| 8 #define kToolbarMaxHeight 128 | 8 #define kToolbarMaxHeight 128 |
| 9 | 9 |
| 10 @implementation BackgroundGradientView | 10 @implementation BackgroundGradientView |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 NSPoint phase = [self patternPhase]; | 45 NSPoint phase = [self patternPhase]; |
| 46 [[NSGraphicsContext currentContext] setPatternPhase:phase]; | 46 [[NSGraphicsContext currentContext] setPatternPhase:phase]; |
| 47 | 47 |
| 48 NSColor *color = [NSColor colorWithPatternImage:backgroundImage]; | 48 NSColor *color = [NSColor colorWithPatternImage:backgroundImage]; |
| 49 [color set]; | 49 [color set]; |
| 50 NSRectFill([self bounds]); | 50 NSRectFill([self bounds]); |
| 51 } else { | 51 } else { |
| 52 CGFloat winHeight = NSHeight([[self window] frame]); | 52 CGFloat winHeight = NSHeight([[self window] frame]); |
| 53 NSGradient *gradient = [theme gradientForStyle:GTMThemeStyleToolBar | 53 NSGradient *gradient = [theme gradientForStyle:GTMThemeStyleToolBar |
| 54 state:isKey]; | 54 state:isKey]; |
| 55 NSPoint startPoint = [self convertPointFromBase: | 55 NSPoint startPoint = |
| 56 NSMakePoint(0, winHeight - kToolbarTopOffset)]; | 56 [self convertPoint:NSMakePoint(0, winHeight - kToolbarTopOffset) |
| 57 NSPoint endPoint = [self convertPointFromBase: | 57 fromView:nil]; |
| 58 NSMakePoint(0, winHeight - kToolbarTopOffset - kToolbarMaxHeight)]; | 58 NSPoint endPoint = |
| 59 [self convertPoint:NSMakePoint(0, winHeight - |
| 60 kToolbarTopOffset - |
| 61 kToolbarMaxHeight) |
| 62 fromView:nil]; |
| 59 | 63 |
| 60 [gradient drawFromPoint:startPoint | 64 [gradient drawFromPoint:startPoint |
| 61 toPoint:endPoint | 65 toPoint:endPoint |
| 62 options:NSGradientDrawsBeforeStartingLocation | | 66 options:NSGradientDrawsBeforeStartingLocation | |
| 63 NSGradientDrawsAfterEndingLocation]; | 67 NSGradientDrawsAfterEndingLocation]; |
| 64 } | 68 } |
| 65 | 69 |
| 66 if (showsDivider_) { | 70 if (showsDivider_) { |
| 67 // Draw bottom stroke | 71 // Draw bottom stroke |
| 68 [[self strokeColor] set]; | 72 [[self strokeColor] set]; |
| 69 NSRect borderRect, contentRect; | 73 NSRect borderRect, contentRect; |
| 70 NSDivideRect([self bounds], &borderRect, &contentRect, 1, NSMinYEdge); | 74 NSDivideRect([self bounds], &borderRect, &contentRect, 1, NSMinYEdge); |
| 71 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); | 75 NSRectFillUsingOperation(borderRect, NSCompositeSourceOver); |
| 72 } | 76 } |
| 73 } | 77 } |
| 74 | 78 |
| 75 - (NSColor*)strokeColor { | 79 - (NSColor*)strokeColor { |
| 76 return [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar | 80 return [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBar |
| 77 state:[[self window] isKeyWindow]]; | 81 state:[[self window] isKeyWindow]]; |
| 78 } | 82 } |
| 79 | 83 |
| 80 @end | 84 @end |
| OLD | NEW |