ZFFramework
 
Loading...
Searching...
No Matches
ZFAni.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFAni_h_
7#define _ZFI_ZFAni_h_
8
9#include "ZFAniForTimer.h"
11
12// ============================================================
28 , ZFMP_IN(const ZFListener &, aniImpl)
29 )
30
31// ============================================================
53 , ZFMP_IN(const zfstring &, propertyName)
54 , ZFMP_IN(ZFObject *, from)
55 , ZFMP_IN(ZFObject *, to)
56 )
57
58// ============================================================
59// utils for impl
61zfclass ZFLIB_ZFUtility ZFAniForImpl : zfextend ZFAniForTimer {
62 ZFOBJECT_DECLARE(ZFAniForImpl, ZFAniForTimer)
63public:
71protected:
73 virtual void aniTimerOnUpdate(ZF_IN zffloat progress) {
74 if(this->aniImpl()) {
75 this->_ZFP_progressHolder->zfv = progress;
76 this->aniImpl().execute(ZFArgs()
77 .sender(this)
78 .param0(this->_ZFP_progressHolder)
79 );
80 }
81 }
83 virtual void objectOnInit(void) {
85 this->_ZFP_progressHolder = zfAlloc(v_zffloat);
86 }
88 virtual void objectOnDealloc(void) {
89 zfRetainChange(this->_ZFP_progressHolder, zfnull);
91 }
94 if(anotherObj != zfnull && anotherObj->classData()->classIsTypeOf(zfself::ClassData())
95 && ZFPropertyAllEqual(this, anotherObj)
96 ) {
97 return ZFCompareEqual;
98 }
100 }
101private:
102 v_zffloat *_ZFP_progressHolder;
103};
104
105zfclassFwd _ZFP_ZFAniForGenericPrivate;
107zfclass ZFLIB_ZFUtility ZFAniForGeneric : zfextend ZFAniForTimer {
108 ZFOBJECT_DECLARE(ZFAniForGeneric, ZFAniForTimer)
109public:
116
120
123
124protected:
126 virtual void aniImplTargetOnUpdate(ZF_IN ZFObject *targetOld);
130 virtual void aniImplStart(void);
132 virtual void aniImplStop(void);
134 virtual void aniTimerOnUpdate(ZF_IN zffloat progress);
136 virtual void objectOnInit(void);
138 virtual void objectOnDealloc(void);
141 if(anotherObj != zfnull && anotherObj->classData()->classIsTypeOf(zfself::ClassData())
142 && ZFPropertyAllEqual(this, anotherObj)
143 ) {
144 return ZFCompareEqual;
145 }
147 }
148private:
149 _ZFP_ZFAniForGenericPrivate *d;
150};
151
153#endif // #ifndef _ZFI_ZFAni_h_
154
zfautoT< ZFAniForTimer > ZFAni(const ZFListener &aniImpl)
util to start a ZFAniForTimer based animation quickly
abstract animation based on timer
#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 zfclassFwd
forward declaration of a class type
Definition ZFCoreTypeDef_ClassType.h:31
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
#define zftrue
bool true type
Definition ZFCoreTypeDef_CoreType.h:107
_zft_zffloat zffloat
same as float, see zfindex
Definition ZFCoreTypeDef_CoreType.h:183
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
ZFCompareResult
compare result of two ZFObjects
Definition ZFCoreTypeDef_OtherType.h:28
@ ZFCompareUncomparable
Definition ZFCoreTypeDef_OtherType.h:29
@ ZFCompareEqual
Definition ZFCoreTypeDef_OtherType.h:31
zft_zfstring< zfchar > zfstring
see zft_zfstring
Definition ZFCoreTypeDef_StringType.h:15
#define ZFMP_IN(ParamType, paramName)
macro to wrap param types for ZFMETHOD_INLINE_0 series
Definition ZFMethod.h:105
#define ZFMETHOD_FUNC_DECLARE_3(ZFLIB_, ReturnType, MethodName, ZFMP_0, ZFMP_1, ZFMP_2)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:910
#define ZFMETHOD_FUNC_DECLARE_1(ZFLIB_, ReturnType, MethodName, ZFMP_0)
see ZFMETHOD_FUNC_DECLARE_0
Definition ZFMethodFuncDeclare.h:624
#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_DECLARE(ChildClass, SuperClass,...)
necessary for every class inherit from ZFObject
Definition ZFObjectDeclare.h:126
#define zfAlloc(T_ZFObject,...)
alloc an object, see ZFObject
Definition ZFObjectRetain.h:104
void zfRetainChange(T_ZFObject &obj, T_ZFObject2 const &v)
util to release property's old value, retain new value, then set to property
Definition ZFObjectRetain.h:323
#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
#define ZFPROPERTY_ON_ATTACH_DECLARE(Type, Name)
see ZFPROPERTY_ON_INIT_DECLARE
Definition ZFPropertyDeclare.h:248
zfbool ZFPropertyAllEqual(ZFObject *obj0, ZFObject *obj1)
compare all properties of obj0 with obj1's property by reflect
#define ZFLIB_ZFUtility
used to export symbols
Definition ZFUtilityDef.h:15
virtual zfany const & toValue()
to value of ani, see ZFAni
Definition ZFAni.h:115
virtual zfbool & autoRestore()
whether auto restore to prev state, true by default
Definition ZFAni.h:122
virtual ZFCompareResult objectCompareValueImpl(ZFObject *anotherObj)
see objectCompareValue
Definition ZFAni.h:140
virtual void aniImplStop(void)
for subclass to stop actual animation
virtual void objectOnDealloc(void)
override this to destroy your object
virtual zfbool aniImplCheckValid(void)
called to check whether the animation is currently valid, an invalid animation is ensured can't be st...
virtual void aniTimerOnUpdate(zffloat progress)
called to do the actual update
virtual zfstring & name()
name of property to animate, see ZFAni
Definition ZFAni.h:111
virtual zfany const & fromValue()
from value of ani, see ZFAni
Definition ZFAni.h:113
virtual void objectOnInit(void)
override this to init your object
virtual void aniImplTargetOnUpdate(ZFObject *targetOld)
called when target changed
virtual void aniImplStart(void)
for subclass to achieve actual animation
static const ZFClass * ClassData(void)
get class info
Definition ZFAni.h:108
virtual void aniTimerOnUpdate(zffloat progress)
called to do the actual update
Definition ZFAni.h:73
virtual void objectOnDealloc(void)
override this to destroy your object
Definition ZFAni.h:88
virtual ZFListener & aniImpl()
the custom ani callback
Definition ZFAni.h:70
static const ZFClass * ClassData(void)
get class info
Definition ZFAni.h:62
virtual void objectOnInit(void)
override this to init your object
Definition ZFAni.h:83
virtual ZFCompareResult objectCompareValueImpl(ZFObject *anotherObj)
see objectCompareValue
Definition ZFAni.h:93
animation based on timer
Definition ZFAniForTimer.h:28
virtual void objectOnInit(void)
override this to init your object
virtual void objectOnDealloc(void)
override this to destroy your object
listener data used by ZFListener
Definition ZFArgs.h:20
listener as ZFCallback, mostly used by ZFObject::observerNotify
Definition ZFObjectObserver.h:30
base class of all objects
Definition ZFObjectCore.h:209
type wrapper for ZFTypeId::Value
Definition ZFTypeId_CoreType.h:316
util method to cast ZFObject types freely
Definition zfany.h:35
type restrict version of zfauto
Definition zfautoFwd.h:110