Skip to content

Commit

Permalink
Added the FTAnimationManager classes from FTUtils
Browse files Browse the repository at this point in the history
  • Loading branch information
neror committed Oct 1, 2009
1 parent 19f2700 commit f1bfd91
Show file tree
Hide file tree
Showing 3 changed files with 754 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CA360.xcodeproj/project.pbxproj
Expand Up @@ -19,6 +19,7 @@
DFAFBACF105EFF4200AE6FF1 /* LayerTransitions.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAFBACE105EFF4200AE6FF1 /* LayerTransitions.m */; };
DFAFBB8D105F0DD800AE6FF1 /* FTUtils+NSObject.m in Sources */ = {isa = PBXBuildFile; fileRef = DFAFBB8C105F0DD800AE6FF1 /* FTUtils+NSObject.m */; };
DFB121621060279A00E7DB00 /* Mario.png in Resources */ = {isa = PBXBuildFile; fileRef = DFB121611060279A00E7DB00 /* Mario.png */; };
DFF3A7761073A30900141522 /* FTAnimationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF3A7751073A30900141522 /* FTAnimationManager.m */; };
DFF70C321039D8BC0052EE6A /* ImageContent.m in Sources */ = {isa = PBXBuildFile; fileRef = DFF70C311039D8BC0052EE6A /* ImageContent.m */; };
DFF70C461039D9E60052EE6A /* FTSLogo.png in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C451039D9E60052EE6A /* FTSLogo.png */; };
DFF70C4F1039DA0A0052EE6A /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = DFF70C4C1039DA0A0052EE6A /* MainWindow.xib */; };
Expand Down Expand Up @@ -62,6 +63,8 @@
DFAFBB8B105F0DD800AE6FF1 /* FTUtils+NSObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "FTUtils+NSObject.h"; sourceTree = "<group>"; };
DFAFBB8C105F0DD800AE6FF1 /* FTUtils+NSObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "FTUtils+NSObject.m"; sourceTree = "<group>"; };
DFB121611060279A00E7DB00 /* Mario.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = Mario.png; sourceTree = "<group>"; };
DFF3A7741073A30900141522 /* FTAnimationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FTAnimationManager.h; sourceTree = "<group>"; };
DFF3A7751073A30900141522 /* FTAnimationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FTAnimationManager.m; sourceTree = "<group>"; };
DFF70C301039D8BC0052EE6A /* ImageContent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ImageContent.h; path = Classes/Samples/ImageContent.h; sourceTree = "<group>"; };
DFF70C311039D8BC0052EE6A /* ImageContent.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ImageContent.m; path = Classes/Samples/ImageContent.m; sourceTree = "<group>"; };
DFF70C451039D9E60052EE6A /* FTSLogo.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = FTSLogo.png; sourceTree = "<group>"; };
Expand Down Expand Up @@ -182,6 +185,8 @@
isa = PBXGroup;
children = (
DFAFBB8A105F0DD700AE6FF1 /* FTUtils.h */,
DFF3A7741073A30900141522 /* FTAnimationManager.h */,
DFF3A7751073A30900141522 /* FTAnimationManager.m */,
DFAFBB8B105F0DD800AE6FF1 /* FTUtils+NSObject.h */,
DFAFBB8C105F0DD800AE6FF1 /* FTUtils+NSObject.m */,
);
Expand Down Expand Up @@ -352,6 +357,7 @@
DFF70DC0103A11DF0052EE6A /* AnimationGroups.m in Sources */,
DFAFBACF105EFF4200AE6FF1 /* LayerTransitions.m in Sources */,
DFAFBB8D105F0DD800AE6FF1 /* FTUtils+NSObject.m in Sources */,
DFF3A7761073A30900141522 /* FTAnimationManager.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
152 changes: 152 additions & 0 deletions Support/FTAnimationManager.h
@@ -0,0 +1,152 @@
#import <Foundation/Foundation.h>
#import <QuartzCore/QuartzCore.h>
#import "FTUtils+NSObject.h"

typedef enum _FTAnimationDirection {
kFTAnimationTop = 0,
kFTAnimationRight,
kFTAnimationBottom,
kFTAnimationLeft
} FTAnimationDirection;

#pragma mark String Constants

extern NSString *const kFTAnimationName;
extern NSString *const kFTAnimationType;
extern NSString *const kFTAnimationTypeIn;
extern NSString *const kFTAnimationTypeOut;

extern NSString *const kFTAnimationSlideIn;
extern NSString *const kFTAnimationSlideOut;
extern NSString *const kFTAnimationBackOut;
extern NSString *const kFTAnimationBackIn;
extern NSString *const kFTAnimationFadeOut;
extern NSString *const kFTAnimationFadeIn;
extern NSString *const kFTAnimationFadeBackgroundOut;
extern NSString *const kFTAnimationFadeBackgroundIn;
extern NSString *const kFTAnimationPopIn;
extern NSString *const kFTAnimationPopOut;
extern NSString *const kFTAnimationFallIn;
extern NSString *const kFTAnimationFlyOut;
extern NSString *const kFTAnimationTargetViewKey;

#pragma mark Inline Functions

static inline CGPoint FTAnimationOffscreenCenterPoint(CGRect viewFrame, CGPoint viewCenter, FTAnimationDirection direction) {
CGRect screenRect = [[UIScreen mainScreen] bounds];
switch (direction) {
case kFTAnimationBottom: {
CGFloat extraOffset = viewFrame.size.height / 2;
return CGPointMake(viewCenter.x, screenRect.size.height + extraOffset);
break;
}
case kFTAnimationTop: {
CGFloat extraOffset = viewFrame.size.height / 2;
return CGPointMake(viewCenter.x, screenRect.origin.y - extraOffset);
break;
}
case kFTAnimationLeft: {
CGFloat extraOffset = viewFrame.size.width / 2;
return CGPointMake(screenRect.origin.x - extraOffset, viewCenter.y);
break;
}
case kFTAnimationRight: {
CGFloat extraOffset = viewFrame.size.width / 2;
return CGPointMake(screenRect.size.width + extraOffset, viewCenter.y);
break;
}
}
return CGPointZero;
}

@interface FTAnimationManager : NSObject {
CGFloat overshootThreshold_;
}

@property(assign) CGFloat overshootThreshold;

+ (FTAnimationManager *)sharedManager;

- (CAAnimation *)chainAnimations:(NSArray *)animations run:(BOOL)run;

- (CAAnimation *)slideInAnimationFor:(UIView *)view direction:(FTAnimationDirection)direction
duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (CAAnimation *)slideOutAnimationFor:(UIView *)view direction:(FTAnimationDirection)direction
duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;

- (CAAnimation *)backOutAnimationFor:(UIView *)view direction:(FTAnimationDirection)direction
duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (CAAnimation *)backInAnimationFor:(UIView *)view direction:(FTAnimationDirection)direction
duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;

- (CAAnimation *)fadeAnimationFor:(UIView *)view duration:(NSTimeInterval)duration
delegate:(id)delegate startSelector:(SEL)startSelector
stopSelector:(SEL)stopSelector fadeOut:(BOOL)fadeOut;

- (CAAnimation *)fadeBackgroundColorAnimationFor:(UIView *)view duration:(NSTimeInterval)duration
delegate:(id)delegate startSelector:(SEL)startSelector
stopSelector:(SEL)stopSelector fadeOut:(BOOL)fadeOut;

- (CAAnimation *)popInAnimationFor:(UIView *)view duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (CAAnimation *)popOutAnimationFor:(UIView *)view duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;

- (CAAnimation *)fallInAnimationFor:(UIView *)view duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (CAAnimation *)flyOutAnimationFor:(UIView *)view duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;


@end

@interface UIView (FTAnimationAdditions)

- (void)slideInFrom:(FTAnimationDirection)direction duration:(NSTimeInterval)duration delegate:(id)delegate;
- (void)slideInFrom:(FTAnimationDirection)direction duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (void)slideOutTo:(FTAnimationDirection)direction duration:(NSTimeInterval)duration delegate:(id)delegate;
- (void)slideOutTo:(FTAnimationDirection)direction duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;

- (void)backOutTo:(FTAnimationDirection)direction duration:(NSTimeInterval)duration delegate:(id)delegate;
- (void)backOutTo:(FTAnimationDirection)direction duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (void)backInFrom:(FTAnimationDirection)direction duration:(NSTimeInterval)duration delegate:(id)delegate;
- (void)backInFrom:(FTAnimationDirection)direction duration:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;

- (void)fadeIn:(NSTimeInterval)duration delegate:(id)delegate;
- (void)fadeIn:(NSTimeInterval)duration delegate:(id)delegate startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (void)fadeOut:(NSTimeInterval)duration delegate:(id)delegate;
- (void)fadeOut:(NSTimeInterval)duration delegate:(id)delegate startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;

- (void)fadeBackgroundColorIn:(NSTimeInterval)duration delegate:(id)delegate;
- (void)fadeBackgroundColorIn:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (void)fadeBackgroundColorOut:(NSTimeInterval)duration delegate:(id)delegate;
- (void)fadeBackgroundColorOut:(NSTimeInterval)duration delegate:(id)delegate
startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;

- (void)popIn:(NSTimeInterval)duration delegate:(id)delegate;
- (void)popIn:(NSTimeInterval)duration delegate:(id)delegate startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (void)popOut:(NSTimeInterval)duration delegate:(id)delegate;
- (void)popOut:(NSTimeInterval)duration delegate:(id)delegate startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;

- (void)fallIn:(NSTimeInterval)duration delegate:(id)delegate;
- (void)fallIn:(NSTimeInterval)duration delegate:(id)delegate startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;
- (void)flyOut:(NSTimeInterval)duration delegate:(id)delegate;
- (void)flyOut:(NSTimeInterval)duration delegate:(id)delegate startSelector:(SEL)startSelector stopSelector:(SEL)stopSelector;

@end

@interface CAAnimation (FTAnimationAdditions)

- (void)setStartSelector:(SEL)selector withTarget:(id)target;
- (void)setStopSelector:(SEL)selector withTarget:(id)target;

@end

0 comments on commit f1bfd91

Please sign in to comment.