OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" | 5 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_toolbar_view.h" |
6 | 6 |
7 #include "chrome/browser/ntp_background_util.h" | 7 #include "chrome/browser/ntp_background_util.h" |
8 #include "chrome/browser/themes/theme_service.h" | 8 #include "chrome/browser/themes/theme_service.h" |
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
49 // The state of our morph; 1 is total bubble, 0 is the regular bar. We use it | 49 // The state of our morph; 1 is total bubble, 0 is the regular bar. We use it |
50 // to morph the bubble to a regular bar (shape and colour). | 50 // to morph the bubble to a regular bar (shape and colour). |
51 CGFloat morph = [controller_ detachedMorphProgress]; | 51 CGFloat morph = [controller_ detachedMorphProgress]; |
52 | 52 |
53 NSRect bounds = [self bounds]; | 53 NSRect bounds = [self bounds]; |
54 | 54 |
55 ui::ThemeProvider* themeProvider = [controller_ themeProvider]; | 55 ui::ThemeProvider* themeProvider = [controller_ themeProvider]; |
56 if (!themeProvider) | 56 if (!themeProvider) |
57 return; | 57 return; |
58 | 58 |
59 NSGraphicsContext* context = [NSGraphicsContext currentContext]; | 59 gfx::ScopedNSGraphicsContextSaveGState scopedGState; |
60 gfx::ScopedNSGraphicsContextSaveGState scopedGState(context); | |
61 | 60 |
62 // Draw the background. | 61 // Draw the background. |
63 { | 62 { |
64 // CanvasSkiaPaint draws to the NSGraphicsContext during its destructor, so | 63 // CanvasSkiaPaint draws to the NSGraphicsContext during its destructor, so |
65 // explicitly scope this. | 64 // explicitly scope this. |
66 // | 65 // |
67 // Paint the entire bookmark bar, even if the damage rect is much smaller | 66 // Paint the entire bookmark bar, even if the damage rect is much smaller |
68 // because PaintBackgroundDetachedMode() assumes that area's origin is | 67 // because PaintBackgroundDetachedMode() assumes that area's origin is |
69 // (0, 0) and that its size is the size of the bookmark bar. | 68 // (0, 0) and that its size is the size of the bookmark bar. |
70 // | 69 // |
(...skipping 25 matching lines...) Expand all Loading... |
96 | 95 |
97 // Draw the rounded rectangle. | 96 // Draw the rounded rectangle. |
98 NSColor* toolbarColor = | 97 NSColor* toolbarColor = |
99 themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR, true); | 98 themeProvider->GetNSColor(ThemeService::COLOR_TOOLBAR, true); |
100 CGFloat alpha = morph * [toolbarColor alphaComponent]; | 99 CGFloat alpha = morph * [toolbarColor alphaComponent]; |
101 [[toolbarColor colorWithAlphaComponent:alpha] set]; // Set with opacity. | 100 [[toolbarColor colorWithAlphaComponent:alpha] set]; // Set with opacity. |
102 [border fill]; | 101 [border fill]; |
103 | 102 |
104 // Fade in/out the background. | 103 // Fade in/out the background. |
105 { | 104 { |
106 gfx::ScopedNSGraphicsContextSaveGState bgScopedState(context); | 105 gfx::ScopedNSGraphicsContextSaveGState bgScopedState; |
107 [border setClip]; | 106 [border setClip]; |
| 107 NSGraphicsContext* context = [NSGraphicsContext currentContext]; |
108 CGContextRef cgContext = (CGContextRef)[context graphicsPort]; | 108 CGContextRef cgContext = (CGContextRef)[context graphicsPort]; |
109 CGContextBeginTransparencyLayer(cgContext, NULL); | 109 CGContextBeginTransparencyLayer(cgContext, NULL); |
110 CGContextSetAlpha(cgContext, 1 - morph); | 110 CGContextSetAlpha(cgContext, 1 - morph); |
111 [context setPatternPhase:[[self window] themePatternPhase]]; | 111 [context setPatternPhase:[[self window] themePatternPhase]]; |
112 [self drawBackgroundWithOpaque:YES]; | 112 [self drawBackgroundWithOpaque:YES]; |
113 CGContextEndTransparencyLayer(cgContext); | 113 CGContextEndTransparencyLayer(cgContext); |
114 } | 114 } |
115 | 115 |
116 // Draw the border of the rounded rectangle. | 116 // Draw the border of the rounded rectangle. |
117 NSColor* borderColor = themeProvider->GetNSColor( | 117 NSColor* borderColor = themeProvider->GetNSColor( |
(...skipping 13 matching lines...) Expand all Loading... |
131 NSMakePoint(morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5, | 131 NSMakePoint(morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5, |
132 morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5); | 132 morph * bookmarks::kNTPBookmarkBarPadding + morph * 0.5); |
133 CGFloat dividerWidth = | 133 CGFloat dividerWidth = |
134 NSWidth(bounds) - 2 * morph * bookmarks::kNTPBookmarkBarPadding - 2 * 0.5; | 134 NSWidth(bounds) - 2 * morph * bookmarks::kNTPBookmarkBarPadding - 2 * 0.5; |
135 [divider moveToPoint:dividerStart]; | 135 [divider moveToPoint:dividerStart]; |
136 [divider relativeLineToPoint:NSMakePoint(dividerWidth, 0)]; | 136 [divider relativeLineToPoint:NSMakePoint(dividerWidth, 0)]; |
137 [divider stroke]; | 137 [divider stroke]; |
138 } | 138 } |
139 | 139 |
140 @end // @implementation BookmarkBarToolbarView | 140 @end // @implementation BookmarkBarToolbarView |
OLD | NEW |