[dali_1.0.1] Merge branch '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) 2014 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-functions.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 DALI_IMPORT_API
28 {
29
30 namespace Internal DALI_INTERNAL
31 {
32 class KeyFrames;
33 }
34
35 /**
36  * @brief A set of key frames for a property that can be animated using Dali::Animation::AnimateBetween().
37  *
38  * This allows the generation of key frame objects from individual
39  * Property::Values. The type of the key frame is specified by the
40  * type of the first value to be added. Adding key frames with a
41  * different Property::Value type will result in a run time assert.
42  */
43 class KeyFrames : public BaseHandle
44 {
45 public:
46   /**
47    * @brief Create an initialized KeyFrame handle.
48    *
49    * @return a handle to a newly allocated Dali resource.
50    */
51   static KeyFrames New();
52
53   /**
54    * @brief Downcast an Object handle to KeyFrames handle.
55    *
56    * If handle points to a KeyFrames object the downcast produces
57    * valid handle. If not the returned handle is left uninitialized.
58    * @param[in] handle to An object
59    * @return handle to a KeyFrames object or an uninitialized handle
60    */
61   static KeyFrames DownCast( BaseHandle handle );
62
63   /**
64    * @brief Create an uninitialized KeyFrame handle.
65    *
66    * This can be initialized with KeyFrame::New(). Calling member
67    * functions with an uninitialized Dali::Object is not allowed.
68    */
69   KeyFrames();
70
71   /**
72    * @brief Destructor
73    *
74    * This is non-virtual since derived Handle types must not contain data or virtual methods.
75    */
76   ~KeyFrames();
77
78   /**
79    * @copydoc Dali::BaseHandle::operator=
80    */
81   using BaseHandle::operator=;
82
83   /**
84    * @brief Gets the type of the key frame.
85    *
86    * If no key frames have been added, this returns Property::NONE.
87    * @return The key frame property type.
88    */
89   Property::Type GetType() const;
90
91   /**
92    * @brief Add a key frame.
93    *
94    * The key frames should be added in time order.
95    * @param[in] progress A value between 0.0 and 1.0.
96    * @param[in] value A value.
97    */
98   void Add(float progress, Property::Value value);
99
100   /**
101    * @brief Add a key frame.
102    *
103    * The key frames should be added in time order.
104    * @param[in] progress A value between 0.0 and 1.0.
105    * @param[in] value A value.
106    * @param[in] alpha The alpha function used to blend to the next keyframe
107    */
108   void Add(float progress, Property::Value value, AlphaFunction alpha);
109
110
111 public: // Not intended for application developers
112   /**
113    * @brief This constructor is used by Dali::New() methods.
114    *
115    * @param[in] keyFrames A pointer to an internal KeyFrame resource
116    */
117   explicit DALI_INTERNAL KeyFrames(Internal::KeyFrames* keyFrames);
118 };
119
120 } // namespace Dali
121
122 #endif // __DALI_KEY_FRAMES_H__