[dali_1.1.19] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / public-api / animation / linear-constrainer.h
1 #ifndef __DALI_LINEAR_CONSTRAINER_H__
2 #define __DALI_LINEAR_CONSTRAINER_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 //EXTERNAL INCLUDES
22 #include <cfloat> //For FLT_MAX
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/object/handle.h>
26 #include <dali/public-api/object/property-index-ranges.h>
27
28 namespace Dali
29 {
30 /**
31  * @addtogroup dali_core_animation
32  * @{
33  */
34
35 namespace Internal DALI_INTERNAL
36 {
37   class LinearConstrainer;
38 }
39
40 /**
41  * @brief
42  *
43  * LinearConstrainer applies constraints to objects given a linear map.
44  * A linear map is defined by a set of value-progress pairs.
45  * Progress must be normalized between [0,1]. If no progress is defined, the values
46  * are considered to be equally spaced along the x axis.
47  * @SINCE_1_0.0
48  */
49 class DALI_IMPORT_API LinearConstrainer : public Handle
50 {
51 public:
52
53   /**
54    * @brief An enumeration of properties belonging to the LinearConstrainer class.
55    * @SINCE_1_0.0
56    */
57   struct Property
58   {
59     enum
60     {
61       VALUE     = DEFAULT_OBJECT_PROPERTY_START_INDEX,  ///< name "value" type Array of float @SINCE_1_0.0
62       PROGRESS,                                         ///< name "progress" type Array of float @SINCE_1_0.0
63     };
64   };
65
66   /**
67    * @brief Create an initialized LinearConstrainer handle.
68    *
69    * @SINCE_1_0.0
70    * @return a handle to a newly allocated Dali resource.
71    */
72   static LinearConstrainer New();
73
74   /**
75    * @brief Downcast an Object handle to LinearConstrainer handle.
76    *
77    * If handle points to a LinearConstrainer object the downcast produces
78    * valid handle. If not the returned handle is left uninitialized.
79    * @SINCE_1_0.0
80    * @param[in] handle to An object
81    * @return handle to a LinearConstrainer object or an uninitialized handle
82    */
83   static LinearConstrainer DownCast( BaseHandle handle );
84
85   /**
86    * @brief Create an uninitialized LinearConstrainer handle.
87    *
88    * This can be initialized with PathConstrainer::New(). Calling member
89    * functions with an uninitialized Dali::Object is not allowed.
90    * @SINCE_1_0.0
91    */
92   LinearConstrainer();
93
94   /**
95    * @brief Destructor
96    *
97    * This is non-virtual since derived Handle types must not contain data or virtual methods.
98    * @SINCE_1_0.0
99    */
100   ~LinearConstrainer();
101
102   /**
103    * @brief This copy constructor is required for (smart) pointer semantics.
104    *
105    * @SINCE_1_0.0
106    * @param [in] handle A reference to the copied handle
107    */
108   LinearConstrainer(const LinearConstrainer& handle);
109
110   /**
111    * @brief This assignment operator is required for (smart) pointer semantics.
112    *
113    * @SINCE_1_0.0
114    * @param [in] rhs  A reference to the copied handle
115    * @return A reference to this
116    */
117   LinearConstrainer& operator=(const LinearConstrainer& rhs);
118
119   /**
120    * @brief Applies the linear constraint to the target property
121    *
122    * @SINCE_1_0.0
123    * @param[in] target Property to be constrained
124    * @param[in] source Property used as parameter for the path
125    * @param[in] range The range of values in the source property which will be mapped to [0,1]
126    * @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]
127    */
128   void Apply( Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap = Vector2(-FLT_MAX, FLT_MAX) );
129
130   /**
131    * @brief Removes the linear constraint in the target object
132    *
133    * @SINCE_1_0.0
134    * @param[in] target A handle to an object constrained by the LinearConstrainer
135    */
136   void Remove( Dali::Handle& target );
137
138 public: // Not intended for application developers
139   /**
140    * @brief This constructor is used by Dali::New() methods.
141    *
142    * @SINCE_1_0.0
143    * @param[in] pathConstrainer A pointer to an internal PathConstrainer resource
144    */
145   explicit DALI_INTERNAL LinearConstrainer(Internal::LinearConstrainer* pathConstrainer);
146 };
147
148 /**
149  * @}
150  */
151 } // namespace Dali
152
153 #endif // __DALI_LINEAR_CONSTRAINER_H__