| 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] | 49 NSPoint position = [[self window] |
| 50 themePatternPhaseForAlignment:THEME_PATTERN_ALIGN_WITH_TAB_STRIP]; | 50 themeImagePositionForAlignment:THEME_IMAGE_ALIGN_WITH_TAB_STRIP]; |
| 51 [[NSGraphicsContext currentContext] cr_setPatternPhase:phase forView:self]; | 51 [[NSGraphicsContext currentContext] cr_setPatternPhase:position |
| 52 forView:self]; |
| 52 [self drawBackgroundWithOpaque:YES]; | 53 [self drawBackgroundWithOpaque:YES]; |
| 53 } | 54 } |
| 54 } | 55 } |
| 55 | 56 |
| 56 - (void)drawAsDetachedBubble { | 57 - (void)drawAsDetachedBubble { |
| 57 CGFloat morph = [controller_ detachedMorphProgress]; | 58 CGFloat morph = [controller_ detachedMorphProgress]; |
| 58 NSRect bounds = [self bounds]; | 59 NSRect bounds = [self bounds]; |
| 59 ThemeService* themeService = [controller_ themeService]; | 60 ThemeService* themeService = [controller_ themeService]; |
| 60 if (!themeService) | 61 if (!themeService) |
| 61 return; | 62 return; |
| 62 | 63 |
| 63 [[NSColor whiteColor] set]; | 64 [[NSColor whiteColor] set]; |
| 64 NSRectFill([self bounds]); | 65 NSRectFill([self bounds]); |
| 65 | 66 |
| 66 // Overlay with a lighter background color. | 67 // Overlay with a lighter background color. |
| 67 NSColor* toolbarColor = gfx::SkColorToCalibratedNSColor( | 68 NSColor* toolbarColor = gfx::SkColorToCalibratedNSColor( |
| 68 chrome::GetDetachedBookmarkBarBackgroundColor(themeService)); | 69 chrome::GetDetachedBookmarkBarBackgroundColor(themeService)); |
| 69 CGFloat alpha = morph * [toolbarColor alphaComponent]; | 70 CGFloat alpha = morph * [toolbarColor alphaComponent]; |
| 70 [[toolbarColor colorWithAlphaComponent:alpha] set]; | 71 [[toolbarColor colorWithAlphaComponent:alpha] set]; |
| 71 NSRectFillUsingOperation(bounds, NSCompositeSourceOver); | 72 NSRectFillUsingOperation(bounds, NSCompositeSourceOver); |
| 72 | 73 |
| 73 // Fade in/out the background. | 74 // Fade in/out the background. |
| 74 { | 75 { |
| 75 gfx::ScopedNSGraphicsContextSaveGState bgScopedState; | 76 gfx::ScopedNSGraphicsContextSaveGState bgScopedState; |
| 76 NSGraphicsContext* context = [NSGraphicsContext currentContext]; | 77 NSGraphicsContext* context = [NSGraphicsContext currentContext]; |
| 77 CGContextRef cgContext = static_cast<CGContextRef>([context graphicsPort]); | 78 CGContextRef cgContext = static_cast<CGContextRef>([context graphicsPort]); |
| 78 CGContextSetAlpha(cgContext, 1 - morph); | 79 CGContextSetAlpha(cgContext, 1 - morph); |
| 79 CGContextBeginTransparencyLayer(cgContext, NULL); | 80 CGContextBeginTransparencyLayer(cgContext, NULL); |
| 80 NSPoint phase = [[self window] | 81 NSPoint position = [[self window] |
| 81 themePatternPhaseForAlignment:THEME_PATTERN_ALIGN_WITH_TAB_STRIP]; | 82 themeImagePositionForAlignment:THEME_IMAGE_ALIGN_WITH_TAB_STRIP]; |
| 82 [context cr_setPatternPhase:phase forView:self]; | 83 [context cr_setPatternPhase:position forView:self]; |
| 83 [self drawBackgroundWithOpaque:YES]; | 84 [self drawBackgroundWithOpaque:YES]; |
| 84 CGContextEndTransparencyLayer(cgContext); | 85 CGContextEndTransparencyLayer(cgContext); |
| 85 } | 86 } |
| 86 | 87 |
| 87 // Bottom stroke. | 88 // Bottom stroke. |
| 88 NSColor* strokeColor = gfx::SkColorToCalibratedNSColor( | 89 NSColor* strokeColor = gfx::SkColorToCalibratedNSColor( |
| 89 chrome::GetDetachedBookmarkBarSeparatorColor(themeService)); | 90 chrome::GetDetachedBookmarkBarSeparatorColor(themeService)); |
| 90 strokeColor = [[self strokeColor] blendedColorWithFraction:morph | 91 strokeColor = [[self strokeColor] blendedColorWithFraction:morph |
| 91 ofColor:strokeColor]; | 92 ofColor:strokeColor]; |
| 92 strokeColor = [strokeColor colorWithAlphaComponent:0.5]; | 93 strokeColor = [strokeColor colorWithAlphaComponent:0.5]; |
| 93 [strokeColor set]; | 94 [strokeColor set]; |
| 94 NSRect strokeRect = bounds; | 95 NSRect strokeRect = bounds; |
| 95 strokeRect.size.height = [self cr_lineWidth]; | 96 strokeRect.size.height = [self cr_lineWidth]; |
| 96 NSRectFillUsingOperation(strokeRect, NSCompositeSourceOver); | 97 NSRectFillUsingOperation(strokeRect, NSCompositeSourceOver); |
| 97 } | 98 } |
| 98 | 99 |
| 99 @end // @implementation BookmarkBarToolbarView | 100 @end // @implementation BookmarkBarToolbarView |
| OLD | NEW |