OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/scoped_nsobject.h" |
| 6 #import "chrome/browser/cocoa/extensions/browser_action_button.h" |
5 #import "chrome/browser/cocoa/extensions/browser_actions_container_view.h" | 7 #import "chrome/browser/cocoa/extensions/browser_actions_container_view.h" |
6 | 8 |
7 namespace { | 9 namespace { |
| 10 const CGFloat kGrippyLowerPadding = 4.0; |
| 11 const CGFloat kGrippyUpperPadding = 8.0; |
| 12 const CGFloat kRightBorderXOffset = -1.0; |
8 const CGFloat kRightBorderWidth = 1.0; | 13 const CGFloat kRightBorderWidth = 1.0; |
9 const CGFloat kRightBorderGrayscale = 0.5; | 14 const CGFloat kRightBorderGrayscale = 0.5; |
10 const CGFloat kUpperPadding = 9.0; | 15 const CGFloat kUpperPadding = 9.0; |
11 const CGFloat kLowerPadding = 5.0; | 16 const CGFloat kLowerPadding = 5.0; |
12 } // namespace | 17 } // namespace |
13 | 18 |
| 19 @interface BrowserActionsContainerView(Private) |
| 20 - (void)drawLeftGrippers; |
| 21 @end |
| 22 |
14 @implementation BrowserActionsContainerView | 23 @implementation BrowserActionsContainerView |
15 | 24 |
16 @synthesize rightBorderShown = rightBorderShown_; | 25 @synthesize rightBorderShown = rightBorderShown_; |
17 | 26 |
18 - (void)drawRect:(NSRect)dirtyRect { | 27 - (void)drawRect:(NSRect)dirtyRect { |
19 NSRect bounds = [self bounds]; | 28 NSRect bounds = [self bounds]; |
20 if (rightBorderShown_) { | 29 if (rightBorderShown_) { |
21 NSColor* middleColor = | 30 NSColor* middleColor = |
22 [NSColor colorWithCalibratedWhite:kRightBorderGrayscale alpha:1.0]; | 31 [NSColor colorWithCalibratedWhite:kRightBorderGrayscale alpha:1.0]; |
23 NSColor* endPointColor = | 32 NSColor* endPointColor = |
24 [NSColor colorWithCalibratedWhite:kRightBorderGrayscale alpha:0.0]; | 33 [NSColor colorWithCalibratedWhite:kRightBorderGrayscale alpha:0.0]; |
25 NSGradient* borderGradient = [[[NSGradient alloc] | 34 NSGradient* borderGradient = [[[NSGradient alloc] |
26 initWithColorsAndLocations:endPointColor, (CGFloat)0.0, | 35 initWithColorsAndLocations:endPointColor, (CGFloat)0.0, |
27 middleColor, (CGFloat)0.5, | 36 middleColor, (CGFloat)0.5, |
28 endPointColor, (CGFloat)1.0, | 37 endPointColor, (CGFloat)1.0, |
29 nil] autorelease]; | 38 nil] autorelease]; |
30 CGFloat xPos = bounds.origin.x + bounds.size.width - kRightBorderWidth; | 39 CGFloat xPos = bounds.origin.x + bounds.size.width - kRightBorderWidth + |
| 40 kRightBorderXOffset; |
31 NSRect borderRect = NSMakeRect(xPos, kLowerPadding, kRightBorderWidth, | 41 NSRect borderRect = NSMakeRect(xPos, kLowerPadding, kRightBorderWidth, |
32 bounds.size.height - kUpperPadding); | 42 bounds.size.height - kUpperPadding); |
33 [borderGradient drawInRect:borderRect angle:90.0]; | 43 [borderGradient drawInRect:borderRect angle:90.0]; |
34 } | 44 } |
| 45 |
| 46 [self drawLeftGrippers]; |
| 47 } |
| 48 |
| 49 - (void)drawLeftGrippers { |
| 50 NSRect grippyRect = NSMakeRect(0.0, kLowerPadding + kGrippyLowerPadding, 1.0, |
| 51 [self bounds].size.height - kUpperPadding - kGrippyUpperPadding); |
| 52 [[NSColor colorWithCalibratedWhite:0.7 alpha:0.5] set]; |
| 53 NSRectFill(grippyRect); |
| 54 |
| 55 [[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] set]; |
| 56 grippyRect.origin.x += 1.0; |
| 57 NSRectFill(grippyRect); |
| 58 |
| 59 grippyRect.origin.x += 1.0; |
| 60 |
| 61 [[NSColor colorWithCalibratedWhite:0.7 alpha:0.5] set]; |
| 62 grippyRect.origin.x += 1.0; |
| 63 NSRectFill(grippyRect); |
| 64 |
| 65 [[NSColor colorWithCalibratedWhite:1.0 alpha:1.0] set]; |
| 66 grippyRect.origin.x += 1.0; |
| 67 NSRectFill(grippyRect); |
| 68 } |
| 69 |
| 70 - (BrowserActionButton*)buttonAtIndex:(NSUInteger)index { |
| 71 return [[self subviews] objectAtIndex:index]; |
35 } | 72 } |
36 | 73 |
37 @end | 74 @end |
OLD | NEW |