OLD | NEW |
(Empty) | |
| 1 // Copyright 2012 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 #ifndef IOS_CHROME_BROWSER_UI_STACK_VIEW_PAGE_ANIMATION_UTIL_H_ |
| 6 #define IOS_CHROME_BROWSER_UI_STACK_VIEW_PAGE_ANIMATION_UTIL_H_ |
| 7 |
| 8 #import <CoreGraphics/CoreGraphics.h> |
| 9 #import <QuartzCore/QuartzCore.h> |
| 10 |
| 11 @class CardView; |
| 12 @class UIView; |
| 13 |
| 14 // Utilities for handling the animations of a page opening or closing. |
| 15 // The expected use is to create a view with the same size and position as the |
| 16 // page content area, add it to the view hierarchy, then call the appropriate |
| 17 // animation method. |
| 18 namespace ios_internal { |
| 19 |
| 20 namespace page_animation_util { |
| 21 |
| 22 // The standard margin between a card and the edge of the content view, in |
| 23 // pixels. |
| 24 extern const CGFloat kCardMargin; |
| 25 |
| 26 // Animation start positions. |
| 27 enum TabStartPosition { |
| 28 // From offscreen on the right. |
| 29 START_RIGHT, |
| 30 // From offscreen on the left. |
| 31 START_LEFT |
| 32 }; |
| 33 |
| 34 // Applies a transformation that moves |view| to the new tab animation start |
| 35 // position. The new tab starts translated down; if |start| is RIGHT, it is |
| 36 // rotated clockwise and translated to the right; if LEFT, it is rotated |
| 37 // counter-clockwise and translated to the left. |
| 38 void SetTabAnimationStartPositionForView(UIView* view, TabStartPosition start); |
| 39 |
| 40 // Adjusts the position of |view| to where a card (pre-MD) animate-in effect |
| 41 // should start, then animates the view back to its original position (calling |
| 42 // |extraAnimation| in the same animation context), and finally calls the given |
| 43 // completion block when finished. For MD, this is still used when a card is |
| 44 // added in the background while in the stack view. |
| 45 void AnimateInCardWithAnimationAndCompletion(UIView* view, |
| 46 void (^extraAnimation)(void), |
| 47 void (^completion)(void)); |
| 48 |
| 49 // Adjusts the position of |view| to |origin|, then animates with a MD |
| 50 // animate-in effect, animating the view back to its original position (calling |
| 51 // |extraAnimation| in the same animation context), and finally calls the given |
| 52 // completion block when finished. |paperOffset| and |contentOffset| describe |
| 53 // the vertical offset for the paper animation and the |view| animation |
| 54 // respectively. |
| 55 void AnimateInPaperWithAnimationAndCompletion(UIView* view, |
| 56 CGFloat paperOffset, |
| 57 CGFloat contentOffset, |
| 58 CGPoint origin, |
| 59 BOOL isOffTheRecord, |
| 60 void (^extraAnimation)(void), |
| 61 void (^completion)(void)); |
| 62 |
| 63 // Sets |currentPageCard| to the size of |displayFrame|, animates it into a |
| 64 // standard inset CardView (just as in the appearance of a single-stack |
| 65 // StackViewController), and out again. Creates and moves a paper card into the |
| 66 // center of the screen, and then slides it offscreen. |completion| is |
| 67 // called at the end of the sequence. |displayFrame| gives the frame within |
| 68 // which the animation will take place. |
| 69 void AnimateNewBackgroundPageWithCompletion(CardView* currentPageCard, |
| 70 CGRect displayFrame, |
| 71 BOOL isPortrait, |
| 72 void (^completion)(void)); |
| 73 |
| 74 // Sets |currentPageCard| to the size of |displayFrame|, animates it into a |
| 75 // standard inset CardView (just as in the appearance of a single-stack |
| 76 // StackViewController), and out again. Moves |newCard| offscreen, then rotates |
| 77 // it into its given position, and finally slides it offscreen. |completion| is |
| 78 // called at the end of the sequence. |displayFrame| gives the frame within |
| 79 // which the animation will take place. |
| 80 void AnimateNewBackgroundTabWithCompletion(CardView* currentPageCard, |
| 81 CardView* newCard, |
| 82 CGRect displayFrame, |
| 83 BOOL isPortrait, |
| 84 void (^completion)(void)); |
| 85 |
| 86 // Animates |view| to its final position following |delay| seconds, then calls |
| 87 // the given completion block when finished. |
| 88 void AnimateOutWithCompletion(UIView* view, |
| 89 NSTimeInterval delay, |
| 90 BOOL clockwise, |
| 91 BOOL isPortrait, |
| 92 void (^completion)(void)); |
| 93 |
| 94 // Returns a transform to rotate and translate the view in the proper direction |
| 95 // and |fraction| of |kAnimateInInitialHorizontalOffset|, |
| 96 // |kAnimateInInitialVerticalOffset| and |kCardRotationAnimationStart|. |
| 97 CGAffineTransform AnimateOutTransform(CGFloat fraction, |
| 98 BOOL clockwise, |
| 99 BOOL isPortrait); |
| 100 |
| 101 // Returns the breadth of the animation-out transform. |
| 102 CGFloat AnimateOutTransformBreadth(); |
| 103 |
| 104 } // namespace page_animation_util |
| 105 |
| 106 } // namespace ios_internal |
| 107 |
| 108 #endif // IOS_CHROME_BROWSER_UI_STACK_VIEW_PAGE_ANIMATION_UTIL_H_ |
OLD | NEW |