2 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.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://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <dali/internal/event/animation/key-frames-impl.h>
26 KeyFrames* KeyFrames::New()
28 return new KeyFrames();
31 KeyFrames::KeyFrames()
32 : mType(Property::NONE),
37 KeyFrames::~KeyFrames()
42 void KeyFrames::CreateKeyFramesSpec(Property::Type type)
45 // Now we have a type, can create specific implementation
48 case Property::BOOLEAN:
49 mKeyFrames = Internal::KeyFrameBoolean::New();
52 mKeyFrames = Internal::KeyFrameNumber::New();
54 case Property::INTEGER:
55 mKeyFrames = Internal::KeyFrameInteger::New();
57 case Property::VECTOR2:
58 mKeyFrames = Internal::KeyFrameVector2::New();
60 case Property::VECTOR3:
61 mKeyFrames = Internal::KeyFrameVector3::New();
63 case Property::VECTOR4:
64 mKeyFrames = Internal::KeyFrameVector4::New();
66 case Property::ROTATION:
67 mKeyFrames = Internal::KeyFrameQuaternion::New();
70 DALI_ASSERT_DEBUG(!"Type not supported");
75 Property::Type KeyFrames::GetType() const
80 void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
82 if(mType == Property::NONE)
84 CreateKeyFramesSpec(value.GetType());
87 // Once we have created a type, can only add values of the same type
88 DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" );
90 DALI_ASSERT_DEBUG(mKeyFrames);
94 case Property::BOOLEAN:
96 Internal::KeyFrameBoolean* kf = static_cast<Internal::KeyFrameBoolean*>(mKeyFrames.Get());
97 kf->AddKeyFrame(time, value.Get<bool>(), alpha);
100 case Property::FLOAT:
102 Internal::KeyFrameNumber* kf = static_cast<Internal::KeyFrameNumber*>(mKeyFrames.Get());
103 kf->AddKeyFrame(time, value.Get<float>(), alpha);
106 case Property::INTEGER:
108 Internal::KeyFrameInteger* kf = static_cast<Internal::KeyFrameInteger*>(mKeyFrames.Get());
109 kf->AddKeyFrame(time, value.Get<int>(), alpha);
112 case Property::VECTOR2:
114 Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(mKeyFrames.Get());
115 kf->AddKeyFrame(time, value.Get<Vector2>(), alpha);
118 case Property::VECTOR3:
120 Internal::KeyFrameVector3* kf = static_cast<Internal::KeyFrameVector3*>(mKeyFrames.Get());
121 kf->AddKeyFrame(time, value.Get<Vector3>(), alpha);
124 case Property::VECTOR4:
126 Internal::KeyFrameVector4* kf = static_cast<Internal::KeyFrameVector4*>(mKeyFrames.Get());
127 kf->AddKeyFrame(time, value.Get<Vector4>(), alpha);
130 case Property::ROTATION:
132 Internal::KeyFrameQuaternion* kf = static_cast<Internal::KeyFrameQuaternion*>(mKeyFrames.Get());
133 kf->AddKeyFrame(time, value.Get<Quaternion>(), alpha);
137 DALI_ASSERT_DEBUG(!"Type not supported");
142 KeyFrameSpec* KeyFrames::GetKeyFramesBase() const
144 return mKeyFrames.Get();