1 #ifndef DALI_ANIMATION_DATA_H
2 #define DALI_ANIMATION_DATA_H
5 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
25 #include <dali/public-api/actors/actor.h>
26 #include <dali/public-api/animation/alpha-function.h>
27 #include <dali/public-api/animation/animation.h>
28 #include <dali/public-api/common/dali-vector.h>
29 #include <dali/public-api/object/property-value.h>
34 * @brief This object stores description data that can be used to generate an Animation.
35 * This data can be produced from passing JSON.
37 * This then allows the same description data to be used to repeatedly create an animation multiple times.
39 class DALI_CORE_API AnimationData
47 * @brief AnimationDataElement Describes one part of an animation.
49 struct AnimationDataElement
53 Property::Value value;
54 AlphaFunction::BuiltinFunction alphaFunction;
55 float timePeriodDelay;
56 float timePeriodDuration;
58 AnimationDataElement()
59 : alphaFunction(AlphaFunction::DEFAULT),
60 timePeriodDelay(0.0f),
61 timePeriodDuration(1.0f)
67 * @brief AnimationData holds the required data required to define an
68 * animation to be performed on an actor or actors.
70 using AnimationDataList = Dali::Vector<AnimationDataElement*>;
73 * @brief Adds one AnimationDataElement to the list to describe one animation.
74 * @param[in] animationDataElement A pre-populated struct to add
75 * @note This class takes ownership of animationDataElement
77 void Add(AnimationDataElement* animationDataElement);
80 * @brief Creates a Dali::Animation from this AnimationData object.
81 * The AnimationData object can describe multiple individual property animations.
82 * Each one will be added to a created animation.
84 * If there is no animation data defined, an invalid Dali::Animation handle is returned.
85 * @param[in] targetActor The actor to target the property animations to.
86 * @param[in] duration The duration of the animation to create.
87 * @return A ready-to-go Dali::Animation, or an invalid handle if there was no data.
89 Dali::Animation CreateAnimation(Dali::Actor targetActor, float duration);
92 * @brief Empties this AnimationData object (and frees all memory).
97 AnimationDataList mAnimationDataList; ///< A vector of individual property animations from which to generate a Dali::Animation.
102 #endif // DALI_ANIMATION_DATA_H