2 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 #include <dali/internal/event/animation/key-frames-impl.h>
25 KeyFrames* KeyFrames::New()
27 return new KeyFrames();
30 KeyFrames::KeyFrames()
31 : mType(Property::NONE),
36 KeyFrames::~KeyFrames()
41 void KeyFrames::CreateKeyFramesSpec(Property::Type type)
44 // Now we have a type, can create specific implementation
47 case Property::BOOLEAN:
48 mKeyFrames = Internal::KeyFrameBoolean::New();
51 mKeyFrames = Internal::KeyFrameNumber::New();
53 case Property::VECTOR2:
54 mKeyFrames = Internal::KeyFrameVector2::New();
56 case Property::VECTOR3:
57 mKeyFrames = Internal::KeyFrameVector3::New();
59 case Property::VECTOR4:
60 mKeyFrames = Internal::KeyFrameVector4::New();
62 case Property::ROTATION:
63 mKeyFrames = Internal::KeyFrameQuaternion::New();
66 DALI_ASSERT_DEBUG(!"Type not supported");
71 Property::Type KeyFrames::GetType() const
76 void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
78 if(mType == Property::NONE)
80 CreateKeyFramesSpec(value.GetType());
83 // Once we have created a type, can only add values of the same type
84 DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" );
86 DALI_ASSERT_DEBUG(mKeyFrames);
90 case Property::BOOLEAN:
92 Internal::KeyFrameBoolean* kf = static_cast<Internal::KeyFrameBoolean*>(mKeyFrames.Get());
93 kf->AddKeyFrame(time, value.Get<bool>(), alpha);
98 Internal::KeyFrameNumber* kf = static_cast<Internal::KeyFrameNumber*>(mKeyFrames.Get());
99 kf->AddKeyFrame(time, value.Get<float>(), alpha);
102 case Property::VECTOR2:
104 Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(mKeyFrames.Get());
105 kf->AddKeyFrame(time, value.Get<Vector2>(), alpha);
108 case Property::VECTOR3:
110 Internal::KeyFrameVector3* kf = static_cast<Internal::KeyFrameVector3*>(mKeyFrames.Get());
111 kf->AddKeyFrame(time, value.Get<Vector3>(), alpha);
114 case Property::VECTOR4:
116 Internal::KeyFrameVector4* kf = static_cast<Internal::KeyFrameVector4*>(mKeyFrames.Get());
117 kf->AddKeyFrame(time, value.Get<Vector4>(), alpha);
120 case Property::ROTATION:
122 Internal::KeyFrameQuaternion* kf = static_cast<Internal::KeyFrameQuaternion*>(mKeyFrames.Get());
123 kf->AddKeyFrame(time, value.Get<Quaternion>(), alpha);
127 DALI_ASSERT_DEBUG(!"Type not supported");
132 KeyFrameSpec* KeyFrames::GetKeyFramesBase() const
134 return mKeyFrames.Get();