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