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

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: 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
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 OSStatus CGSNewConnection(const void** attr, CGSConnection* cid);
35 OSStatus CGSReleaseConnection(CGSConnection cid);
36 CGError CGSNewCIFilterByName(CGSConnection cid,
37 CFStringRef filterName,
38 CGSWindowFilterRef *outFilter);
39 CGError CGSAddWindowFilter(CGSConnection cid,
40 CGSWindow wid,
41 CGSWindowFilterRef filter,
42 int flags);
43 CGError CGSReleaseCIFilter(CGSConnection cid, CGSWindowFilterRef filter);
44 CGError CGSSetCIFilterValuesFromDictionary(
45 CGSConnection cid, CGSWindowFilterRef filter, CFDictionaryRef filterValues);
46 } // extern "C"
47
48 @interface InfoBubbleWindow (Private)
28 - (void)appIsTerminating; 49 - (void)appIsTerminating;
29 - (void)finishCloseAfterAnimation; 50 - (void)finishCloseAfterAnimation;
30 @end 51 @end
31 52
32 // A helper class to proxy app notifications to the window. 53 // A helper class to proxy app notifications to the window.
33 class AppNotificationBridge : public content::NotificationObserver { 54 class AppNotificationBridge : public content::NotificationObserver {
34 public: 55 public:
35 explicit AppNotificationBridge(InfoBubbleWindow* owner) : owner_(owner) { 56 explicit AppNotificationBridge(InfoBubbleWindow* owner) : owner_(owner) {
36 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING, 57 registrar_.Add(this, content::NOTIFICATION_APP_TERMINATING,
37 content::NotificationService::AllSources()); 58 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 216 // Order self appropriately assuming that its alpha is zero as set up
196 // in the designated initializer. 217 // in the designated initializer.
197 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; 218 [super orderWindow:orderingMode relativeTo:otherWindowNumber];
198 219
199 // Set up frame so it can be adjust down by a few pixels. 220 // Set up frame so it can be adjust down by a few pixels.
200 NSRect frame = [self frame]; 221 NSRect frame = [self frame];
201 NSPoint newOrigin = frame.origin; 222 NSPoint newOrigin = frame.origin;
202 newOrigin.y += kOrderInSlideOffset; 223 newOrigin.y += kOrderInSlideOffset;
203 [self setFrameOrigin:newOrigin]; 224 [self setFrameOrigin:newOrigin];
204 225
226 // Add a gaussian blur to the window.
227 CGSConnection cgsConnection;
Nico 2012/05/01 20:02:41 = _CGSDefaultConnection(); ?
Robert Sesek 2012/05/01 20:08:12 Groovy.
228 if (CGSNewConnection(NULL, &cgsConnection) == noErr) {
229 CGSWindowFilterRef filter;
230 if (CGSNewCIFilterByName(cgsConnection, CFSTR("CIGaussianBlur"),
231 &filter) == kCGErrorSuccess) {
232 NSDictionary* blurOptions =
233 [NSDictionary dictionaryWithObject:[NSNumber numberWithFloat:1.5]
234 forKey:@"inputRadius"];
235
236 if (CGSSetCIFilterValuesFromDictionary(cgsConnection, filter,
237 base::mac::NSToCFCast(blurOptions)) == kCGErrorSuccess) {
238 CGSAddWindowFilter(cgsConnection, [self windowNumber], filter, 1);
239 }
240
241 CGSReleaseCIFilter(cgsConnection, filter);
242 }
243
244 CGSReleaseConnection(cgsConnection);
245 }
246
205 // Apply animations to show and move self. 247 // Apply animations to show and move self.
206 [NSAnimationContext beginGrouping]; 248 [NSAnimationContext beginGrouping];
207 // The star currently triggers on mouse down, not mouse up. 249 // The star currently triggers on mouse down, not mouse up.
208 [[NSAnimationContext currentContext] 250 [[NSAnimationContext currentContext]
209 gtm_setDuration:kOrderInAnimationDuration 251 gtm_setDuration:kOrderInAnimationDuration
210 eventMask:NSLeftMouseUpMask|NSLeftMouseDownMask]; 252 eventMask:NSLeftMouseUpMask|NSLeftMouseDownMask];
211 [[self animator] setAlphaValue:1.0]; 253 [[self animator] setAlphaValue:1.0];
212 [[self animator] setFrame:frame display:YES]; 254 [[self animator] setFrame:frame display:YES];
213 [NSAnimationContext endGrouping]; 255 [NSAnimationContext endGrouping];
214 } else { 256 } else {
215 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; 257 [super orderWindow:orderingMode relativeTo:otherWindowNumber];
216 } 258 }
217 } 259 }
218 260
219 // If the window is currently animating a close, block all UI events to the 261 // If the window is currently animating a close, block all UI events to the
220 // window. 262 // window.
221 - (void)sendEvent:(NSEvent*)theEvent { 263 - (void)sendEvent:(NSEvent*)theEvent {
222 if (!closing_) 264 if (!closing_)
223 [super sendEvent:theEvent]; 265 [super sendEvent:theEvent];
224 } 266 }
225 267
226 - (BOOL)isClosing { 268 - (BOOL)isClosing {
227 return closing_; 269 return closing_;
228 } 270 }
229 271
230 @end 272 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698