Merge branch 'devel/master (1.1.2 ~ 1.1.7)' into tizen
[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) 2015 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-value.h>
25 #include <dali/public-api/object/property-types.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  */
47 class DALI_IMPORT_API KeyFrames : public BaseHandle
48 {
49 public:
50   /**
51    * @brief Create an initialized KeyFrame handle.
52    *
53    * @return a handle to a newly allocated Dali resource.
54    */
55   static KeyFrames New();
56
57   /**
58    * @brief Downcast an Object handle to KeyFrames handle.
59    *
60    * If handle points to a KeyFrames object the downcast produces
61    * valid handle. If not the returned handle is left uninitialized.
62    * @param[in] handle to An object
63    * @return handle to a KeyFrames object or an uninitialized handle
64    */
65   static KeyFrames DownCast( BaseHandle handle );
66
67   /**
68    * @brief Create an uninitialized KeyFrame handle.
69    *
70    * This can be initialized with KeyFrame::New(). Calling member
71    * functions with an uninitialized Dali::Object is not allowed.
72    */
73   KeyFrames();
74
75   /**
76    * @brief Destructor
77    *
78    * This is non-virtual since derived Handle types must not contain data or virtual methods.
79    */
80   ~KeyFrames();
81
82   /**
83    * @brief This copy constructor is required for (smart) pointer semantics.
84    *
85    * @param [in] handle A reference to the copied handle
86    */
87   KeyFrames(const KeyFrames& handle);
88
89   /**
90    * @brief This assignment operator is required for (smart) pointer semantics.
91    *
92    * @param [in] rhs  A reference to the copied handle
93    * @return A reference to this
94    */
95   KeyFrames& operator=(const KeyFrames& rhs);
96
97   /**
98    * @brief Gets the type of the key frame.
99    *
100    * If no key frames have been added, this returns Property::NONE.
101    * @return The key frame property type.
102    */
103   Property::Type GetType() const;
104
105   /**
106    * @brief Add a key frame.
107    *
108    * The key frames should be added in time order.
109    * @param[in] progress A value between 0.0 and 1.0.
110    * @param[in] value A value.
111    */
112   void Add(float progress, Property::Value value);
113
114   /**
115    * @brief Add a key frame.
116    *
117    * The key frames should be added in time order.
118    * @param[in] progress A value between 0.0 and 1.0.
119    * @param[in] value A value.
120    * @param[in] alpha The alpha function used to blend to the next keyframe
121    */
122   void Add(float progress, Property::Value value, AlphaFunction alpha);
123
124
125 public: // Not intended for application developers
126   /**
127    * @brief This constructor is used by Dali::New() methods.
128    *
129    * @param[in] keyFrames A pointer to an internal KeyFrame resource
130    */
131   explicit DALI_INTERNAL KeyFrames(Internal::KeyFrames* keyFrames);
132 };
133
134 /**
135  * @}
136  */
137 } // namespace Dali
138
139 #endif // __DALI_KEY_FRAMES_H__