| OLD | NEW |
| 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/constrained_window/constrained_window_custom_sh
eet.h" | 5 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_custom_sh
eet.h" |
| 6 | 6 |
| 7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" | 7 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" |
| 8 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" | 8 #import "ui/base/cocoa/constrained_window/constrained_window_animation.h" |
| 9 | 9 |
| 10 // Length of the animation in seconds. | 10 // Length of the animation in seconds. |
| 11 const NSTimeInterval kAnimationDuration = 0.18; | 11 const NSTimeInterval kAnimationDuration = 0.18; |
| 12 | 12 |
| 13 @implementation CustomConstrainedWindowSheet | 13 @implementation CustomConstrainedWindowSheet |
| 14 | 14 |
| 15 - (id)initWithCustomWindow:(NSWindow*)customWindow { | 15 - (id)initWithCustomWindow:(NSWindow*)customWindow { |
| 16 if ((self = [super init])) { | 16 if ((self = [super init])) { |
| 17 customWindow_.reset([customWindow retain]); | 17 customWindow_.reset([customWindow retain]); |
| 18 } | 18 } |
| 19 return self; | 19 return self; |
| 20 } | 20 } |
| 21 | 21 |
| 22 - (void)setUseSimpleAnimations:(BOOL)simpleAnimations { | 22 - (void)setUseSimpleAnimations:(BOOL)simpleAnimations { |
| 23 useSimpleAnimations_ = simpleAnimations; | 23 useSimpleAnimations_ = simpleAnimations; |
| 24 } | 24 } |
| 25 | 25 |
| 26 - (void)showSheetForWindow:(NSWindow*)window { | 26 - (void)showSheetForWindow:(NSWindow*)window { |
| 27 base::scoped_nsobject<NSAnimation> animation; | 27 base::scoped_nsobject<NSAnimation> animation; |
| 28 if (!useSimpleAnimations_) { | 28 if (useSimpleAnimations_) { |
| 29 [customWindow_ setAlphaValue:0.0]; |
| 30 } else { |
| 29 animation.reset( | 31 animation.reset( |
| 30 [[ConstrainedWindowAnimationShow alloc] initWithWindow:customWindow_]); | 32 [[ConstrainedWindowAnimationShow alloc] initWithWindow:customWindow_]); |
| 31 } | 33 } |
| 32 [window addChildWindow:customWindow_ | 34 [window addChildWindow:customWindow_ |
| 33 ordered:NSWindowAbove]; | 35 ordered:NSWindowAbove]; |
| 34 [self unhideSheet]; | 36 [self unhideSheet]; |
| 35 [self updateSheetPosition]; | 37 [self updateSheetPosition]; |
| 36 [customWindow_ makeKeyAndOrderFront:nil]; | 38 [customWindow_ makeKeyAndOrderFront:nil]; |
| 37 | 39 |
| 38 if (useSimpleAnimations_) { | 40 if (useSimpleAnimations_) { |
| 39 [customWindow_ setAlphaValue:0.0]; | |
| 40 [NSAnimationContext beginGrouping]; | 41 [NSAnimationContext beginGrouping]; |
| 41 [[NSAnimationContext currentContext] setDuration:kAnimationDuration]; | 42 [[NSAnimationContext currentContext] setDuration:kAnimationDuration]; |
| 42 [[customWindow_ animator] setAlphaValue:1.0]; | 43 [[customWindow_ animator] setAlphaValue:1.0]; |
| 43 [NSAnimationContext endGrouping]; | 44 [NSAnimationContext endGrouping]; |
| 44 } else { | 45 } else { |
| 45 [animation startAnimation]; | 46 [animation startAnimation]; |
| 46 } | 47 } |
| 47 } | 48 } |
| 48 | 49 |
| 49 - (void)closeSheetWithAnimation:(BOOL)withAnimation { | 50 - (void)closeSheetWithAnimation:(BOOL)withAnimation { |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 | 108 |
| 108 - (void)resizeWithNewSize:(NSSize)size { | 109 - (void)resizeWithNewSize:(NSSize)size { |
| 109 // NOOP | 110 // NOOP |
| 110 } | 111 } |
| 111 | 112 |
| 112 - (NSWindow*)sheetWindow { | 113 - (NSWindow*)sheetWindow { |
| 113 return customWindow_; | 114 return customWindow_; |
| 114 } | 115 } |
| 115 | 116 |
| 116 @end | 117 @end |
| OLD | NEW |