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/toolbar/toolbar_view.h" | 5 #import "chrome/browser/ui/cocoa/toolbar/toolbar_view.h" |
6 | 6 |
7 #import "chrome/browser/ui/cocoa/themed_window.h" | 7 #import "chrome/browser/ui/cocoa/themed_window.h" |
8 #import "chrome/browser/ui/cocoa/view_id_util.h" | 8 #import "chrome/browser/ui/cocoa/view_id_util.h" |
9 #import "ui/base/cocoa/nsgraphics_context_additions.h" | 9 #import "ui/base/cocoa/nsgraphics_context_additions.h" |
10 | 10 |
11 @implementation ToolbarView | 11 @implementation ToolbarView |
12 | 12 |
13 @synthesize dividerOpacity = dividerOpacity_; | 13 @synthesize dividerOpacity = dividerOpacity_; |
14 | 14 |
15 // Prevent mouse down events from moving the parent window around. | 15 // Prevent mouse down events from moving the parent window around. |
16 - (BOOL)mouseDownCanMoveWindow { | 16 - (BOOL)mouseDownCanMoveWindow { |
17 return NO; | 17 return NO; |
18 } | 18 } |
19 | 19 |
20 - (void)drawRect:(NSRect)rect { | 20 - (void)drawRect:(NSRect)rect { |
21 // The toolbar's background pattern is phased relative to the | 21 NSPoint phase = [[self window] |
22 // tab strip view's background pattern. | 22 themePatternPhaseForAlignment:THEME_PATTERN_ALIGN_WITH_TAB_STRIP]; |
23 NSPoint phase = [[self window] themePatternPhase]; | |
24 [[NSGraphicsContext currentContext] cr_setPatternPhase:phase forView:self]; | 23 [[NSGraphicsContext currentContext] cr_setPatternPhase:phase forView:self]; |
25 [self drawBackgroundWithOpaque:YES]; | 24 [self drawBackgroundWithOpaque:YES]; |
26 } | 25 } |
27 | 26 |
28 // Override of |-[BackgroundGradientView strokeColor]|; make it respect opacity. | 27 // Override of |-[BackgroundGradientView strokeColor]|; make it respect opacity. |
29 - (NSColor*)strokeColor { | 28 - (NSColor*)strokeColor { |
30 return [[super strokeColor] colorWithAlphaComponent:[self dividerOpacity]]; | 29 return [[super strokeColor] colorWithAlphaComponent:[self dividerOpacity]]; |
31 } | 30 } |
32 | 31 |
33 - (BOOL)accessibilityIsIgnored { | 32 - (BOOL)accessibilityIsIgnored { |
34 return NO; | 33 return NO; |
35 } | 34 } |
36 | 35 |
37 - (id)accessibilityAttributeValue:(NSString*)attribute { | 36 - (id)accessibilityAttributeValue:(NSString*)attribute { |
38 if ([attribute isEqual:NSAccessibilityRoleAttribute]) | 37 if ([attribute isEqual:NSAccessibilityRoleAttribute]) |
39 return NSAccessibilityToolbarRole; | 38 return NSAccessibilityToolbarRole; |
40 | 39 |
41 return [super accessibilityAttributeValue:attribute]; | 40 return [super accessibilityAttributeValue:attribute]; |
42 } | 41 } |
43 | 42 |
44 - (ViewID)viewID { | 43 - (ViewID)viewID { |
45 return VIEW_ID_TOOLBAR; | 44 return VIEW_ID_TOOLBAR; |
46 } | 45 } |
47 | 46 |
48 - (BOOL)isOpaque { | 47 - (BOOL)isOpaque { |
49 return YES; | 48 return YES; |
50 } | 49 } |
51 | 50 |
52 @end | 51 @end |
OLD | NEW |