OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import <Cocoa/Cocoa.h> |
| 6 |
| 7 #import "base/mac/scoped_nsobject.h" |
| 8 #include "base/callback.h" |
| 9 #include "ui/base/ui_base_export.h" |
| 10 |
| 11 // Controller for animations that show or hide an NSWindow. Used for cases where |
| 12 // -[NSWindow setAnimationBehavior:] is unable to provide the necessary |
| 13 // characteristics. For example WindowAnimationController allows the animation |
| 14 // to be canceled, and works for windows containing remote CALayers. |
| 15 UI_BASE_EXPORT |
| 16 @interface WindowAnimationController : NSObject<NSAnimationDelegate> { |
| 17 @private |
| 18 // When closing, the window to close. Retained until the animation ends. |
| 19 base::scoped_nsobject<NSWindow> window_; |
| 20 |
| 21 // The animation started and owned by |self|. Reset when the animation ends. |
| 22 base::scoped_nsobject<NSViewAnimation> animation_; |
| 23 |
| 24 // If non-null, callback triggered when the animation completes. Then reset. |
| 25 base::Closure callback_; |
| 26 |
| 27 // Animation durations. Default is 0.2 seconds. |
| 28 NSTimeInterval orderInDuration_; |
| 29 NSTimeInterval orderOutDuration_; |
| 30 } |
| 31 |
| 32 @property(assign, nonatomic) NSTimeInterval orderInDuration; |
| 33 @property(assign, nonatomic) NSTimeInterval orderOutDuration; |
| 34 |
| 35 // Returns whether |window_| is scheduled to be closed when the animation ends. |
| 36 - (BOOL)isClosing; |
| 37 |
| 38 // Animate |window| to show or close it, after canceling any current animation. |
| 39 // Translates from the current location to |targetOrigin| and fades out (if |
| 40 // closing), or fades in. Note: If a previous animation is canceled in this way |
| 41 // any previous |callback_| is NOT run (and the window is not closed). That is, |
| 42 // the close is effectively interrupted, allowing the window to be shown again. |
| 43 // Also note that canceling an animation moves it to the end frame, which can |
| 44 // cause a jump. |
| 45 - (void)animateWindow:(NSWindow*)window |
| 46 targetOrigin:(NSPoint)targetOrigin |
| 47 closing:(BOOL)closing |
| 48 callback:(const base::Closure&)callback; |
| 49 |
| 50 // Stops the animation (moving to the end frame), closes |window_| (if set) and |
| 51 // runs |callback_|. |
| 52 - (void)cancelAnimationWithCallback; |
| 53 |
| 54 @end |
OLD | NEW |