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/search/search.h" | 7 #include "chrome/browser/search/search.h" |
8 #include "chrome/browser/themes/theme_properties.h" | 8 #include "chrome/browser/themes/theme_properties.h" |
9 #include "chrome/browser/themes/theme_service.h" | 9 #include "chrome/browser/themes/theme_service.h" |
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 [self addCursorRect:[self visibleRect] cursor:arrow]; | 39 [self addCursorRect:[self visibleRect] cursor:arrow]; |
40 [arrow setOnMouseEntered:YES]; | 40 [arrow setOnMouseEntered:YES]; |
41 } | 41 } |
42 | 42 |
43 - (void)drawRect:(NSRect)rect { | 43 - (void)drawRect:(NSRect)rect { |
44 if ([controller_ isInState:BookmarkBar::DETACHED] || | 44 if ([controller_ isInState:BookmarkBar::DETACHED] || |
45 [controller_ isAnimatingToState:BookmarkBar::DETACHED] || | 45 [controller_ isAnimatingToState:BookmarkBar::DETACHED] || |
46 [controller_ isAnimatingFromState:BookmarkBar::DETACHED]) { | 46 [controller_ isAnimatingFromState:BookmarkBar::DETACHED]) { |
47 [self drawAsDetachedBubble]; | 47 [self drawAsDetachedBubble]; |
48 } else { | 48 } else { |
49 NSPoint phase = [[self window] themePatternPhase]; | 49 NSPoint phase = [[self window] |
| 50 themePatternPhaseForAlignment:THEME_PATTERN_ALIGN_WITH_TAB_STRIP]; |
50 [[NSGraphicsContext currentContext] cr_setPatternPhase:phase forView:self]; | 51 [[NSGraphicsContext currentContext] cr_setPatternPhase:phase forView:self]; |
51 [self drawBackgroundWithOpaque:YES]; | 52 [self drawBackgroundWithOpaque:YES]; |
52 } | 53 } |
53 } | 54 } |
54 | 55 |
55 - (void)drawAsDetachedBubble { | 56 - (void)drawAsDetachedBubble { |
56 CGFloat morph = [controller_ detachedMorphProgress]; | 57 CGFloat morph = [controller_ detachedMorphProgress]; |
57 NSRect bounds = [self bounds]; | 58 NSRect bounds = [self bounds]; |
58 ThemeService* themeService = [controller_ themeService]; | 59 ThemeService* themeService = [controller_ themeService]; |
59 if (!themeService) | 60 if (!themeService) |
60 return; | 61 return; |
61 | 62 |
62 [[NSColor whiteColor] set]; | 63 [[NSColor whiteColor] set]; |
63 NSRectFill([self bounds]); | 64 NSRectFill([self bounds]); |
64 | 65 |
65 // Overlay with a lighter background color. | 66 // Overlay with a lighter background color. |
66 NSColor* toolbarColor = gfx::SkColorToCalibratedNSColor( | 67 NSColor* toolbarColor = gfx::SkColorToCalibratedNSColor( |
67 chrome::GetDetachedBookmarkBarBackgroundColor(themeService)); | 68 chrome::GetDetachedBookmarkBarBackgroundColor(themeService)); |
68 CGFloat alpha = morph * [toolbarColor alphaComponent]; | 69 CGFloat alpha = morph * [toolbarColor alphaComponent]; |
69 [[toolbarColor colorWithAlphaComponent:alpha] set]; | 70 [[toolbarColor colorWithAlphaComponent:alpha] set]; |
70 NSRectFillUsingOperation(bounds, NSCompositeSourceOver); | 71 NSRectFillUsingOperation(bounds, NSCompositeSourceOver); |
71 | 72 |
72 // Fade in/out the background. | 73 // Fade in/out the background. |
73 { | 74 { |
74 gfx::ScopedNSGraphicsContextSaveGState bgScopedState; | 75 gfx::ScopedNSGraphicsContextSaveGState bgScopedState; |
75 NSGraphicsContext* context = [NSGraphicsContext currentContext]; | 76 NSGraphicsContext* context = [NSGraphicsContext currentContext]; |
76 CGContextRef cgContext = static_cast<CGContextRef>([context graphicsPort]); | 77 CGContextRef cgContext = static_cast<CGContextRef>([context graphicsPort]); |
77 CGContextSetAlpha(cgContext, 1 - morph); | 78 CGContextSetAlpha(cgContext, 1 - morph); |
78 CGContextBeginTransparencyLayer(cgContext, NULL); | 79 CGContextBeginTransparencyLayer(cgContext, NULL); |
79 [context cr_setPatternPhase:[[self window] themePatternPhase] forView:self]; | 80 NSPoint phase = [[self window] |
| 81 themePatternPhaseForAlignment:THEME_PATTERN_ALIGN_WITH_TAB_STRIP]; |
| 82 [context cr_setPatternPhase:phase forView:self]; |
80 [self drawBackgroundWithOpaque:YES]; | 83 [self drawBackgroundWithOpaque:YES]; |
81 CGContextEndTransparencyLayer(cgContext); | 84 CGContextEndTransparencyLayer(cgContext); |
82 } | 85 } |
83 | 86 |
84 // Bottom stroke. | 87 // Bottom stroke. |
85 NSColor* strokeColor = gfx::SkColorToCalibratedNSColor( | 88 NSColor* strokeColor = gfx::SkColorToCalibratedNSColor( |
86 chrome::GetDetachedBookmarkBarSeparatorColor(themeService)); | 89 chrome::GetDetachedBookmarkBarSeparatorColor(themeService)); |
87 strokeColor = [[self strokeColor] blendedColorWithFraction:morph | 90 strokeColor = [[self strokeColor] blendedColorWithFraction:morph |
88 ofColor:strokeColor]; | 91 ofColor:strokeColor]; |
89 strokeColor = [strokeColor colorWithAlphaComponent:0.5]; | 92 strokeColor = [strokeColor colorWithAlphaComponent:0.5]; |
90 [strokeColor set]; | 93 [strokeColor set]; |
91 NSRect strokeRect = bounds; | 94 NSRect strokeRect = bounds; |
92 strokeRect.size.height = [self cr_lineWidth]; | 95 strokeRect.size.height = [self cr_lineWidth]; |
93 NSRectFillUsingOperation(strokeRect, NSCompositeSourceOver); | 96 NSRectFillUsingOperation(strokeRect, NSCompositeSourceOver); |
94 } | 97 } |
95 | 98 |
96 @end // @implementation BookmarkBarToolbarView | 99 @end // @implementation BookmarkBarToolbarView |
OLD | NEW |