/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2021 Samsung Electronics Co., Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
{
namespace Internal
{
-
KeyFrames* KeyFrames::New()
{
return new KeyFrames();
}
-KeyFrames::KeyFrames()
- : mType(Property::NONE),
- mKeyFrames(NULL)
-{
-}
-
-KeyFrames::~KeyFrames()
-{
-}
-
-
void KeyFrames::CreateKeyFramesSpec(Property::Type type)
{
mType = type;
{
case Property::BOOLEAN:
{
- mKeyFrames = Internal::KeyFrameBoolean::New();
+ mKeyFrames = std::make_unique<Internal::KeyFrameBoolean>();
break;
}
case Property::INTEGER:
{
- mKeyFrames = Internal::KeyFrameInteger::New();
+ mKeyFrames = std::make_unique<Internal::KeyFrameInteger>();
break;
}
case Property::FLOAT:
{
- mKeyFrames = Internal::KeyFrameNumber::New();
+ mKeyFrames = std::make_unique<Internal::KeyFrameNumber>();
break;
}
case Property::VECTOR2:
{
- mKeyFrames = Internal::KeyFrameVector2::New();
+ mKeyFrames = std::make_unique<Internal::KeyFrameVector2>();
break;
}
case Property::VECTOR3:
{
- mKeyFrames = Internal::KeyFrameVector3::New();
+ mKeyFrames = std::make_unique<Internal::KeyFrameVector3>();
break;
}
case Property::VECTOR4:
{
- mKeyFrames = Internal::KeyFrameVector4::New();
+ mKeyFrames = std::make_unique<Internal::KeyFrameVector4>();
break;
}
case Property::ROTATION:
{
- mKeyFrames = Internal::KeyFrameQuaternion::New();
+ mKeyFrames = std::make_unique<Internal::KeyFrameQuaternion>();
break;
}
default:
{
- DALI_ABORT( "Type not animateable" );
+ DALI_ABORT("Property type is not animatable");
break;
}
}
return mType;
}
-void KeyFrames::Add(float time, Property::Value value, AlphaFunction alpha)
+void KeyFrames::Add(float time, const Property::Value& value, AlphaFunction alpha)
{
if(mType == Property::NONE)
{
}
// Once we have created a type, can only add values of the same type
- DALI_ASSERT_ALWAYS( mType == value.GetType() && "Can only add values of the same type to a KeyFrame" );
+ DALI_ASSERT_ALWAYS(mType == value.GetType() && "Can only add values of the same type to a KeyFrame");
+
+ auto keyframes = mKeyFrames.get();
- DALI_ASSERT_DEBUG(mKeyFrames);
+ DALI_ASSERT_DEBUG(keyframes);
switch(mType)
{
case Property::BOOLEAN:
{
- Internal::KeyFrameBoolean* kf = static_cast<Internal::KeyFrameBoolean*>(mKeyFrames.Get());
+ Internal::KeyFrameBoolean* kf = static_cast<Internal::KeyFrameBoolean*>(keyframes);
kf->AddKeyFrame(time, value.Get<bool>(), alpha);
break;
}
case Property::INTEGER:
{
- Internal::KeyFrameInteger* kf = static_cast<Internal::KeyFrameInteger*>(mKeyFrames.Get());
+ Internal::KeyFrameInteger* kf = static_cast<Internal::KeyFrameInteger*>(keyframes);
kf->AddKeyFrame(time, value.Get<int>(), alpha);
break;
}
case Property::FLOAT:
{
- Internal::KeyFrameNumber* kf = static_cast<Internal::KeyFrameNumber*>(mKeyFrames.Get());
+ Internal::KeyFrameNumber* kf = static_cast<Internal::KeyFrameNumber*>(keyframes);
kf->AddKeyFrame(time, value.Get<float>(), alpha);
break;
}
case Property::VECTOR2:
{
- Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(mKeyFrames.Get());
+ Internal::KeyFrameVector2* kf = static_cast<Internal::KeyFrameVector2*>(keyframes);
kf->AddKeyFrame(time, value.Get<Vector2>(), alpha);
break;
}
case Property::VECTOR3:
{
- Internal::KeyFrameVector3* kf = static_cast<Internal::KeyFrameVector3*>(mKeyFrames.Get());
+ Internal::KeyFrameVector3* kf = static_cast<Internal::KeyFrameVector3*>(keyframes);
kf->AddKeyFrame(time, value.Get<Vector3>(), alpha);
break;
}
case Property::VECTOR4:
{
- Internal::KeyFrameVector4* kf = static_cast<Internal::KeyFrameVector4*>(mKeyFrames.Get());
+ Internal::KeyFrameVector4* kf = static_cast<Internal::KeyFrameVector4*>(keyframes);
kf->AddKeyFrame(time, value.Get<Vector4>(), alpha);
break;
}
case Property::ROTATION:
{
- Internal::KeyFrameQuaternion* kf = static_cast<Internal::KeyFrameQuaternion*>(mKeyFrames.Get());
+ Internal::KeyFrameQuaternion* kf = static_cast<Internal::KeyFrameQuaternion*>(keyframes);
kf->AddKeyFrame(time, value.Get<Quaternion>(), alpha);
break;
}
KeyFrameSpec* KeyFrames::GetKeyFramesBase() const
{
- return mKeyFrames.Get();
+ return mKeyFrames.get();
+}
+
+Property::Value KeyFrames::GetLastKeyFrameValue() const
+{
+ Property::Value value;
+
+ std::size_t noOfKeyFrames = mKeyFrames->GetNumberOfKeyFrames();
+ if(noOfKeyFrames)
+ {
+ float time;
+ mKeyFrames->GetKeyFrameAsValue(noOfKeyFrames - 1, time, value);
+ }
+
+ return value;
+}
+
+std::size_t KeyFrames::GetKeyFrameCount() const
+{
+ return mKeyFrames->GetNumberOfKeyFrames();
+}
+
+void KeyFrames::GetKeyFrame(std::size_t index, float& time, Property::Value& value) const
+{
+ if(index < mKeyFrames->GetNumberOfKeyFrames())
+ {
+ mKeyFrames->GetKeyFrameAsValue(index, time, value);
+ }
}
-} // Internal
-} // Dali
+} // namespace Internal
+} // namespace Dali