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