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

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

Issue 12315069: Mac: Update zoom bubble UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 7 years, 9 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/memory/scoped_nsobject.h" 9 #include "base/memory/scoped_nsobject.h"
10 #include "chrome/common/chrome_notification_types.h" 10 #include "chrome/common/chrome_notification_types.h"
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 } 89 }
90 } 90 }
91 91
92 @end 92 @end
93 93
94 94
95 @implementation InfoBubbleWindow 95 @implementation InfoBubbleWindow
96 96
97 @synthesize delayOnClose = delayOnClose_; 97 @synthesize delayOnClose = delayOnClose_;
98 @synthesize canBecomeKeyWindow = canBecomeKeyWindow_; 98 @synthesize canBecomeKeyWindow = canBecomeKeyWindow_;
99 @synthesize enableAnimations = enableAnimations_;
99 100
100 - (id)initWithContentRect:(NSRect)contentRect 101 - (id)initWithContentRect:(NSRect)contentRect
101 styleMask:(NSUInteger)aStyle 102 styleMask:(NSUInteger)aStyle
102 backing:(NSBackingStoreType)bufferingType 103 backing:(NSBackingStoreType)bufferingType
103 defer:(BOOL)flag { 104 defer:(BOOL)flag {
104 if ((self = [super initWithContentRect:contentRect 105 if ((self = [super initWithContentRect:contentRect
105 styleMask:NSBorderlessWindowMask 106 styleMask:NSBorderlessWindowMask
106 backing:bufferingType 107 backing:bufferingType
107 defer:flag])) { 108 defer:flag])) {
108 [self setBackgroundColor:[NSColor clearColor]]; 109 [self setBackgroundColor:[NSColor clearColor]];
109 [self setExcludedFromWindowsMenu:YES]; 110 [self setExcludedFromWindowsMenu:YES];
110 [self setOpaque:NO]; 111 [self setOpaque:NO];
111 [self setHasShadow:YES]; 112 [self setHasShadow:YES];
112 delayOnClose_ = YES; 113 delayOnClose_ = YES;
113 canBecomeKeyWindow_ = YES; 114 canBecomeKeyWindow_ = YES;
115 enableAnimations_ = YES;
114 notificationBridge_.reset(new AppNotificationBridge(self)); 116 notificationBridge_.reset(new AppNotificationBridge(self));
115 117
116 // Start invisible. Will be made visible when ordered front. 118 // Start invisible. Will be made visible when ordered front.
117 [self setAlphaValue:0.0]; 119 [self setAlphaValue:0.0];
118 120
119 // Set up alphaValue animation so that self is delegate for the animation. 121 // Set up alphaValue animation so that self is delegate for the animation.
120 // Setting up the delegate is required so that the 122 // Setting up the delegate is required so that the
121 // animationDidStop:finished: callback can be handled. 123 // animationDidStop:finished: callback can be handled.
122 // Notice that only the alphaValue Animation is replaced in case 124 // Notice that only the alphaValue Animation is replaced in case
123 // superclasses set up animations. 125 // superclasses set up animations.
(...skipping 27 matching lines...) Expand all
151 - (void)close { 153 - (void)close {
152 // Block the window from receiving events while it fades out. 154 // Block the window from receiving events while it fades out.
153 closing_ = YES; 155 closing_ = YES;
154 156
155 if (!delayOnClose_) { 157 if (!delayOnClose_) {
156 [self finishCloseAfterAnimation]; 158 [self finishCloseAfterAnimation];
157 } else { 159 } else {
158 // Apply animations to hide self. 160 // Apply animations to hide self.
159 [NSAnimationContext beginGrouping]; 161 [NSAnimationContext beginGrouping];
160 [[NSAnimationContext currentContext] 162 [[NSAnimationContext currentContext]
161 gtm_setDuration:kOrderOutAnimationDuration 163 gtm_setDuration:enableAnimations_ ? kOrderOutAnimationDuration :
164 kMinimumTimeInterval
162 eventMask:NSLeftMouseUpMask]; 165 eventMask:NSLeftMouseUpMask];
163 [[self animator] setAlphaValue:0.0]; 166 [[self animator] setAlphaValue:0.0];
164 [NSAnimationContext endGrouping]; 167 [NSAnimationContext endGrouping];
165 } 168 }
166 } 169 }
167 170
168 // If the app is terminating but the window is still fading out, cancel the 171 // If the app is terminating but the window is still fading out, cancel the
169 // animation and close the window to prevent it from leaking. 172 // animation and close the window to prevent it from leaking.
170 // See http://crbug.com/37717 173 // See http://crbug.com/37717
171 - (void)appIsTerminating { 174 - (void)appIsTerminating {
(...skipping 28 matching lines...) Expand all
200 // Set up frame so it can be adjust down by a few pixels. 203 // Set up frame so it can be adjust down by a few pixels.
201 NSRect frame = [self frame]; 204 NSRect frame = [self frame];
202 NSPoint newOrigin = frame.origin; 205 NSPoint newOrigin = frame.origin;
203 newOrigin.y += kOrderInSlideOffset; 206 newOrigin.y += kOrderInSlideOffset;
204 [self setFrameOrigin:newOrigin]; 207 [self setFrameOrigin:newOrigin];
205 208
206 // Apply animations to show and move self. 209 // Apply animations to show and move self.
207 [NSAnimationContext beginGrouping]; 210 [NSAnimationContext beginGrouping];
208 // The star currently triggers on mouse down, not mouse up. 211 // The star currently triggers on mouse down, not mouse up.
209 [[NSAnimationContext currentContext] 212 [[NSAnimationContext currentContext]
210 gtm_setDuration:kOrderInAnimationDuration 213 gtm_setDuration:enableAnimations_ ? kOrderInAnimationDuration :
214 kMinimumTimeInterval
211 eventMask:NSLeftMouseUpMask|NSLeftMouseDownMask]; 215 eventMask:NSLeftMouseUpMask|NSLeftMouseDownMask];
212 [[self animator] setAlphaValue:1.0]; 216 [[self animator] setAlphaValue:1.0];
213 [[self animator] setFrame:frame display:YES]; 217 [[self animator] setFrame:frame display:YES];
214 [NSAnimationContext endGrouping]; 218 [NSAnimationContext endGrouping];
215 } else { 219 } else {
216 [super orderWindow:orderingMode relativeTo:otherWindowNumber]; 220 [super orderWindow:orderingMode relativeTo:otherWindowNumber];
217 } 221 }
218 } 222 }
219 223
220 // If the window is currently animating a close, block all UI events to the 224 // If the window is currently animating a close, block all UI events to the
221 // window. 225 // window.
222 - (void)sendEvent:(NSEvent*)theEvent { 226 - (void)sendEvent:(NSEvent*)theEvent {
223 if (!closing_) 227 if (!closing_)
224 [super sendEvent:theEvent]; 228 [super sendEvent:theEvent];
225 } 229 }
226 230
227 - (BOOL)isClosing { 231 - (BOOL)isClosing {
228 return closing_; 232 return closing_;
229 } 233 }
230 234
231 @end 235 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698