summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/toolbar_button_cell.mm
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 17:43:01 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 17:43:01 +0000
commitf940976145eb807c85eef2d14c38ace469773a60 (patch)
treeaa0e0b35e67c375a2d8e1c124c8225d3ae3b6b56 /chrome/browser/cocoa/toolbar_button_cell.mm
parent70ac49883a4e9b48a875110ff342feb1a8724813 (diff)
downloadchromium_src-f940976145eb807c85eef2d14c38ace469773a60.zip
chromium_src-f940976145eb807c85eef2d14c38ace469773a60.tar.gz
chromium_src-f940976145eb807c85eef2d14c38ace469773a60.tar.bz2
Bookmark bar, now with buttons.
Much of this CL is refactoring; it's not as large as it looks. (Do I always claim that? It's really true this time.) Review URL: http://codereview.chromium.org/115150 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17872 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/toolbar_button_cell.mm')
-rw-r--r--chrome/browser/cocoa/toolbar_button_cell.mm77
1 files changed, 1 insertions, 76 deletions
diff --git a/chrome/browser/cocoa/toolbar_button_cell.mm b/chrome/browser/cocoa/toolbar_button_cell.mm
index 22030e6..b434df9 100644
--- a/chrome/browser/cocoa/toolbar_button_cell.mm
+++ b/chrome/browser/cocoa/toolbar_button_cell.mm
@@ -2,82 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/cocoa/toolbar_button_cell.h"
+#import "chrome/browser/cocoa/toolbar_button_cell.h"
@implementation ToolbarButtonCell
-
-- (NSBackgroundStyle)interiorBackgroundStyle {
- return [self isHighlighted] ?
- NSBackgroundStyleLowered : NSBackgroundStyleRaised;
-}
-
-- (void)awakeFromNib {
- [[self image] setTemplate:YES];
-}
-
-- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
- NSRect drawFrame = NSInsetRect(cellFrame, 1.5, 1.5);
- ButtonType type = [[(NSControl*)controlView cell] tag];
- switch (type) {
- case kRightButtonType:
- drawFrame.origin.x -= 20;
- case kLeftButtonType:
- case kLeftButtonWithShadowType:
- drawFrame.size.width += 20;
- default:
- break;
- }
-
- float radius = 3.5;
- BOOL highlighted = [self isHighlighted];
-
- NSBezierPath *path = [NSBezierPath bezierPathWithRoundedRect:drawFrame
- xRadius:radius
- yRadius:radius];
- NSBezierPath *outerPath =
- [NSBezierPath bezierPathWithRoundedRect:NSInsetRect(drawFrame, -1, -1)
- xRadius:radius + 1
- yRadius:radius + 1];
- NSGradient *gradient = nil;
-
- if (highlighted) {
- NSColor* start = [NSColor colorWithCalibratedHue:0.6
- saturation:1.0
- brightness:0.6
- alpha:1.0];
- NSColor* end = [NSColor colorWithCalibratedHue:0.6
- saturation:1.0
- brightness:0.8
- alpha:1.0];
- gradient = [[[NSGradient alloc] initWithStartingColor:start
- endingColor:end] autorelease];
- } else {
- NSColor* start = [NSColor colorWithCalibratedWhite:1.0 alpha:1.0];
- NSColor* end = [NSColor colorWithCalibratedWhite:0.90 alpha:1.0];
- gradient = [[[NSGradient alloc] initWithStartingColor:start
- endingColor:end] autorelease];
- }
-
- [[NSColor colorWithCalibratedWhite:1.0 alpha:0.25] set];
- [outerPath stroke];
- [gradient drawInBezierPath:path angle:90.0];
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.15] set];
- [path stroke];
-
- if (type == kLeftButtonWithShadowType) {
- NSRect borderRect, contentRect;
- NSDivideRect(cellFrame, &borderRect, &contentRect, 1.0, NSMaxXEdge);
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.15] set];
- NSRectFillUsingOperation(NSInsetRect(borderRect, 0, 2),
- NSCompositeHighlight);
- }
- CGContextRef ctx = static_cast<CGContextRef>
- ([[NSGraphicsContext currentContext] graphicsPort]);
-
- CGContextSetAlpha(ctx, 0.8);
- CGContextBeginTransparencyLayer(ctx, NULL);
- [self drawInteriorWithFrame:NSOffsetRect(cellFrame, 0, 1) inView:controlView];
- CGContextEndTransparencyLayer(ctx);
-}
-
@end