OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #import "chrome/browser/ui/cocoa/exclusive_access_bubble_view.h" | |
6 | |
7 #include "base/mac/scoped_nsobject.h" | |
8 #include "ui/gfx/scoped_ns_graphics_context_save_gstate_mac.h" | |
9 | |
10 namespace { | |
11 | |
12 const CGFloat kShadowTop = 20; | |
13 const CGFloat kShadowBottom = 50; | |
14 const CGFloat kShadowLeft = 50; | |
15 const CGFloat kShadowRight = 50; | |
16 const CGFloat kShadowBlurRadius = 30; | |
17 const CGFloat kShadowAlpha = 0.5; | |
18 const CGFloat kBubbleCornerRadius = 8.0; | |
19 } | |
20 | |
21 @implementation ExclusiveAccessBubbleView | |
22 | |
23 - (void)drawRect:(NSRect)rect { | |
24 // Make room for the border to be seen. | |
25 NSRect bounds = [self bounds]; | |
26 bounds.size.width -= kShadowLeft + kShadowRight; | |
27 bounds.size.height -= kShadowTop + kShadowBottom; | |
28 bounds.origin.x += kShadowLeft; | |
29 bounds.origin.y += kShadowBottom; | |
30 NSBezierPath* bezier = [NSBezierPath bezierPath]; | |
31 | |
32 CGFloat radius = kBubbleCornerRadius; | |
33 // Start with a rounded rectangle. | |
34 [bezier appendBezierPathWithRoundedRect:bounds xRadius:radius yRadius:radius]; | |
35 | |
36 [bezier closePath]; | |
37 [[NSColor whiteColor] set]; | |
38 gfx::ScopedNSGraphicsContextSaveGState scoped_g_state; | |
39 base::scoped_nsobject<NSShadow> shadow([[NSShadow alloc] init]); | |
40 [shadow setShadowBlurRadius:kShadowBlurRadius]; | |
41 [shadow setShadowColor:[[NSColor blackColor] | |
42 colorWithAlphaComponent:kShadowAlpha]]; | |
43 [shadow set]; | |
44 | |
45 [bezier fill]; | |
46 } | |
47 | |
48 @end | |
OLD | NEW |