summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/ui/cocoa/hover_close_button.mm44
-rw-r--r--third_party/molokocacao/NSBezierPath+MCAdditions.h2
-rw-r--r--third_party/molokocacao/NSBezierPath+MCAdditions.m6
-rw-r--r--third_party/molokocacao/README.chromium2
4 files changed, 40 insertions, 14 deletions
diff --git a/chrome/browser/ui/cocoa/hover_close_button.mm b/chrome/browser/ui/cocoa/hover_close_button.mm
index a01d95c..43bbc5c 100644
--- a/chrome/browser/ui/cocoa/hover_close_button.mm
+++ b/chrome/browser/ui/cocoa/hover_close_button.mm
@@ -50,6 +50,12 @@ NSString* const kFadeOutValueKeyPath = @"fadeOutValue";
xPath:(NSBezierPath*)xPath
circlePath:(NSBezierPath*)circlePath
hoverState:(HoverState)hoverState;
+
++ (NSBitmapImageRep*)imageRepForBounds:(NSRect)bounds
+ scale:(float)scale
+ xPath:(NSBezierPath*)xPath
+ circlePath:(NSBezierPath*)circlePath
+ hoverState:(HoverState)hoverState;
@end
@implementation HoverCloseButton
@@ -248,21 +254,39 @@ NSString* const kFadeOutValueKeyPath = @"fadeOutValue";
xPath:(NSBezierPath*)xPath
circlePath:(NSBezierPath*)circlePath
hoverState:(HoverState)hoverState {
+ NSImage* image = [[[NSImage alloc] initWithSize:bounds.size] autorelease];
+ for (int scale = 1; scale <= 2; ++scale) {
+ [image addRepresentation:
+ [self imageRepForBounds:bounds
+ scale:scale
+ xPath:xPath
+ circlePath:circlePath
+ hoverState:hoverState]];
+ }
+ return image;
+}
+
++ (NSBitmapImageRep*)imageRepForBounds:(NSRect)bounds
+ scale:(float)scale
+ xPath:(NSBezierPath*)xPath
+ circlePath:(NSBezierPath*)circlePath
+ hoverState:(HoverState)hoverState {
gfx::ScopedNSGraphicsContextSaveGState graphicsStateSaver;
- scoped_nsobject<NSBitmapImageRep> imageRep(
- [[NSBitmapImageRep alloc]
+ NSBitmapImageRep* imageRep =
+ [[[NSBitmapImageRep alloc]
initWithBitmapDataPlanes:NULL
- pixelsWide:NSWidth(bounds)
- pixelsHigh:NSHeight(bounds)
+ pixelsWide:NSWidth(bounds) * scale
+ pixelsHigh:NSHeight(bounds) * scale
bitsPerSample:8
samplesPerPixel:4
hasAlpha:YES
isPlanar:NO
colorSpaceName:NSCalibratedRGBColorSpace
bitmapFormat:0
- bytesPerRow:kButtonWidth * 4
- bitsPerPixel:32]);
+ bytesPerRow:0
+ bitsPerPixel:0] autorelease];
+ [imageRep setSize:bounds.size];
NSGraphicsContext* gc =
[NSGraphicsContext graphicsContextWithBitmapImageRep:imageRep];
[NSGraphicsContext setCurrentContext:gc];
@@ -291,11 +315,9 @@ NSString* const kFadeOutValueKeyPath = @"fadeOutValue";
kXShadowCircleAlpha : kXShadowAlpha;
[shadow setShadowColor:[NSColor colorWithCalibratedWhite:0.15 alpha:alpha]];
[shadow setShadowOffset:NSMakeSize(0.0, 0.0)];
- [shadow setShadowBlurRadius:2.5];
- [xPath fillWithInnerShadow:shadow];
- NSImage* image = [[[NSImage alloc] initWithSize:bounds.size] autorelease];
- [image addRepresentation:imageRep];
- return image;
+ [shadow setShadowBlurRadius:2.75 * scale];
+ [xPath fillWithInnerShadow:shadow scale:scale];
+ return imageRep;
}
@end
diff --git a/third_party/molokocacao/NSBezierPath+MCAdditions.h b/third_party/molokocacao/NSBezierPath+MCAdditions.h
index 54ab2c6..eb64479 100644
--- a/third_party/molokocacao/NSBezierPath+MCAdditions.h
+++ b/third_party/molokocacao/NSBezierPath+MCAdditions.h
@@ -16,7 +16,7 @@
- (NSBezierPath*)pathWithStrokeWidth:(CGFloat)strokeWidth;
-- (void)fillWithInnerShadow:(NSShadow*)shadow;
+- (void)fillWithInnerShadow:(NSShadow *)shadow scale:(float)scale;
- (void)drawBlurWithColor:(NSColor*)color radius:(CGFloat)radius;
- (void)strokeInside;
diff --git a/third_party/molokocacao/NSBezierPath+MCAdditions.m b/third_party/molokocacao/NSBezierPath+MCAdditions.m
index e1771cc..250a3ba 100644
--- a/third_party/molokocacao/NSBezierPath+MCAdditions.m
+++ b/third_party/molokocacao/NSBezierPath+MCAdditions.m
@@ -92,7 +92,7 @@ static void CGPathCallback(void *info, const CGPathElement *element)
#endif // MCBEZIER_USE_PRIVATE_FUNCTION
}
-- (void)fillWithInnerShadow:(NSShadow *)shadow
+- (void)fillWithInnerShadow:(NSShadow *)shadow scale:(float)scale
{
[NSGraphicsContext saveGraphicsState];
@@ -100,7 +100,9 @@ static void CGPathCallback(void *info, const CGPathElement *element)
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;
+
+ // The context's user transform isn't automatically applied to shadow offsets.
+ offset.height += scale * bounds.size.height;
shadow.shadowOffset = offset;
NSAffineTransform *transform = [NSAffineTransform transform];
if ([[NSGraphicsContext currentContext] isFlipped])
diff --git a/third_party/molokocacao/README.chromium b/third_party/molokocacao/README.chromium
index 53ed629..060b3cf 100644
--- a/third_party/molokocacao/README.chromium
+++ b/third_party/molokocacao/README.chromium
@@ -4,6 +4,7 @@ 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
+Security critical: YES
Description:
Additions to NSBezierPath to make certain operations more convenient (inner
@@ -12,3 +13,4 @@ shadows on paths, for example).
Local Modifications:
- Added LICENSE file based on email correspondence with Sean.
- Added header guards.
+ - Added a "scale:" parameter to fillWithInnerShadow:.