Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(248)

Side by Side Diff: chrome/browser/ui/cocoa/info_bubble_window.mm

Issue 10272035: [Mac] Give info bubble windows a gaussian blur and a smaller border radius. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: _CGSDefaultConnection Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/info_bubble_view.mm ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/info_bubble_window.h" 5 #import "chrome/browser/ui/cocoa/info_bubble_window.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/mac/foundation_util.h"
9 #include "base/memory/scoped_nsobject.h" 10 #include "base/memory/scoped_nsobject.h"
10 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
11 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
12 #include "content/public/browser/notification_service.h" 13 #include "content/public/browser/notification_service.h"
13 #include "content/public/browser/notification_types.h" 14 #include "content/public/browser/notification_types.h"
14 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h" 15 #import "third_party/GTM/AppKit/GTMNSAnimation+Duration.h"
15 16
16 namespace { 17 namespace {
17 const CGFloat kOrderInSlideOffset = 10; 18 const CGFloat kOrderInSlideOffset = 10;
18 const NSTimeInterval kOrderInAnimationDuration = 0.075; 19 const NSTimeInterval kOrderInAnimationDuration = 0.075;
19 const NSTimeInterval kOrderOutAnimationDuration = 0.15; 20 const NSTimeInterval kOrderOutAnimationDuration = 0.15;
20 // The minimum representable time interval. This can be used as the value 21 // The minimum representable time interval. This can be used as the value
21 // passed to +[NSAnimationContext setDuration:] to stop an in-progress 22 // passed to +[NSAnimationContext setDuration:] to stop an in-progress
22 // animation as quickly as possible. 23 // animation as quickly as possible.
23 const NSTimeInterval kMinimumTimeInterval = 24 const NSTimeInterval kMinimumTimeInterval =
24 std::numeric_limits<NSTimeInterval>::min(); 25 std::numeric_limits<NSTimeInterval>::min();
25 } 26 } // namespace
26 27
27 @interface InfoBubbleWindow(Private) 28 // Forward declare private window server functions used to style the window.
29 extern "C" {
30 typedef int CGSConnection;
31 typedef int CGSWindow;
32 typedef void* CGSWindowFilterRef;
33
34 CGSConnection _CGSDefaultConnection();
35 CGError CGSNewCIFilterByName(CGSConnection cid,
36 CFStringRef filterName,
37 CGSWindowFilterRef *outFilter);
38 CGError CGSAddWindowFilter(CGSConnection cid,
39 CGSWindow wid,
40 CGSWindowFilterRef filter,
41 int flags);
42 CGError CGSReleaseCIFilter(CGSConnection cid, CGSWindowFilterRef filter);
43 CGError CGSSetCIFilterValuesFromDictionary(
44 CGSConnection cid, CGSWindowFilterRef filter, CFDictionaryRef filterValues);
45 } // extern "C"
46
47 @interface InfoBubbleWindow (Private)
28 - (void)appIsTerminating; 48 - (void)appIsTerminating;
29 - (void)finishCloseAfterAnimation; 49 - (void)finishCloseAfterAnimation;
30 @end 50 @end
31 51
32 // A helper class to proxy app notifications to the window. 52 // A helper class to proxy app notifications to the window.
33 class AppNotificationBridge : public content::NotificationObserver { 53 class AppNotificationBridge : public content::NotificationObserver {
34 public: 54 public:
35 explicit AppNotificationBridge(InfoBubbleWindow* owner) : owner_(owner) { 55 explicit AppNotificationBridge(InfoBubbleWindow* owner) : owner_(owner) {
36 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, 56 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING,
37 content::NotificationService::AllSources()); 57 content::NotificationService::AllSources());
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 // Order self appropriately assuming that its alpha is zero as set up 215 // Order self appropriately assuming that its alpha is zero as set up
196 // in the designated initializer. 216 // in the designated initializer.
197 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; 217 [super orderWindow:orderingMode relativeTo:otherWindowNumber];
198 218
199 // Set up frame so it can be adjust down by a few pixels. 219 // Set up frame so it can be adjust down by a few pixels.
200 NSRect frame = [self frame]; 220 NSRect frame = [self frame];
201 NSPoint newOrigin = frame.origin; 221 NSPoint newOrigin = frame.origin;
202 newOrigin.y += kOrderInSlideOffset; 222 newOrigin.y += kOrderInSlideOffset;
203 [self setFrameOrigin:newOrigin]; 223 [self setFrameOrigin:newOrigin];
204 224
225 // Add a gaussian blur to the window.
226 CGSConnection cgsConnection = _CGSDefaultConnection();
227 CGSWindowFilterRef filter;
228 if (CGSNewCIFilterByName(cgsConnection, CFSTR("CIGaussianBlur"),
229 &filter) == kCGErrorSuccess) {
230 NSDictionary* blurOptions =
231 [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:1.5]
232 forKey:@"inputRadius"];
233
234 if (CGSSetCIFilterValuesFromDictionary(cgsConnection, filter,
235 base::mac::NSToCFCast(blurOptions)) == kCGErrorSuccess) {
236 CGSAddWindowFilter(cgsConnection, [self windowNumber], filter, 1);
237 }
238
239 CGSReleaseCIFilter(cgsConnection, filter);
240 }
241
205 // Apply animations to show and move self. 242 // Apply animations to show and move self.
206 [NSAnimationContext beginGrouping]; 243 [NSAnimationContext beginGrouping];
207 // The star currently triggers on mouse down, not mouse up. 244 // The star currently triggers on mouse down, not mouse up.
208 [[NSAnimationContext currentContext] 245 [[NSAnimationContext currentContext]
209 gtm_setDuration:kOrderInAnimationDuration 246 gtm_setDuration:kOrderInAnimationDuration
210 eventMask:NSLeftMouseUpMask|NSLeftMouseDownMask]; 247 eventMask:NSLeftMouseUpMask|NSLeftMouseDownMask];
211 [[self animator] setAlphaValue:1.0]; 248 [[self animator] setAlphaValue:1.0];
212 [[self animator] setFrame:frame display:YES]; 249 [[self animator] setFrame:frame display:YES];
213 [NSAnimationContext endGrouping]; 250 [NSAnimationContext endGrouping];
214 } else { 251 } else {
215 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; 252 [super orderWindow:orderingMode relativeTo:otherWindowNumber];
216 } 253 }
217 } 254 }
218 255
219 // If the window is currently animating a close, block all UI events to the 256 // If the window is currently animating a close, block all UI events to the
220 // window. 257 // window.
221 - (void)sendEvent:(NSEvent*)theEvent { 258 - (void)sendEvent:(NSEvent*)theEvent {
222 if (!closing_) 259 if (!closing_)
223 [super sendEvent:theEvent]; 260 [super sendEvent:theEvent];
224 } 261 }
225 262
226 - (BOOL)isClosing { 263 - (BOOL)isClosing {
227 return closing_; 264 return closing_;
228 } 265 }
229 266
230 @end 267 @end
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/info_bubble_view.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698