8d662cfe5d09ac5cd538adfd1a6ccdb2faa657a8
[platform/core/uifw/dali-toolkit.git] / dali-toolkit / devel-api / visual-factory / transition-data.h
1 #ifndef __DALI_TOOLKIT_TRANSITION_DATA_H__
2 #define __DALI_TOOLKIT_TRANSITION_DATA_H__
3
4 /*
5  * Copyright (c) 2018 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 <dali/public-api/object/base-handle.h>
23 #include <dali/public-api/animation/alpha-function.h>
24 #include <dali/public-api/object/property-array.h>
25 #include <dali/public-api/object/property-map.h>
26
27 // INTERNAL INCLUDES
28 #include <dali-toolkit/public-api/dali-toolkit-common.h>
29
30 namespace Dali
31 {
32
33 namespace Toolkit
34 {
35
36 namespace Internal
37 {
38 class TransitionData;
39 }
40
41 /**
42  * @brief This object translates data from a property array of maps
43  * into an array of animators.
44  *
45  * Each animator describes a named object and a named property of that object
46  * to be animated. Internally, these are translated into object instances and
47  * property indices to be animated.
48  * @see Dali::Toolkit::Internal::Control::CreateTransition()
49  *
50  * The animators can each be retrieved as a Property::Map by using Count() and
51  * GetAnimatorAt().
52  *
53  * In psuedo-JSON, the property array can be represented as follows:
54  *
55  * [
56  *   {
57  *     "target": "objectName",
58  *     "property": "propertyKey",
59  *     "initialValue": <value>,  # The property value can be one of several types
60  *     "targetValue":  <value>,
61  *     "animator": {
62  *       "alphaFunction":<easing-function>",
63  *       "timePeriod":{
64  *         "duration": 1.0,
65  *         "delay":    0.0
66  *       }
67  *     }
68  *   },
69  *   # more animators
70  * ]
71  *
72  */
73 class DALI_TOOLKIT_API TransitionData : public BaseHandle
74 {
75 public:
76   /**
77    * Create an uninitialized handle
78    *
79    * @SINCE_1_2.12
80    */
81   TransitionData();
82
83   /**
84    * Destructor - non virtual
85    *
86    * @SINCE_1_2.12
87    */
88   ~TransitionData();
89
90   /**
91    * @brief Creates a TransitionData object
92    *
93    * @SINCE_1_2.12
94    * @param[in] transition The transition data to store (a single animator)
95    * @return A handle to an initialized data.
96    */
97   static TransitionData New( const Property::Map& transition );
98
99   /**
100    * @brief Creates a TransitionData object
101    *
102    * @SINCE_1_2.12
103    * @param[in] transition The transition data to store (an array of maps of animators)
104    * @return A handle to an initialized data.
105    */
106   static TransitionData New( const Property::Array& transition );
107
108   /**
109    * @brief Downcast to a TransitionData handle
110    *
111    * @SINCE_1_2.12
112    * If handle is not a TransitionData, the returned handle is left uninitialized.
113    * @param[in] handle Handle to an object
114    * @return TransitionData handle or an uninitialized handle.
115    */
116   static TransitionData DownCast( BaseHandle handle );
117
118   /**
119    * @brief Copy constructor
120    *
121    * @SINCE_1_2.12
122    * @param[in] handle Handle to an object
123    */
124   TransitionData( const TransitionData& handle );
125
126   /**
127    * @brief Assignment Operator
128    *
129    * @SINCE_1_2.12
130    * @param[in] handle Handle to an object
131    * @return A reference to this object.
132    */
133   TransitionData& operator=( const TransitionData& handle );
134
135   /**
136    * @brief returns the count of the individual property transitions
137    * stored within this handle.
138    *
139    * @SINCE_1_2.12
140    * @return The count of individual transitions
141    */
142   size_t Count() const;
143
144   /**
145    * @brief Return the animator at the given index as a property map.
146    * @param[in] index The index of the animator ( Must be less than Count() )
147    * @return A property map representing the animator
148    */
149   Property::Map GetAnimatorAt( size_t index );
150
151 public: // Not intended for application developers
152
153   explicit DALI_INTERNAL TransitionData( Internal::TransitionData *impl );
154 };
155
156 } // namespace Toolkit
157 } // namespace Dali
158
159 #endif // __DALI_TOOLKIT_TRANSITION_DATA_H__