mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 05:32:11 +00:00
Add NSAnimation class from mySTEP
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24878 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7d1631a845
commit
36e8d2a357
3 changed files with 372 additions and 0 deletions
129
Headers/AppKit/NSAnimation.h
Normal file
129
Headers/AppKit/NSAnimation.h
Normal file
|
@ -0,0 +1,129 @@
|
|||
/*
|
||||
* NSAnimation.h
|
||||
*
|
||||
* Created by Dr. H. Nikolaus Schaller on Sat Jan 07 2006.
|
||||
* Copyright (c) 2005 DSITRI.
|
||||
*
|
||||
* This file used to be part of the mySTEP Library.
|
||||
* This file now is part of the GNUstep GUI Library.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; see the file COPYING.LIB.
|
||||
* If not, write to the Free Software Foundation,
|
||||
* 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#ifndef _NSAnimation_h_GNUstep_
|
||||
#define _NSAnimation_h_GNUstep_
|
||||
|
||||
#include <Foundation/Foundation.h>
|
||||
|
||||
typedef enum _NSAnimationCurve
|
||||
{
|
||||
NSAnimationEaseInOut = 0, // default
|
||||
NSAnimationEaseIn,
|
||||
NSAnimationEaseOut,
|
||||
NSAnimationLinear
|
||||
} NSAnimationCurve;
|
||||
|
||||
typedef enum _NSAnimationBlockingMode
|
||||
{
|
||||
NSAnimationBlocking,
|
||||
NSAnimationNonblocking,
|
||||
NSAnimationNonblockingThreaded
|
||||
} NSAnimationBlockingMode;
|
||||
|
||||
typedef float NSAnimationProgress;
|
||||
|
||||
extern NSString *NSAnimationProgressMarkNotification;
|
||||
|
||||
@interface NSAnimation : NSObject < NSCopying, NSCoding >
|
||||
{
|
||||
NSAnimationBlockingMode _animationBlockingMode;
|
||||
NSAnimationCurve _animationCurve;
|
||||
NSAnimationProgress _currentProgress;
|
||||
NSMutableArray *_progressMarks;
|
||||
id _delegate;
|
||||
NSTimeInterval _duration;
|
||||
float _currentValue;
|
||||
float _frameRate;
|
||||
BOOL _isAnimating; // ?or the NSThread *
|
||||
}
|
||||
|
||||
- (void) addProgressMark: (NSAnimationProgress) progress;
|
||||
- (NSAnimationBlockingMode) animationBlockingMode;
|
||||
- (NSAnimationCurve) animationCurve;
|
||||
- (void) clearStartAnimation;
|
||||
- (void) clearStopAnimation;
|
||||
- (NSAnimationProgress) currentProgress;
|
||||
- (float) currentValue;
|
||||
- (id) delegate;
|
||||
- (NSTimeInterval) duration;
|
||||
- (float) frameRate;
|
||||
- (id) initWithDuration: (NSTimeInterval) duration animationCurve:
|
||||
(NSAnimationCurve) curve;
|
||||
- (BOOL) isAnimating;
|
||||
- (NSArray *) progressMarks;
|
||||
- (void) removeProgressMark: (NSAnimationProgress) progress;
|
||||
- (NSArray *) runLoopModesForAnimating;
|
||||
- (void) setAnimationBlockingMode: (NSAnimationBlockingMode) mode;
|
||||
- (void) setAnimationCurve: (NSAnimationCurve) curve;
|
||||
- (void) setCurrentProgress: (NSAnimationProgress) progress;
|
||||
- (void) setDelegate: (id) delegate;
|
||||
- (void) setDuration: (NSTimeInterval) duration;
|
||||
- (void) setFrameRate: (float) fps;
|
||||
- (void) setProgressMarks: (NSArray *) progress;
|
||||
- (void) startAnimation;
|
||||
- (void) startWhenAnimation: (NSAnimation *) animation reachesProgress:
|
||||
(NSAnimationProgress) start;
|
||||
- (void) stopAnimation;
|
||||
- (void) stopWhenAnimation: (NSAnimation *) animation reachesProgress:
|
||||
(NSAnimationProgress) stop;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@interface NSObject (NSAnimation)
|
||||
|
||||
- (void) animation: (NSAnimation *) animation didReachProgressMark:
|
||||
(NSAnimationProgress) progress;
|
||||
- (float) animation: (NSAnimation *) animation valueForProgress:
|
||||
(NSAnimationProgress) progress;
|
||||
- (void) animationDidEnd: (NSAnimation *) animation;
|
||||
- (void) animationDidStop: (NSAnimation *) animation;
|
||||
- (BOOL) animationShouldStart: (NSAnimation *) animation;
|
||||
|
||||
@end
|
||||
|
||||
|
||||
extern NSString *NSViewAnimationTargetKey;
|
||||
extern NSString *NSViewAnimationStartFrameKey;
|
||||
extern NSString *NSViewAnimationEndFrameKey;
|
||||
extern NSString *NSViewAnimationEffectKey;
|
||||
extern NSString *NSViewAnimationFadeInEffect;
|
||||
extern NSString *NSViewAnimationFadeOutEffect;
|
||||
|
||||
@interface NSViewAnimation : NSAnimation
|
||||
{
|
||||
NSArray *_viewAnimations;
|
||||
}
|
||||
|
||||
- (id) initWithViewAnimations: (NSArray *) animations;
|
||||
- (void) setWithViewAnimations: (NSArray *) animations;
|
||||
- (NSArray *) viewAnimations;
|
||||
|
||||
@end
|
||||
|
||||
#endif /* _NSAnimation_h_GNUstep_ */
|
||||
|
|
@ -50,6 +50,7 @@ libgnustep-gui_OBJC_FILES = Functions.m \
|
|||
NSActionCell.m \
|
||||
NSAffineTransform.m \
|
||||
NSAlert.m \
|
||||
NSAnimation.m \
|
||||
NSApplication.m \
|
||||
NSArrayController.m \
|
||||
NSAttributedString.m \
|
||||
|
@ -234,6 +235,7 @@ AppKitExceptions.h \
|
|||
NSActionCell.h \
|
||||
NSAffineTransform.h \
|
||||
NSAlert.h \
|
||||
NSAnimation.h \
|
||||
NSApplication.h \
|
||||
NSArrayController.h \
|
||||
NSBezierPath.h \
|
||||
|
|
241
Source/NSAnimation.m
Normal file
241
Source/NSAnimation.m
Normal file
|
@ -0,0 +1,241 @@
|
|||
/*
|
||||
* NSAnimation.m
|
||||
*
|
||||
* Created by Dr. H. Nikolaus Schaller on Sat Mar 06 2006.
|
||||
* Copyright (c) 2005 DSITRI.
|
||||
*
|
||||
* This file used to be part of the mySTEP Library.
|
||||
* This file now is part of the GNUstep GUI Library.
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this library; see the file COPYING.LIB.
|
||||
* If not, write to the Free Software Foundation,
|
||||
* 51 Franklin Street, Fifth Floor,
|
||||
* Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <AppKit/NSAnimation.h>
|
||||
|
||||
NSString *NSAnimationProgressMarkNotification
|
||||
= @"NSAnimationProgressMarkNotification";
|
||||
|
||||
NSString *NSViewAnimationTargetKey = @"NSViewAnimationTargetKey";
|
||||
NSString *NSViewAnimationStartFrameKey = @"NSViewAnimationStartFrameKey";
|
||||
NSString *NSViewAnimationEndFrameKey = @"NSViewAnimationEndFrameKey";
|
||||
NSString *NSViewAnimationEffectKey = @"NSViewAnimationEffectKey";
|
||||
NSString *NSViewAnimationFadeInEffect = @"NSViewAnimationFadeInEffect";
|
||||
NSString *NSViewAnimationFadeOutEffect = @"NSViewAnimationFadeOutEffect";
|
||||
|
||||
@implementation NSAnimation
|
||||
|
||||
- (void) addProgressMark: (NSAnimationProgress) progress
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
- (NSAnimationBlockingMode) animationBlockingMode
|
||||
{
|
||||
return _animationBlockingMode;
|
||||
}
|
||||
|
||||
- (NSAnimationCurve) animationCurve
|
||||
{
|
||||
return _animationCurve;
|
||||
}
|
||||
|
||||
- (void) clearStartAnimation
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
- (void) clearStopAnimation
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
- (NSAnimationProgress) currentProgress
|
||||
{
|
||||
return _currentProgress;
|
||||
}
|
||||
|
||||
- (float) currentValue
|
||||
{
|
||||
return _currentValue;
|
||||
}
|
||||
|
||||
- (id) delegate
|
||||
{
|
||||
return _delegate;
|
||||
}
|
||||
|
||||
- (NSTimeInterval) duration
|
||||
{
|
||||
return _duration;
|
||||
}
|
||||
|
||||
- (float) frameRate
|
||||
{
|
||||
return _frameRate;
|
||||
}
|
||||
|
||||
- (id) initWithDuration: (NSTimeInterval) duration animationCurve:
|
||||
(NSAnimationCurve) curve
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
_duration = duration;
|
||||
_animationCurve = curve;
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (id) copyWithZone: (NSZone *) zone
|
||||
{
|
||||
return [self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[_progressMarks release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (BOOL) isAnimating
|
||||
{
|
||||
return _isAnimating;
|
||||
}
|
||||
|
||||
- (NSArray *) progressMarks
|
||||
{
|
||||
return _progressMarks;
|
||||
}
|
||||
|
||||
- (void) removeProgressMark: (NSAnimationProgress) progress
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
- (NSArray *) runLoopModesForAnimating
|
||||
{
|
||||
return nil;
|
||||
}
|
||||
|
||||
- (void) setAnimationBlockingMode: (NSAnimationBlockingMode) mode
|
||||
{
|
||||
_animationBlockingMode = mode;
|
||||
}
|
||||
|
||||
- (void) setAnimationCurve: (NSAnimationCurve) curve
|
||||
{
|
||||
_animationCurve = curve;
|
||||
}
|
||||
|
||||
- (void) setCurrentProgress: (NSAnimationProgress) progress
|
||||
{
|
||||
_currentProgress = progress;
|
||||
}
|
||||
|
||||
- (void) setDelegate: (id) delegate
|
||||
{
|
||||
_delegate = delegate;
|
||||
}
|
||||
|
||||
- (void) setDuration: (NSTimeInterval) duration
|
||||
{
|
||||
_duration = duration;
|
||||
}
|
||||
|
||||
- (void) setFrameRate: (float) fps
|
||||
{
|
||||
_frameRate = fps;
|
||||
}
|
||||
|
||||
- (void) setProgressMarks: (NSArray *) progress
|
||||
{
|
||||
ASSIGN(_progressMarks, progress) ;
|
||||
}
|
||||
|
||||
- (void) _animate
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
// call delegate
|
||||
// estimate delay to keep fps
|
||||
// create new timer
|
||||
}
|
||||
|
||||
- (void) startAnimation
|
||||
{
|
||||
_isAnimating = YES;
|
||||
[self _animate];
|
||||
}
|
||||
|
||||
- (void) startWhenAnimation: (NSAnimation *) animation reachesProgress:
|
||||
(NSAnimationProgress) start
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
- (void) stopAnimation
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
// remove any timer
|
||||
_isAnimating = NO;
|
||||
}
|
||||
|
||||
- (void) stopWhenAnimation: (NSAnimation *) animation reachesProgress:
|
||||
(NSAnimationProgress) stop
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
- (void) encodeWithCoder: (NSCoder *) coder
|
||||
{
|
||||
[self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
- (id) initWithCoder: (NSCoder *) coder
|
||||
{
|
||||
return [self notImplemented: _cmd];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation NSViewAnimation
|
||||
|
||||
- (id) initWithViewAnimations: (NSArray *) animations
|
||||
{
|
||||
if ((self = [super init]))
|
||||
{
|
||||
_viewAnimations = [animations retain];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void) dealloc
|
||||
{
|
||||
[_viewAnimations release];
|
||||
[super dealloc];
|
||||
}
|
||||
|
||||
- (void) setWithViewAnimations: (NSArray *) animations
|
||||
{
|
||||
ASSIGN(_viewAnimations, animations) ;
|
||||
}
|
||||
|
||||
- (NSArray *) viewAnimations
|
||||
{
|
||||
return _viewAnimations;
|
||||
}
|
||||
|
||||
@end
|
||||
|
Loading…
Reference in a new issue