diff options
author | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-23 20:37:09 +0000 |
---|---|---|
committer | pinkerton@google.com <pinkerton@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-23 20:37:09 +0000 |
commit | a3e4dd79aa7550b6a43ec1fb87e1026ec524f7d5 (patch) | |
tree | cc135fb2985b682cd53ef1021ed2f61238367fa3 /chrome/browser/cocoa/toolbar_button_cell.mm | |
parent | 30dce773eb5fcd940ade62bdb8da8bd86b539744 (diff) | |
download | chromium_src-a3e4dd79aa7550b6a43ec1fb87e1026ec524f7d5.zip chromium_src-a3e4dd79aa7550b6a43ec1fb87e1026ec524f7d5.tar.gz chromium_src-a3e4dd79aa7550b6a43ec1fb87e1026ec524f7d5.tar.bz2 |
ui refresh from cole. make it look chromey and get the basic framework for the views we'll need.
Review URL: http://codereview.chromium.org/18720
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8571 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/toolbar_button_cell.mm')
-rw-r--r-- | chrome/browser/cocoa/toolbar_button_cell.mm | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/toolbar_button_cell.mm b/chrome/browser/cocoa/toolbar_button_cell.mm new file mode 100644 index 0000000..d8b0baf --- /dev/null +++ b/chrome/browser/cocoa/toolbar_button_cell.mm @@ -0,0 +1,82 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// 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" + +enum { + kLeftButtonType = -1, + kLeftButtonWithShadowType = -2, + kStandardButtonType = 0, + kRightButtonType = 1, +}; +typedef NSInteger ButtonType; + +@implementation ToolbarButtonCell + +- (NSBackgroundStyle)interiorBackgroundStyle { + return [self isHighlighted] ? + NSBackgroundStyleLowered : NSBackgroundStyleRaised; +} + +- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView{ + NSRect drawFrame = NSInsetRect(cellFrame, 1.5, 1.5); + ButtonType type = [controlView 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), + NSCompositeSourceOver); + } + + [self drawInteriorWithFrame:NSOffsetRect(cellFrame, 0, 1) inView:controlView]; +} + +@end |