| 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 #import "chrome/browser/cocoa/bookmark_bar_toolbar_view.h" | 5 #import "chrome/browser/cocoa/bookmark_bar_toolbar_view.h" |
| 6 | 6 |
| 7 #include "app/gfx/canvas_paint.h" | 7 #include "app/gfx/canvas_paint.h" |
| 8 #include "app/theme_provider.h" | 8 #include "app/theme_provider.h" |
| 9 #include "base/gfx/rect.h" | 9 #include "base/gfx/rect.h" |
| 10 #include "chrome/browser/browser_theme_provider.h" | 10 #include "chrome/browser/browser_theme_provider.h" |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 NSColor* toolbarColor = | 91 NSColor* toolbarColor = |
| 92 [[self gtm_theme] backgroundColorForStyle:GTMThemeStyleToolBar | 92 [[self gtm_theme] backgroundColorForStyle:GTMThemeStyleToolBar |
| 93 state:GTMThemeStateActiveWindow]; | 93 state:GTMThemeStateActiveWindow]; |
| 94 // workaround for default theme | 94 // workaround for default theme |
| 95 // TODO(alcor) next GTM update return nil for background color if not set; | 95 // TODO(alcor) next GTM update return nil for background color if not set; |
| 96 // http://crbug.com/25196 | 96 // http://crbug.com/25196 |
| 97 if ([toolbarColor isEqual:[NSColor colorWithCalibratedWhite:0.5 alpha:1.0]]) | 97 if ([toolbarColor isEqual:[NSColor colorWithCalibratedWhite:0.5 alpha:1.0]]) |
| 98 toolbarColor = nil; | 98 toolbarColor = nil; |
| 99 if (!toolbarColor) | 99 if (!toolbarColor) |
| 100 toolbarColor = [NSColor colorWithCalibratedWhite:0.9 alpha:1.0]; | 100 toolbarColor = [NSColor colorWithCalibratedWhite:0.9 alpha:1.0]; |
| 101 [[toolbarColor colorWithAlphaComponent:morph] set]; // Set with opacity. | 101 CGFloat alpha = morph * [toolbarColor alphaComponent]; |
| 102 [[toolbarColor colorWithAlphaComponent:alpha] set]; // Set with opacity. |
| 102 [border fill]; | 103 [border fill]; |
| 103 | 104 |
| 104 // Fade in/out the background. | 105 // Fade in/out the background. |
| 105 [context saveGraphicsState]; | 106 [context saveGraphicsState]; |
| 106 [border setClip]; | 107 [border setClip]; |
| 107 CGContextRef cgContext = (CGContextRef)[context graphicsPort]; | 108 CGContextRef cgContext = (CGContextRef)[context graphicsPort]; |
| 108 CGContextBeginTransparencyLayer(cgContext, NULL); | 109 CGContextBeginTransparencyLayer(cgContext, NULL); |
| 109 CGContextSetAlpha(cgContext, 1 - morph); | 110 CGContextSetAlpha(cgContext, 1 - morph); |
| 110 [context setPatternPhase:[self gtm_themePatternPhase]]; | 111 [context setPatternPhase:[self gtm_themePatternPhase]]; |
| 111 [self drawBackground]; | 112 [self drawBackground]; |
| 112 CGContextEndTransparencyLayer(cgContext); | 113 CGContextEndTransparencyLayer(cgContext); |
| 113 [context restoreGraphicsState]; | 114 [context restoreGraphicsState]; |
| 114 | 115 |
| 115 // Draw the border of the rounded rectangle. | 116 // Draw the border of the rounded rectangle. |
| 116 NSColor* borderColor = | 117 NSColor* borderColor = |
| 117 [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBarButton | 118 [[self gtm_theme] strokeColorForStyle:GTMThemeStyleToolBarButton |
| 118 state:GTMThemeStateActiveWindow]; | 119 state:GTMThemeStateActiveWindow]; |
| 119 [[borderColor colorWithAlphaComponent:morph] set]; // Set with opacity. | 120 alpha = morph * [borderColor alphaComponent]; |
| 121 [[borderColor colorWithAlphaComponent:alpha] set]; // Set with opacity. |
| 120 [border stroke]; | 122 [border stroke]; |
| 121 | 123 |
| 122 // Fade in/out the divider. | 124 // Fade in/out the divider. |
| 123 // TODO(viettrungluu): It's not obvious that this divider lines up exactly | 125 // TODO(viettrungluu): It's not obvious that this divider lines up exactly |
| 124 // with |BackgroundGradientView|'s (in fact, it probably doesn't). | 126 // with |BackgroundGradientView|'s (in fact, it probably doesn't). |
| 125 [[[self strokeColor] colorWithAlphaComponent:(1 - morph)] set]; | 127 NSColor* strokeColor = [self strokeColor]; |
| 128 alpha = (1 - morph) * [strokeColor alphaComponent]; |
| 129 [[strokeColor colorWithAlphaComponent:alpha] set]; |
| 126 NSBezierPath* divider = [NSBezierPath bezierPath]; | 130 NSBezierPath* divider = [NSBezierPath bezierPath]; |
| 127 NSPoint dividerStart = | 131 NSPoint dividerStart = |
| 128 NSMakePoint(morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5, | 132 NSMakePoint(morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5, |
| 129 morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5); | 133 morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5); |
| 130 CGFloat dividerWidth = | 134 CGFloat dividerWidth = |
| 131 NSWidth(bounds) - 2 * morph * bookmarks::kNTPBookmarkBarPadding - 2 * 0.5; | 135 NSWidth(bounds) - 2 * morph * bookmarks::kNTPBookmarkBarPadding - 2 * 0.5; |
| 132 [divider moveToPoint:dividerStart]; | 136 [divider moveToPoint:dividerStart]; |
| 133 [divider relativeLineToPoint:NSMakePoint(dividerWidth, 0)]; | 137 [divider relativeLineToPoint:NSMakePoint(dividerWidth, 0)]; |
| 134 [divider stroke]; | 138 [divider stroke]; |
| 135 | 139 |
| 136 // Restore the graphics context. | 140 // Restore the graphics context. |
| 137 [context restoreGraphicsState]; | 141 [context restoreGraphicsState]; |
| 138 } | 142 } |
| 139 | 143 |
| 140 @end // @implementation BookmarkBarToolbarView | 144 @end // @implementation BookmarkBarToolbarView |
| OLD | NEW |