OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #include "chrome/browser/cocoa/gradient_button_cell.h" | 5 #include "chrome/browser/cocoa/gradient_button_cell.h" |
6 | 6 |
7 @implementation GradientButtonCell | 7 @implementation GradientButtonCell |
8 | 8 |
9 - (NSBackgroundStyle)interiorBackgroundStyle { | 9 - (NSBackgroundStyle)interiorBackgroundStyle { |
10 return [self isHighlighted] ? | 10 return [self isHighlighted] ? |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 alpha:1.0]; | 51 alpha:1.0]; |
52 gradient = [[[NSGradient alloc] initWithStartingColor:start | 52 gradient = [[[NSGradient alloc] initWithStartingColor:start |
53 endingColor:end] autorelease]; | 53 endingColor:end] autorelease]; |
54 } else { | 54 } else { |
55 NSColor* start = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0]; | 55 NSColor* start = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0]; |
56 NSColor* end = [NSColor colorWithCalibratedWhite:0.90 alpha:1.0]; | 56 NSColor* end = [NSColor colorWithCalibratedWhite:0.90 alpha:1.0]; |
57 gradient = [[[NSGradient alloc] initWithStartingColor:start | 57 gradient = [[[NSGradient alloc] initWithStartingColor:start |
58 endingColor:end] autorelease]; | 58 endingColor:end] autorelease]; |
59 } | 59 } |
60 | 60 |
| 61 // Stroke the borders and appropriate fill gradient. If we're borderless, |
| 62 // the only time we want to draw the inner gradient is if we're highlighted. |
61 [[NSColor colorWithCalibratedWhite:1.0 alpha:0.25] set]; | 63 [[NSColor colorWithCalibratedWhite:1.0 alpha:0.25] set]; |
62 [outerPath stroke]; | 64 if ([self isBordered]) { |
63 [gradient drawInBezierPath:path angle:90.0]; | 65 [outerPath stroke]; |
64 [[NSColor colorWithCalibratedWhite:0.0 alpha:0.15] set]; | 66 [gradient drawInBezierPath:path angle:90.0]; |
65 [path stroke]; | 67 [[NSColor colorWithCalibratedWhite:0.0 alpha:0.15] set]; |
| 68 [path stroke]; |
| 69 } else { |
| 70 if (highlighted) |
| 71 [gradient drawInBezierPath:path angle:90.0]; |
| 72 } |
66 | 73 |
67 if (type == kLeftButtonWithShadowType) { | 74 if (type == kLeftButtonWithShadowType) { |
68 NSRect borderRect, contentRect; | 75 NSRect borderRect, contentRect; |
69 NSDivideRect(cellFrame, &borderRect, &contentRect, 1.0, NSMaxXEdge); | 76 NSDivideRect(cellFrame, &borderRect, &contentRect, 1.0, NSMaxXEdge); |
70 [[NSColor colorWithCalibratedWhite:0.0 alpha:0.15] set]; | 77 [[NSColor colorWithCalibratedWhite:0.0 alpha:0.15] set]; |
71 NSRectFillUsingOperation(NSInsetRect(borderRect, 0, 2), | 78 NSRectFillUsingOperation(NSInsetRect(borderRect, 0, 2), |
72 NSCompositeSourceOver); | 79 NSCompositeSourceOver); |
73 } | 80 } |
74 | 81 |
75 [self drawInteriorWithFrame:NSOffsetRect(cellFrame, 0, 1) inView:controlView]; | 82 [self drawInteriorWithFrame:NSOffsetRect(cellFrame, 0, 1) inView:controlView]; |
76 } | 83 } |
77 | 84 |
78 @end | 85 @end |
OLD | NEW |