ZFFramework
 
Loading...
Searching...
No Matches
ZFAnimation.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFAnimation_h_
7#define _ZFI_ZFAnimation_h_
8
9#include "ZFUtilityDef.h"
11
16
17// ============================================================
18zfclassFwd _ZFP_ZFAnimationPrivate;
22zfclass ZFLIB_ZFUtility ZFAnimation : zfextend ZFStyle {
23 ZFOBJECT_DECLARE(ZFAnimation, ZFStyle)
24
25public:
26 // ============================================================
27 // event
33 ZFEVENT(AniOnStart)
40 ZFEVENT(AniOnLoop)
47 ZFEVENT(AniOnStop)
48
49 // ============================================================
50 // property
51public:
62
69
76
77public:
83 , ZFMP_IN(ZFObject *, target)
84 )
89
90 // ============================================================
91 // start stop
92public:
99 , ZFMP_IN_OPT(const ZFListener &, onStop, zfnull)
115
116public:
124
129
136
137public:
140 , ZFMP_IN(const ZFListener &, cb)
144 , ZFMP_IN(const ZFListener &, cb)
148 , ZFMP_IN(const ZFListener &, cb)
150
151protected:
153 virtual void aniImplTargetOnUpdate(ZF_IN ZFObject *targetOld) {}
161 virtual zfbool aniImplCheckValid(void) {
162 return zftrue;
163 }
164
165public:
166 zffinal void _ZFP_ZFAnimation_aniDummyNotifyStop(void);
167protected:
171 virtual void aniImplStart(void);
175 virtual void aniImplStop(void);
177 virtual inline void aniOnStart(void) {
179 }
180
181 virtual inline void aniOnLoop(void) {
183 }
184
185 virtual inline void aniOnStop(ZF_IN ZFResultType resultType) {
187 }
188public:
193
194protected:
197 ZFMP_IN(ZFObject *, target)
199
200protected:
202 virtual void objectOnInit(void);
204 virtual void objectOnDealloc(void);
206 virtual void objectOnDeallocPrepare(void);
207
208protected:
214
215private:
216 _ZFP_ZFAnimationPrivate *d;
217};
218
219// ============================================================
223zfclass ZFLIB_ZFUtility ZFAniTask : zfextend ZFTask {
224 ZFOBJECT_DECLARE(ZFAniTask, ZFTask)
225
226public:
229
230protected:
232 virtual void objectOnInit(void) {
234 }
235
237 ZFMP_IN(ZFAnimation *, impl)
239
240public:
242 virtual void taskOnStart(void);
247};
248
250#endif // #ifndef _ZFI_ZFAnimation_h_
251
zftimet & ZFAniDuration(void)
global default animation duration, 250 by default
Definition ZFAnimation.h:15
#define zffinal
dummy macro shows that a method or class is designed must not to be overrided
Definition ZFCoreTypeDef_ClassType.h:63
#define zfextend
dummy macro shows class inherit from another
Definition ZFCoreTypeDef_ClassType.h:53
#define zfoverride
dummy macro shows that method override parent's method
Definition ZFCoreTypeDef_ClassType.h:58
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
#define ZF_IN_OPT
dummy macro that shows the param used as optional input
Definition ZFCoreTypeDef_ClassType.h:184
#define ZF_IN_OUT
dummy macro that shows the param used as required input and output
Definition ZFCoreTypeDef_ClassType.h:196
#define zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
_ZFT_t_zfindex zfindex
similar to size_t, used for index and size only
Definition ZFCoreTypeDef_CoreType.h:154
#define zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
_zft_zftimet zftimet
time unit, ensured at least 64 bit, ensured signed
Definition ZFCoreTypeDef_CoreType.h:203
_zft_zfidentity zfidentity
identity type, ensured at least 32 bit, ensured unsigned
Definition ZFCoreTypeDef_CoreType.h:225
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFEXPORT_VAR_DECLARE(ZFLIB_, Type, Name)
util to export global variable
Definition ZFExport.h:68
#define ZFMP_IN_OPT(ParamType, paramName, DefaultValue)
see ZFMP_IN
Definition ZFMethod.h:108
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_DECLARE_0(ReturnType, MethodName)
see ZFMethod
Definition ZFMethodDeclare.h:693
#define ZFMETHOD_DECLARE_1(ReturnType, MethodName, ZFMP_0)
see ZFMethod
Definition ZFMethodDeclare.h:854
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
#define zfclass
same as class, shows that this class is a ZFObject type
Definition ZFObjectClassTypeFwd.h:38
#define ZFOBJECT_ON_INIT_DECLARE_1(ZFMP_0)
see ZFOBJECT_ON_INIT_INLINE_1
Definition ZFObjectDeclare.h:263
#define ZFOBJECT_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:126
#define ZFEVENT(YourEvent)
see ZFObject::observerNotify
Definition ZFObjectObserver.h:328
#define ZFPROPERTY_RETAIN(Type, Name,...)
declare a retain property
Definition ZFPropertyDeclare.h:104
#define ZFPROPERTY_ASSIGN(Type, Name,...)
see ZFPROPERTY_RETAIN
Definition ZFPropertyDeclare.h:128
void ZFObjectPropertyInfoT(zfstring &ret, ZFObject *obj, zfindex maxCount=((zfindex) -1), const ZFTokenForKeyValueContainer &token=_ZFP_ZFTokenForKeyValueContainerDefault)
use reflect to print all property if the property is not ZFPropertyIsInitValue
v_ZFResultType::ZFEnumType ZFResultType
see v_ZFResultType
Definition ZFResultType.h:23
global header for ZFUtility module
#define ZFLIB_ZFUtility
used to export symbols
Definition ZFUtilityDef.h:15
virtual void taskOnStop(ZFResultType resultType)
called to stop task
virtual zfanyT< ZFAnimation > const & impl()
the impl
Definition ZFAnimation.h:228
virtual void objectInfoImpl(zfstring &ret)
see objectInfo
virtual void objectOnInit(void)
override this to init your object
Definition ZFAnimation.h:232
virtual void taskOnStart(void)
called to start task
base class of all animation
Definition ZFAnimation.h:22
virtual void stop()
stop the animation or do nothing if not started
virtual void aniOnStart(void)
see E_AniOnStart
Definition ZFAnimation.h:177
virtual void start(const ZFListener &onStop=(zft_zfnull))
start the animation
virtual void aniOnStop(ZFResultType resultType)
see E_AniOnStop
Definition ZFAnimation.h:185
static zfidentity E_AniOnLoop(void)
see ZFObject::observerNotify
virtual zftimet durationFixed()
util method to duration
virtual void objectInfoImplAppend(zfstring &ret)
see objectInfo
Definition ZFAnimation.h:210
virtual zfindex & loop()
loop count, 0 by default
Definition ZFAnimation.h:68
virtual void objectOnDealloc(void)
override this to destroy your object
virtual zfbool started()
true if the animation is running
virtual void objectOnInit(ZFObject *target)
init with target
virtual void aniOnStop(const ZFListener &cb)
util to attach observer
virtual void aniImplStop(void)
for subclass to stop actual animation
virtual zfidentity aniId()
get current animation's id
void aniImplNotifyStop(ZFResultType resultType=v_ZFResultType::e_Success)
subclass must notify after the animation stop
virtual void target(ZFObject *target)
animation's target, assign only, but would be retain automatically while animation is running
virtual void aniOnLoop(void)
see E_AniOnLoop
Definition ZFAnimation.h:181
virtual void aniImplTargetOnUpdate(ZFObject *targetOld)
called when target changed
Definition ZFAnimation.h:153
virtual void aniOnLoop(const ZFListener &cb)
util to attach observer
virtual void objectOnDeallocPrepare(void)
called before objectOnDealloc, safe to call virtual functions here
static zfidentity E_AniOnStart(void)
see ZFObject::observerNotify
virtual zfanyT< ZFCurve > const & curve()
curve for animation, null to use linear curve, null by default
Definition ZFAnimation.h:75
virtual zftimet & duration()
animation's duration in miliseconds, 0 to use ZFAniDuration, 0 by default
Definition ZFAnimation.h:57
virtual zfbool aniImplCheckValid(void)
called to check whether the animation is currently valid, an invalid animation is ensured can't be st...
Definition ZFAnimation.h:161
virtual zfbool stoppedByUser()
true if the animation is stopped by calling stop
virtual zfbool valid()
check whether animation is valid, see aniImplCheckValid
virtual zfindex loopCur()
current loop count, 0 for first time
static zfidentity E_AniOnStop(void)
see ZFObject::observerNotify
virtual void aniOnStart(const ZFListener &cb)
util to attach observer
virtual void aniImplStart(void)
for subclass to achieve actual animation
time based event driver
Definition ZFCurve.h:18
listener as ZFCallback, mostly used by ZFObject::observerNotify
Definition ZFObjectObserver.h:30
virtual void objectInfoImplAppend(zfstring &ret)
see objectInfo
Definition ZFObjectCore.h:331
void observerNotify(zfidentity eventId, ZFObject *param0=zft_zfnull, ZFObject *param1=zft_zfnull)
notify the observer with eventId
virtual ZFResultType & resultType()
for task impl to store task result, reset to success when start
Definition ZFTask.h:84
virtual void objectOnInit(const ZFListener &implOnStart, const ZFListener &implOnStop=(zft_zfnull))
util constructor to attach custom impl to E_TaskOnStart and E_TaskOnStop
@ e_Success
Definition ZFResultType.h:16
util method to cast ZFObject types freely
Definition zfany.h:35
see zfany
Definition zfany.h:106
util class to alloc and hold ZFObject type
Definition ZFObjectAutoPtr.h:157