OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #import "chrome/browser/ui/cocoa/exclusive_access_bubble_view.h" | 5 #import "chrome/browser/ui/cocoa/exclusive_access_bubble_view.h" |
6 | 6 |
7 #include "base/mac/mac_util.h" | |
8 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
9 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | 8 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" |
10 | 9 |
11 namespace { | 10 namespace { |
12 | 11 |
13 const CGFloat kShadowTop = 20; | 12 const CGFloat kShadowTop = 20; |
14 const CGFloat kShadowBottom = 50; | 13 const CGFloat kShadowBottom = 50; |
15 const CGFloat kShadowLeft = 50; | 14 const CGFloat kShadowLeft = 50; |
16 const CGFloat kShadowRight = 50; | 15 const CGFloat kShadowRight = 50; |
17 const CGFloat kShadowBlurRadius = 150; | 16 const CGFloat kShadowBlurRadius = 30; |
18 // NOTE(koz): The blur radius parameter to setShadowBlurRadius: has a bigger | |
19 // effect on lion, so use a smaller value for it. | |
20 const CGFloat kShadowBlurRadiusLion = 30; | |
21 const CGFloat kShadowAlpha = 0.5; | 17 const CGFloat kShadowAlpha = 0.5; |
22 const CGFloat kBubbleCornerRadius = 8.0; | 18 const CGFloat kBubbleCornerRadius = 8.0; |
23 } | 19 } |
24 | 20 |
25 @implementation ExclusiveAccessBubbleView | 21 @implementation ExclusiveAccessBubbleView |
26 | 22 |
27 - (void)drawRect:(NSRect)rect { | 23 - (void)drawRect:(NSRect)rect { |
28 // Make room for the border to be seen. | 24 // Make room for the border to be seen. |
29 NSRect bounds = [self bounds]; | 25 NSRect bounds = [self bounds]; |
30 bounds.size.width -= kShadowLeft + kShadowRight; | 26 bounds.size.width -= kShadowLeft + kShadowRight; |
31 bounds.size.height -= kShadowTop + kShadowBottom; | 27 bounds.size.height -= kShadowTop + kShadowBottom; |
32 bounds.origin.x += kShadowLeft; | 28 bounds.origin.x += kShadowLeft; |
33 bounds.origin.y += kShadowBottom; | 29 bounds.origin.y += kShadowBottom; |
34 NSBezierPath* bezier = [NSBezierPath bezierPath]; | 30 NSBezierPath* bezier = [NSBezierPath bezierPath]; |
35 | 31 |
36 CGFloat radius = kBubbleCornerRadius; | 32 CGFloat radius = kBubbleCornerRadius; |
37 // Start with a rounded rectangle. | 33 // Start with a rounded rectangle. |
38 [bezier appendBezierPathWithRoundedRect:bounds xRadius:radius yRadius:radius]; | 34 [bezier appendBezierPathWithRoundedRect:bounds xRadius:radius yRadius:radius]; |
39 | 35 |
40 [bezier closePath]; | 36 [bezier closePath]; |
41 [[NSColor whiteColor] set]; | 37 [[NSColor whiteColor] set]; |
42 gfx::ScopedNSGraphicsContextSaveGState scoped_g_state; | 38 gfx::ScopedNSGraphicsContextSaveGState scoped_g_state; |
43 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); | 39 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); |
44 if (base::mac::IsOSLionOrLater()) { | 40 [shadow setShadowBlurRadius:kShadowBlurRadius]; |
45 [shadow setShadowBlurRadius:kShadowBlurRadiusLion]; | |
46 } else { | |
47 [shadow setShadowBlurRadius:kShadowBlurRadius]; | |
48 } | |
49 [shadow setShadowColor:[[NSColor blackColor] | 41 [shadow setShadowColor:[[NSColor blackColor] |
50 colorWithAlphaComponent:kShadowAlpha]]; | 42 colorWithAlphaComponent:kShadowAlpha]]; |
51 [shadow set]; | 43 [shadow set]; |
52 | 44 |
53 [bezier fill]; | 45 [bezier fill]; |
54 } | 46 } |
55 | 47 |
56 @end | 48 @end |
OLD | NEW |