-#ifndef __DALI_INTERNAL_KEY_FRAMES_H__
-#define __DALI_INTERNAL_KEY_FRAMES_H__
+#ifndef DALI_INTERNAL_KEY_FRAMES_H
+#define DALI_INTERNAL_KEY_FRAMES_H
/*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2019 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.
{
class KeyFrameSpec;
class KeyFrames;
-typedef IntrusivePtr<KeyFrames> KeyFramesPtr;
-
+using KeyFramesPtr = IntrusivePtr<KeyFrames>;
/**
* KeyFrames class is responsible for creating and building a specialized KeyFrame class
KeyFrames();
protected:
- virtual ~KeyFrames();
+ ~KeyFrames() override;
private:
/**
*/
KeyFrameSpec* GetKeyFramesBase() const;
+ /**
+ * Return the value of the last key frame.
+ */
+ Dali::Property::Value GetLastKeyFrameValue() const;
+
private:
Dali::Property::Type mType; // Type of the specialization
IntrusivePtr<KeyFrameSpec> mKeyFrames; // Pointer to the specialized key frame object
KeyFrameSpec() {}
- virtual unsigned int GetNumberOfKeyFrames() const = 0;
+ virtual std::size_t GetNumberOfKeyFrames() const = 0;
+
+ /**
+ * Get the key frame value as a Property::Value.
+ * @param[in] index The index of the key frame to fetch
+ * @param[out] value The value of the given key frame
+ */
+ virtual void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) = 0;
protected:
/**
* A reference counted object may only be deleted by calling Unreference()
*/
- virtual ~KeyFrameSpec() {}
+ ~KeyFrameSpec() override {}
};
* The base template class for each key frame specialization. It stores a vector of
* ProgressValue pairs in mPVs, and uses the existing interface for KeyFrameChannel
* to point at this vector.
- * TODO: Incorporate KeyFrameChannel into this base template
*/
template<typename V>
class KeyFrameBaseSpec : public KeyFrameSpec
{
private:
- typedef ProgressValue<V> PV;
- typedef std::vector<PV> PVContainer;
+ using PV = ProgressValue<V>;
+ using PVContainer = std::vector<PV>;
PVContainer mPVs; // The ProgressValue pairs
KeyFrameChannel<V>* mKeyFrames; // The key frame interpolator
mKeyFrames = new KeyFrameChannel<V>(KeyFrameChannelBase::Translate, mPVs);
}
+ KeyFrameBaseSpec<V>& operator=( const KeyFrameBaseSpec<V>& keyFrames )
+ {
+ if( this != &keyFrames )
+ {
+ mPVs.clear();
+ mPVs = keyFrames.mPVs;
+ delete mKeyFrames;
+ mKeyFrames = new KeyFrameChannel<V>(KeyFrameChannelBase::Translate, mPVs);
+ }
+ return *this;
+ }
+
/**
* Destructor. Ensure progress value pairs are cleared down
*/
- virtual ~KeyFrameBaseSpec<V>()
+ ~KeyFrameBaseSpec<V>() override
{
delete mKeyFrames;
mPVs.clear();
*/
void AddKeyFrame(float t, V v, AlphaFunction alpha)
{
- // TODO:: Support alpha
mPVs.push_back(PV(t, v));
}
* Get the number of key frames
* @return The size of the progress value vector
*/
- virtual unsigned int GetNumberOfKeyFrames() const
+ std::size_t GetNumberOfKeyFrames() const override
{
return mPVs.size();
}
}
/**
+ * @copydoc KeyFrameSpec::GetKeyFrameAsValue()
+ */
+ void GetKeyFrameAsValue( std::size_t index, Property::Value& value ) override
+ {
+ value = mPVs[index].mValue;
+ }
+
+ /**
* Return whether the progress is valid for the range of keyframes. (The first
* keyframe doesn't have to start at 0, and the last doesn't have to end at 1.0)
* @param[in] progress The progress to test
}
};
-typedef KeyFrameBaseSpec<float> KeyFrameNumber;
-typedef KeyFrameBaseSpec<bool> KeyFrameBoolean;
-typedef KeyFrameBaseSpec<int> KeyFrameInteger;
-typedef KeyFrameBaseSpec<unsigned int> KeyFrameUnsignedInteger;
-typedef KeyFrameBaseSpec<Vector2> KeyFrameVector2;
-typedef KeyFrameBaseSpec<Vector3> KeyFrameVector3;
-typedef KeyFrameBaseSpec<Vector4> KeyFrameVector4;
-typedef KeyFrameBaseSpec<Quaternion> KeyFrameQuaternion;
-
-typedef IntrusivePtr<KeyFrameBoolean> KeyFrameBooleanPtr;
-typedef IntrusivePtr<KeyFrameNumber> KeyFrameNumberPtr;
-typedef IntrusivePtr<KeyFrameInteger> KeyFrameIntegerPtr;
-typedef IntrusivePtr<KeyFrameUnsignedInteger> KeyFrameUnsignedIntegerPtr;
-typedef IntrusivePtr<KeyFrameVector2> KeyFrameVector2Ptr;
-typedef IntrusivePtr<KeyFrameVector3> KeyFrameVector3Ptr;
-typedef IntrusivePtr<KeyFrameVector4> KeyFrameVector4Ptr;
-typedef IntrusivePtr<KeyFrameQuaternion> KeyFrameQuaternionPtr;
-
+using KeyFrameNumber = KeyFrameBaseSpec<float>;
+using KeyFrameBoolean = KeyFrameBaseSpec<bool>;
+using KeyFrameInteger = KeyFrameBaseSpec<int>;
+using KeyFrameVector2 = KeyFrameBaseSpec<Vector2>;
+using KeyFrameVector3 = KeyFrameBaseSpec<Vector3>;
+using KeyFrameVector4 = KeyFrameBaseSpec<Vector4>;
+using KeyFrameQuaternion = KeyFrameBaseSpec<Quaternion>;
+
+using KeyFrameBooleanPtr = IntrusivePtr<KeyFrameBoolean>;
+using KeyFrameNumberPtr = IntrusivePtr<KeyFrameNumber>;
+using KeyFrameIntegerPtr = IntrusivePtr<KeyFrameInteger>;
+using KeyFrameVector2Ptr = IntrusivePtr<KeyFrameVector2>;
+using KeyFrameVector3Ptr = IntrusivePtr<KeyFrameVector3>;
+using KeyFrameVector4Ptr = IntrusivePtr<KeyFrameVector4>;
+using KeyFrameQuaternionPtr = IntrusivePtr<KeyFrameQuaternion>;
inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameBoolean*& keyFrameSpec)
{
keyFrameSpec = static_cast<const Internal::KeyFrameInteger*>(keyFrames.GetKeyFramesBase());
}
-inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameUnsignedInteger*& keyFrameSpec)
-{
- keyFrameSpec = static_cast<Internal::KeyFrameUnsignedInteger*>(keyFrames.GetKeyFramesBase());
-}
-
-inline void GetSpecialization(const Internal::KeyFrames& keyFrames, const Internal::KeyFrameUnsignedInteger*& keyFrameSpec)
-{
- keyFrameSpec = static_cast<const Internal::KeyFrameUnsignedInteger*>(keyFrames.GetKeyFramesBase());
-}
-
inline void GetSpecialization(Internal::KeyFrames& keyFrames, Internal::KeyFrameVector2*& keyFrameSpec)
{
keyFrameSpec = static_cast<Internal::KeyFrameVector2*>(keyFrames.GetKeyFramesBase());
} // Dali
-#endif //__DALI_INTERNAL_KEY_FRAMES_H__
+#endif // DALI_INTERNAL_KEY_FRAMES_H