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::VECTOR2:
55 mKeyFrames = Internal::KeyFrameVector2::New();
57 case Property::VECTOR3:
58 mKeyFrames = Internal::KeyFrameVector3::New();
60 case Property::VECTOR4:
61 mKeyFrames = Internal::KeyFrameVector4::New();
63 case Property::ROTATION:
64 mKeyFrames = Internal::KeyFrameQuaternion::New();
67 DALI_ASSERT_DEBUG(!"Type not supported");
72 Property::Type KeyFrames::GetType() const
77 void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
79 if(mType == Property::NONE)
81 CreateKeyFramesSpec(value.GetType());
84 // Once we have created a type, can only add values of the same type
85 DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" );
87 DALI_ASSERT_DEBUG(mKeyFrames);
91 case Property::BOOLEAN:
93 Internal::KeyFrameBoolean* kf = static_cast<Internal::KeyFrameBoolean*>(mKeyFrames.Get());
94 kf->AddKeyFrame(time, value.Get<bool>(), alpha);
99 Internal::KeyFrameNumber* kf = static_cast<Internal::KeyFrameNumber*>(mKeyFrames.Get());
100 kf->AddKeyFrame(time, value.Get<float>(), alpha);
103 case Property::VECTOR2:
105 Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(mKeyFrames.Get());
106 kf->AddKeyFrame(time, value.Get<Vector2>(), alpha);
109 case Property::VECTOR3:
111 Internal::KeyFrameVector3* kf = static_cast<Internal::KeyFrameVector3*>(mKeyFrames.Get());
112 kf->AddKeyFrame(time, value.Get<Vector3>(), alpha);
115 case Property::VECTOR4:
117 Internal::KeyFrameVector4* kf = static_cast<Internal::KeyFrameVector4*>(mKeyFrames.Get());
118 kf->AddKeyFrame(time, value.Get<Vector4>(), alpha);
121 case Property::ROTATION:
123 Internal::KeyFrameQuaternion* kf = static_cast<Internal::KeyFrameQuaternion*>(mKeyFrames.Get());
124 kf->AddKeyFrame(time, value.Get<Quaternion>(), alpha);
128 DALI_ASSERT_DEBUG(!"Type not supported");
133 KeyFrameSpec* KeyFrames::GetKeyFramesBase() const
135 return mKeyFrames.Get();