Chromium Code Reviews| Index: chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm |
| diff --git a/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm b/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm |
| index ab67fc6804b9dea5550e579b8a0dac4039b480d0..b970b02bcf58b06df91cd66d459a29e4c22af5d7 100644 |
| --- a/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm |
| +++ b/chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sheet.mm |
| @@ -7,6 +7,9 @@ |
| #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_controller.h" |
| #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" |
| +// Length of the animation in seconds. |
| +const NSTimeInterval kAnimationDuration = 0.18; |
| + |
| @implementation CustomConstrainedWindowSheet |
| - (id)initWithCustomWindow:(NSWindow*)customWindow { |
| @@ -16,21 +19,48 @@ |
| return self; |
| } |
| +- (void)setUseSimpleAnimations:(BOOL)simpleAnimations { |
| + useSimpleAnimations_ = simpleAnimations; |
| +} |
| + |
| - (void)showSheetForWindow:(NSWindow*)window { |
| - base::scoped_nsobject<NSAnimation> animation( |
| - [[ConstrainedWindowAnimationShow alloc] initWithWindow:customWindow_]); |
| + base::scoped_nsobject<NSAnimation> animation; |
| + if (!useSimpleAnimations_) { |
| + animation.reset( |
| + [[ConstrainedWindowAnimationShow alloc] initWithWindow:customWindow_]); |
| + } |
| [window addChildWindow:customWindow_ |
| ordered:NSWindowAbove]; |
| [self unhideSheet]; |
| [self updateSheetPosition]; |
| [customWindow_ makeKeyAndOrderFront:nil]; |
| - [animation startAnimation]; |
| + |
| + if (useSimpleAnimations_) { |
| + [customWindow_ setAlphaValue:0.0]; |
| + [[NSAnimationContext currentContext] setDuration:kAnimationDuration]; |
|
tapted
2016/03/15 00:39:40
I think we need a
[NSAnimationContext beginGroupi
erikchen
2016/03/15 00:52:25
Done.
|
| + [[customWindow_ animator] setAlphaValue:1.0]; |
| + } else { |
| + [animation startAnimation]; |
| + } |
| } |
| - (void)closeSheetWithAnimation:(BOOL)withAnimation { |
| if (withAnimation) { |
| - base::scoped_nsobject<NSAnimation> animation( |
| - [[ConstrainedWindowAnimationHide alloc] initWithWindow:customWindow_]); |
| + base::scoped_nsobject<NSAnimation> animation; |
| + if (useSimpleAnimations_) { |
| + // Use a blocking animation, rather than -[NSWindow animator]. |
| + NSArray* animationArray = @[ @{ |
| + NSViewAnimationTargetKey : customWindow_, |
| + NSViewAnimationEffectKey : NSViewAnimationFadeOutEffect, |
| + } ]; |
| + animation.reset( |
| + [[NSViewAnimation alloc] initWithViewAnimations:animationArray]); |
| + [animation setDuration:kAnimationDuration]; |
| + [animation setAnimationBlockingMode:NSAnimationBlocking]; |
| + } else { |
| + animation.reset([[ConstrainedWindowAnimationHide alloc] |
| + initWithWindow:customWindow_]); |
| + } |
| [animation startAnimation]; |
| } |