0d140b071510fcbc4f840d2a5737f42d7f1a66d5
[platform/core/uifw/dali-core.git] / dali / public-api / animation / key-frames.h
1 #ifndef DALI_KEY_FRAMES_H
2 #define DALI_KEY_FRAMES_H
3
4 /*
5  * Copyright (c) 2020 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 // INTERNAL INCLUDES
22 #include <dali/public-api/animation/alpha-function.h>
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/object/property-types.h>
25 #include <dali/public-api/object/property-value.h>
26
27 namespace Dali
28 {
29 /**
30  * @addtogroup dali_core_animation
31  * @{
32  */
33
34 namespace Internal DALI_INTERNAL
35 {
36 class KeyFrames;
37 }
38
39 /**
40  * @brief A set of key frames for a property that can be animated using Dali::Animation::AnimateBetween().
41  *
42  * This allows the generation of key frame objects from individual
43  * Property::Values. The type of the key frame is specified by the
44  * type of the first value to be added. Adding key frames with a
45  * different Property::Value type will result in a run time assert.
46  * @SINCE_1_0.0
47  */
48 class DALI_CORE_API KeyFrames : public BaseHandle
49 {
50 public:
51   /**
52    * @brief Creates an initialized KeyFrames handle.
53    *
54    * @SINCE_1_0.0
55    * @return A handle to a newly allocated Dali resource
56    */
57   static KeyFrames New();
58
59   /**
60    * @brief Downcasts a handle to KeyFrames handle.
61    *
62    * If handle points to a KeyFrames object, the downcast produces valid handle.
63    * If not, the returned handle is left uninitialized.
64    * @SINCE_1_0.0
65    * @param[in] handle Handle to an object
66    * @return Handle to a KeyFrames object or an uninitialized handle
67    */
68   static KeyFrames DownCast(BaseHandle handle);
69
70   /**
71    * @brief Creates an uninitialized KeyFrame handle.
72    *
73    * This can be initialized with KeyFrame::New().
74    * Calling member functions with an uninitialized KeyFrames handle is not allowed.
75    * @SINCE_1_0.0
76    */
77   KeyFrames();
78
79   /**
80    * @brief Destructor.
81    *
82    * This is non-virtual since derived Handle types must not contain data or virtual methods.
83    * @SINCE_1_0.0
84    */
85   ~KeyFrames();
86
87   /**
88    * @brief This copy constructor is required for (smart) pointer semantics.
89    *
90    * @SINCE_1_0.0
91    * @param[in] handle A reference to the copied handle
92    */
93   KeyFrames(const KeyFrames& handle);
94
95   /**
96    * @brief This assignment operator is required for (smart) pointer semantics.
97    *
98    * @SINCE_1_0.0
99    * @param[in] rhs A reference to the copied handle
100    * @return A reference to this
101    */
102   KeyFrames& operator=(const KeyFrames& rhs);
103
104   /**
105    * @brief Move constructor.
106    *
107    * @SINCE_1_9.22
108    * @param[in] rhs A reference to the moved handle
109    */
110   KeyFrames(KeyFrames&& rhs);
111
112   /**
113    * @brief Move assignment operator.
114    *
115    * @SINCE_1_9.22
116    * @param[in] rhs A reference to the moved handle
117    * @return A reference to this
118    */
119   KeyFrames& operator=(KeyFrames&& rhs);
120
121   /**
122    * @brief Gets the type of the key frame.
123    *
124    * If no key frames have been added, this returns Property::NONE.
125    * @SINCE_1_0.0
126    * @return The key frame property type
127    */
128   Property::Type GetType() const;
129
130   /**
131    * @brief Adds a key frame.
132    *
133    * The key frames should be added in time order.
134    * @SINCE_1_0.0
135    * @param[in] progress A progress value between 0.0 and 1.0
136    * @param[in] value A value
137    */
138   void Add(float progress, Property::Value value);
139
140   /**
141    * @brief Adds a key frame.
142    *
143    * The key frames should be added in time order.
144    * @SINCE_1_0.0
145    * @param[in] progress A progress value between 0.0 and 1.0
146    * @param[in] value A value
147    * @param[in] alpha The alpha function used to blend to the next keyframe
148    */
149   void Add(float progress, Property::Value value, AlphaFunction alpha);
150
151 public: // Not intended for application developers
152   /// @cond internal
153   /**
154    * @brief This constructor is used by KeyFrames::New() methods.
155    *
156    * @SINCE_1_0.0
157    * @param[in] keyFrames A pointer to an internal KeyFrame resource
158    */
159   explicit DALI_INTERNAL KeyFrames(Internal::KeyFrames* keyFrames);
160   /// @endcond
161 };
162
163 /**
164  * @}
165  */
166 } // namespace Dali
167
168 #endif // DALI_KEY_FRAMES_H