#include <dali-test-suite-utils.h>
#include <dali/devel-api/actors/actor-devel.h>
#include <dali/devel-api/animation/animation-devel.h>
+#include <dali/devel-api/animation/key-frames-devel.h>
#include <dali/public-api/dali-core.h>
#include <stdlib.h>
END_TEST;
}
+int UtcDaliAnimationKeyFramesGetKeyFrameCountP(void)
+{
+ TestApplication application;
+
+ KeyFrames keyFrames = KeyFrames::New();
+ keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.6f));
+ keyFrames.Add(0.6f, Vector4(0.0f, 0.0f, 0.0f, 0.3f));
+ keyFrames.Add(1.0f, Vector4(0.0f, 0.0f, 0.0f, 0.8f));
+
+ DALI_TEST_EQUALS(DevelKeyFrames::GetKeyFrameCount(keyFrames), 3, TEST_LOCATION);
+
+ END_TEST;
+}
+
+int UtcDaliAnimationKeyFramesGetKeyFrameP(void)
+{
+ TestApplication application;
+
+ float inputTime = 0.6f;
+ Vector4 inputValue = Vector4(0.0f, 0.0f, 0.0f, 0.3f);
+
+ KeyFrames keyFrames = KeyFrames::New();
+ keyFrames.Add(0.0f, Vector4(0.0f, 0.0f, 0.0f, 0.6f));
+ keyFrames.Add(inputTime, inputValue);
+ keyFrames.Add(1.0f, Vector4(0.0f, 0.0f, 0.0f, 0.8f));
+
+ float outputTime;
+ Property::Value outputValue;
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 3, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::NONE, TEST_LOCATION);
+
+ DevelKeyFrames::GetKeyFrame(keyFrames, 1, outputTime, outputValue);
+
+ DALI_TEST_EQUALS(outputTime, inputTime, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.GetType(), Property::Type::VECTOR4, TEST_LOCATION);
+ DALI_TEST_EQUALS(outputValue.Get<Vector4>(), inputValue, TEST_LOCATION);
+
+ END_TEST;
+}
+
int UtcDaliAnimationAnimateBetweenActorColorAlphaP(void)
{
TestApplication application;
--- /dev/null
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/devel-api/animation/key-frames-devel.h>
+#include <dali/internal/event/animation/key-frames-impl.h>
+
+namespace Dali
+{
+namespace DevelKeyFrames
+{
+
+std::size_t GetKeyFrameCount(KeyFrames keyFrames)
+{
+ return GetImplementation(keyFrames).GetKeyFrameCount();
+}
+
+void GetKeyFrame(KeyFrames keyFrames, std::size_t index, float& time, Property::Value& value)
+{
+ GetImplementation(keyFrames).GetKeyFrame(index, time, value);
+}
+
+} // namespace DevelKeyFrames
+
+} // namespace Dali
--- /dev/null
+#ifndef DALI_KEY_FRAMES_DEVEL_H
+#define DALI_KEY_FRAMES_DEVEL_H
+
+/*
+ * 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
+
+// INTERNAL INCLUDES
+#include <dali/public-api/animation/key-frames.h>
+
+namespace Dali
+{
+namespace DevelKeyFrames
+{
+using ValueConvertor = Property::Value (*)(const Property::Value& input);
+
+/**
+ * @brief Get the number of key frames.
+ * @param[in] keyFrames The KeyFrames object to perform this operation on
+ * @return Total number of key frames
+ */
+DALI_CORE_API std::size_t GetKeyFrameCount(KeyFrames keyFrames);
+
+/**
+ * Get a key frame.
+ * @param[in] keyFrames The KeyFrames object to perform this operation on
+ * @param[in] index The index of the key frame to fetch
+ * @param[out] time The progress of the given key frame
+ * @param[out] value The value of the given key frame
+ */
+DALI_CORE_API void GetKeyFrame(KeyFrames keyFrames, std::size_t index, float& time, Property::Value& value);
+
+} // namespace DevelKeyFrames
+
+} // namespace Dali
+
+#endif // DALI_KEY_FRAMES_DEVEL_H
${devel_api_src_dir}/actors/custom-actor-devel.cpp
${devel_api_src_dir}/animation/animation-data.cpp
${devel_api_src_dir}/animation/animation-devel.cpp
+ ${devel_api_src_dir}/animation/key-frames-devel.cpp
${devel_api_src_dir}/animation/path-constrainer.cpp
${devel_api_src_dir}/common/addon-binder.cpp
${devel_api_src_dir}/common/capabilities.cpp
${devel_api_src_dir}/animation/animation-data.h
${devel_api_src_dir}/animation/path-constrainer.h
${devel_api_src_dir}/animation/animation-devel.h
+ ${devel_api_src_dir}/animation/key-frames-devel.h
)
std::size_t noOfKeyFrames = mKeyFrames->GetNumberOfKeyFrames();
if(noOfKeyFrames)
{
- mKeyFrames->GetKeyFrameAsValue(noOfKeyFrames - 1, value);
+ 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);
+ }
+}
+
} // namespace Internal
} // namespace Dali
*/
Dali::Property::Value GetLastKeyFrameValue() const;
+ /**
+ * @copydoc Dali::DevelKeyFrames::GetKeyFrameCount()
+ */
+ std::size_t GetKeyFrameCount() const;
+
+ /**
+ * @copydoc Dali::DevelKeyFrames::GetKeyFrame()
+ */
+ void GetKeyFrame(std::size_t index, float& time, Property::Value& value) const;
+
private:
Dali::Property::Type mType{Property::NONE}; // Type of the specialization
std::unique_ptr<KeyFrameSpec> mKeyFrames; // Pointer to the specialized key frame object
/**
* Get the key frame value as a Property::Value.
* @param[in] index The index of the key frame to fetch
+ * @param[out] time The progress of the given key frame
* @param[out] value The value of the given key frame
*/
- virtual void GetKeyFrameAsValue(std::size_t index, Property::Value& value) = 0;
+ virtual void GetKeyFrameAsValue(std::size_t index, float& time, Property::Value& value) const = 0;
};
/**
/**
* @copydoc KeyFrameSpec::GetKeyFrameAsValue()
*/
- void GetKeyFrameAsValue(std::size_t index, Property::Value& value) override
+ void GetKeyFrameAsValue(std::size_t index, float& time, Property::Value& value) const override
{
- value = mChannel.mValues[index].mValue;
+ const auto& element = mChannel.mValues[index];
+ time = element.mProgress;
+ value = element.mValue;
}
/**