diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 20:25:38 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-07-01 20:25:38 +0000 |
commit | bcc18d3d4b89f4985b4bf542c319d6e94de452e0 (patch) | |
tree | 689fe92abe4b260a511e44d0415d625989c3e44c /chrome/browser | |
parent | 4cd2d520d95db38a157fd2f86161ea457eab7af2 (diff) | |
download | chromium_src-bcc18d3d4b89f4985b4bf542c319d6e94de452e0.zip chromium_src-bcc18d3d4b89f4985b4bf542c319d6e94de452e0.tar.gz chromium_src-bcc18d3d4b89f4985b4bf542c319d6e94de452e0.tar.bz2 |
[Mac] Moving some new third party code into its proper dir. Also tweak the radius of the close button hover state circle a bit.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/2833050
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@51417 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/cocoa/DEPS | 1 | ||||
-rw-r--r-- | chrome/browser/cocoa/hover_close_button.mm | 4 | ||||
-rw-r--r-- | chrome/browser/cocoa/third_party/LICENSE | 23 | ||||
-rw-r--r-- | chrome/browser/cocoa/third_party/NSBezierPath+MCAdditions.h | 27 | ||||
-rw-r--r-- | chrome/browser/cocoa/third_party/NSBezierPath+MCAdditions.m | 188 | ||||
-rw-r--r-- | chrome/browser/cocoa/third_party/README.chromium | 14 |
6 files changed, 3 insertions, 254 deletions
diff --git a/chrome/browser/cocoa/DEPS b/chrome/browser/cocoa/DEPS index eb3e240..c00f313 100644 --- a/chrome/browser/cocoa/DEPS +++ b/chrome/browser/cocoa/DEPS @@ -1,3 +1,4 @@ include_rules = [ + "+third_party/molokocacao", # For NSBezierPath additions. "+third_party/ocmock", # For unit tests. ] diff --git a/chrome/browser/cocoa/hover_close_button.mm b/chrome/browser/cocoa/hover_close_button.mm index c885ae6..da1dd9a 100644 --- a/chrome/browser/cocoa/hover_close_button.mm +++ b/chrome/browser/cocoa/hover_close_button.mm @@ -6,8 +6,8 @@ #include "app/l10n_util.h" #include "base/scoped_nsobject.h" -#import "chrome/browser/cocoa/third_party/NSBezierPath+MCAdditions.h" #include "grit/generated_resources.h" +#import "third_party/molokocacao/NSBezierPath+MCAdditions.h" namespace { // Convenience function to return the middle point of the given |rect|. @@ -15,7 +15,7 @@ static NSPoint MidRect(NSRect rect) { return NSMakePoint(NSMidX(rect), NSMidY(rect)); } -const CGFloat kCircleRadiusPercentage = 0.45; +const CGFloat kCircleRadiusPercentage = 0.415; const CGFloat kCircleHoverWhite = 0.565; const CGFloat kCircleClickWhite = 0.396; const CGFloat kXShadowAlpha = 0.6; diff --git a/chrome/browser/cocoa/third_party/LICENSE b/chrome/browser/cocoa/third_party/LICENSE deleted file mode 100644 index 6133156..0000000 --- a/chrome/browser/cocoa/third_party/LICENSE +++ /dev/null @@ -1,23 +0,0 @@ -Copyright 2008 MolokoCacao -All rights reserved - -Redistribution and use in source and binary forms, with or without -modification, are permitted providing that the following conditions -are met: -1. Redistributions of source code must retain the above copyright - notice, this list of conditions and the following disclaimer. -2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - -THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR -IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY -DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING -IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -POSSIBILITY OF SUCH DAMAGE. diff --git a/chrome/browser/cocoa/third_party/NSBezierPath+MCAdditions.h b/chrome/browser/cocoa/third_party/NSBezierPath+MCAdditions.h deleted file mode 100644 index 7750fca..0000000 --- a/chrome/browser/cocoa/third_party/NSBezierPath+MCAdditions.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// NSBezierPath+MCAdditions.h -// -// Created by Sean Patrick O'Brien on 4/1/08. -// Copyright 2008 MolokoCacao. All rights reserved. -// - -#ifndef CHROME_BROWSER_COCOA_THIRD_PARTY_NSBEZIERPATH_MCADDITIONS_H_ -#define CHROME_BROWSER_COCOA_THIRD_PARTY_NSBEZIERPATH_MCADDITIONS_H_ - -#import <Cocoa/Cocoa.h> - -@interface NSBezierPath (MCAdditions) - -+ (NSBezierPath*)bezierPathWithCGPath:(CGPathRef)pathRef; - -- (NSBezierPath*)pathWithStrokeWidth:(CGFloat)strokeWidth; - -- (void)fillWithInnerShadow:(NSShadow*)shadow; -- (void)drawBlurWithColor:(NSColor*)color radius:(CGFloat)radius; - -- (void)strokeInside; -- (void)strokeInsideWithinRect:(NSRect)clipRect; - -@end - -#endif // CHROME_BROWSER_COCOA_THIRD_PARTY_NSBEZIERPATH_MCADDITIONS_H_ diff --git a/chrome/browser/cocoa/third_party/NSBezierPath+MCAdditions.m b/chrome/browser/cocoa/third_party/NSBezierPath+MCAdditions.m deleted file mode 100644 index e1771cc..0000000 --- a/chrome/browser/cocoa/third_party/NSBezierPath+MCAdditions.m +++ /dev/null @@ -1,188 +0,0 @@ -// -// NSBezierPath+MCAdditions.m -// -// Created by Sean Patrick O'Brien on 4/1/08. -// Copyright 2008 MolokoCacao. All rights reserved. -// - -#import "NSBezierPath+MCAdditions.h" - -#import "third_party/GTM/AppKit/GTMNSBezierPath+CGPath.h" - -// remove/comment out this line of you don't want to use undocumented functions -#define MCBEZIER_USE_PRIVATE_FUNCTION - -#ifdef MCBEZIER_USE_PRIVATE_FUNCTION -extern CGPathRef CGContextCopyPath(CGContextRef context); -#endif - -static void CGPathCallback(void *info, const CGPathElement *element) -{ - NSBezierPath *path = info; - CGPoint *points = element->points; - - switch (element->type) { - case kCGPathElementMoveToPoint: - { - [path moveToPoint:NSMakePoint(points[0].x, points[0].y)]; - break; - } - case kCGPathElementAddLineToPoint: - { - [path lineToPoint:NSMakePoint(points[0].x, points[0].y)]; - break; - } - case kCGPathElementAddQuadCurveToPoint: - { - // NOTE: This is untested. - NSPoint currentPoint = [path currentPoint]; - NSPoint interpolatedPoint = NSMakePoint((currentPoint.x + 2*points[0].x) / 3, (currentPoint.y + 2*points[0].y) / 3); - [path curveToPoint:NSMakePoint(points[1].x, points[1].y) controlPoint1:interpolatedPoint controlPoint2:interpolatedPoint]; - break; - } - case kCGPathElementAddCurveToPoint: - { - [path curveToPoint:NSMakePoint(points[2].x, points[2].y) controlPoint1:NSMakePoint(points[0].x, points[0].y) controlPoint2:NSMakePoint(points[1].x, points[1].y)]; - break; - } - case kCGPathElementCloseSubpath: - { - [path closePath]; - break; - } - } -} - -@implementation NSBezierPath (MCAdditions) - -+ (NSBezierPath *)bezierPathWithCGPath:(CGPathRef)pathRef -{ - NSBezierPath *path = [NSBezierPath bezierPath]; - CGPathApply(pathRef, path, CGPathCallback); - - return path; -} - -- (NSBezierPath *)pathWithStrokeWidth:(CGFloat)strokeWidth -{ -#ifdef MCBEZIER_USE_PRIVATE_FUNCTION - NSBezierPath *path = [self copy]; - CGContextRef context = [[NSGraphicsContext currentContext] graphicsPort]; - CGPathRef pathRef = [path gtm_CGPath]; - [path release]; - - CGContextSaveGState(context); - - CGContextBeginPath(context); - CGContextAddPath(context, pathRef); - CGContextSetLineWidth(context, strokeWidth); - CGContextReplacePathWithStrokedPath(context); - CGPathRef strokedPathRef = CGContextCopyPath(context); - CGContextBeginPath(context); - NSBezierPath *strokedPath = [NSBezierPath bezierPathWithCGPath:strokedPathRef]; - - CGContextRestoreGState(context); - - CFRelease(pathRef); - CFRelease(strokedPathRef); - - return strokedPath; -#else - return nil; -#endif // MCBEZIER_USE_PRIVATE_FUNCTION -} - -- (void)fillWithInnerShadow:(NSShadow *)shadow -{ - [NSGraphicsContext saveGraphicsState]; - - NSSize offset = shadow.shadowOffset; - NSSize originalOffset = offset; - CGFloat radius = shadow.shadowBlurRadius; - NSRect bounds = NSInsetRect(self.bounds, -(ABS(offset.width) + radius), -(ABS(offset.height) + radius)); - offset.height += bounds.size.height; - shadow.shadowOffset = offset; - NSAffineTransform *transform = [NSAffineTransform transform]; - if ([[NSGraphicsContext currentContext] isFlipped]) - [transform translateXBy:0 yBy:bounds.size.height]; - else - [transform translateXBy:0 yBy:-bounds.size.height]; - - NSBezierPath *drawingPath = [NSBezierPath bezierPathWithRect:bounds]; - [drawingPath setWindingRule:NSEvenOddWindingRule]; - [drawingPath appendBezierPath:self]; - [drawingPath transformUsingAffineTransform:transform]; - - [self addClip]; - [shadow set]; - [[NSColor blackColor] set]; - [drawingPath fill]; - - shadow.shadowOffset = originalOffset; - - [NSGraphicsContext restoreGraphicsState]; -} - -- (void)drawBlurWithColor:(NSColor *)color radius:(CGFloat)radius -{ - NSRect bounds = NSInsetRect(self.bounds, -radius, -radius); - NSShadow *shadow = [[NSShadow alloc] init]; - shadow.shadowOffset = NSMakeSize(0, bounds.size.height); - shadow.shadowBlurRadius = radius; - shadow.shadowColor = color; - NSBezierPath *path = [self copy]; - NSAffineTransform *transform = [NSAffineTransform transform]; - if ([[NSGraphicsContext currentContext] isFlipped]) - [transform translateXBy:0 yBy:bounds.size.height]; - else - [transform translateXBy:0 yBy:-bounds.size.height]; - [path transformUsingAffineTransform:transform]; - - [NSGraphicsContext saveGraphicsState]; - - [shadow set]; - [[NSColor blackColor] set]; - NSRectClip(bounds); - [path fill]; - - [NSGraphicsContext restoreGraphicsState]; - - [path release]; - [shadow release]; -} - -// Credit for the next two methods goes to Matt Gemmell -- (void)strokeInside -{ - /* Stroke within path using no additional clipping rectangle. */ - [self strokeInsideWithinRect:NSZeroRect]; -} - -- (void)strokeInsideWithinRect:(NSRect)clipRect -{ - NSGraphicsContext *thisContext = [NSGraphicsContext currentContext]; - float lineWidth = [self lineWidth]; - - /* Save the current graphics context. */ - [thisContext saveGraphicsState]; - - /* Double the stroke width, since -stroke centers strokes on paths. */ - [self setLineWidth:(lineWidth * 2.0)]; - - /* Clip drawing to this path; draw nothing outwith the path. */ - [self setClip]; - - /* Further clip drawing to clipRect, usually the view's frame. */ - if (clipRect.size.width > 0.0 && clipRect.size.height > 0.0) { - [NSBezierPath clipRect:clipRect]; - } - - /* Stroke the path. */ - [self stroke]; - - /* Restore the previous graphics context. */ - [thisContext restoreGraphicsState]; - [self setLineWidth:lineWidth]; -} - -@end diff --git a/chrome/browser/cocoa/third_party/README.chromium b/chrome/browser/cocoa/third_party/README.chromium deleted file mode 100644 index c82463f..0000000 --- a/chrome/browser/cocoa/third_party/README.chromium +++ /dev/null @@ -1,14 +0,0 @@ -Name: NSBezierPath additions from Sean Patrick O'Brien -URL: http://www.seanpatrickobrien.com/journal/posts/3 -Source URL: http://www.seanpatrickobrien.com/downloads/track/?path=%2Ftutorials%2F1%2FExampleButton.zip -Version: 1.0 -License: BSD -License File: LICENSE - -Description: -Additions to NSBezierPath to make certain operations more convenient (inner -shadows on paths, for example). - -Local Modifications: - - Added LICENSE file based on email correspondence with Sean. - - Added header guards. |