Use modern construct 'using' instead of typedef.
[platform/core/uifw/dali-core.git] / dali / devel-api / animation / animation-data.h
1 #ifndef DALI_ANIMATION_DATA_H
2 #define DALI_ANIMATION_DATA_H
3
4 /*
5  * Copyright (c) 2019 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // EXTERNAL INCLUDES
22 #include <string>
23
24 // INTERNAL INCLUDES
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>
30
31 namespace Dali
32 {
33
34 /**
35  * @brief This object stores description data that can be used to generate an Animation.
36  * This data can be produced from passing JSON.
37  *
38  * This then allows the same description data to be used to repeatedly create an animation multiple times.
39  */
40 class DALI_CORE_API AnimationData
41 {
42 public:
43
44   AnimationData();
45
46   ~AnimationData();
47
48   /**
49    * @brief AnimationDataElement Describes one part of an animation.
50    */
51   struct AnimationDataElement
52   {
53     std::string actor;
54     std::string property;
55     Property::Value value;
56     AlphaFunction::BuiltinFunction alphaFunction;
57     float timePeriodDelay;
58     float timePeriodDuration;
59
60     AnimationDataElement()
61     : alphaFunction( AlphaFunction::DEFAULT ),
62       timePeriodDelay( 0.0f ),
63       timePeriodDuration( 1.0f )
64     {
65     }
66   };
67
68
69   /**
70    * @brief AnimationData holds the required data required to define an
71    * animation to be performed on an actor or actors.
72    */
73   using AnimationDataList = Dali::Vector<AnimationDataElement*>;
74
75   /**
76    * @brief Adds one AnimationDataElement to the list to describe one animation.
77    * @param[in] animationDataElement A pre-populated struct to add
78    * @note This class takes ownership of animationDataElement
79    */
80   void Add( AnimationDataElement* animationDataElement );
81
82
83   /**
84    * @brief Creates a Dali::Animation from this AnimationData object.
85    * The AnimationData object can describe multiple individual property animations.
86    * Each one will be added to a created animation.
87    *
88    * If there is no animation data defined, an invalid Dali::Animation handle is returned.
89    * @param[in] targetActor The actor to target the property animations to.
90    * @param[in] duration The duration of the animation to create.
91    * @return    A ready-to-go Dali::Animation, or an invalid handle if there was no data.
92    */
93   Dali::Animation CreateAnimation( Dali::Actor targetActor, float duration );
94
95
96   /**
97    * @brief Empties this AnimationData object (and frees all memory).
98    */
99   void Clear();
100
101 private:
102
103   AnimationDataList mAnimationDataList; ///< A vector of individual property animations from which to generate a Dali::Animation.
104
105 };
106
107
108 } // namespace Dali
109
110 #endif // DALI_ANIMATION_DATA_H
111