Moved actor recursion methods to actor-parent-impl
[platform/core/uifw/dali-core.git] / dali / devel-api / animation / path-constrainer.h
1 #ifndef DALI_PATH_CONSTRAINER_H
2 #define DALI_PATH_CONSTRAINER_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 <cfloat> //For FLT_MAX
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/animation/path.h>
26 #include <dali/public-api/object/handle.h>
27 #include <dali/public-api/object/property-index-ranges.h>
28
29 namespace Dali
30 {
31 namespace Internal DALI_INTERNAL
32 {
33 class PathConstrainer;
34 }
35 /**
36  * @brief
37  *
38  * PathConstrainer applies constraints to objects to follow a path.
39  * A Vector3 property will be constrained to the position of the path and a Rotation property will be constrained to follow
40  * the tangent of the path given a forward vector in object's local space.
41  *
42  */
43 class DALI_CORE_API PathConstrainer : public Handle
44 {
45 public:
46   /**
47    * @brief An enumeration of properties belonging to the PathConstrainer class.
48    */
49   struct Property
50   {
51     enum
52     {
53       FORWARD = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "forward" type Vector3
54       POINTS,                                        ///< name "points" type Array of Vector3
55       CONTROL_POINTS                                 ///< name "controlPoints" type Array of Vector3
56     };
57   };
58
59   /**
60    * @brief Create an initialized PathConstrainer handle.
61    *
62    * @return a handle to a newly allocated Dali resource.
63    */
64   static PathConstrainer New();
65
66   /**
67    * @brief Downcast an Object handle to PathConstrainer handle.
68    *
69    * If handle points to a PathConstrainer object the downcast produces
70    * valid handle. If not the returned handle is left uninitialized.
71    * @param[in] handle to An object
72    * @return handle to a PathConstrainer object or an uninitialized handle
73    */
74   static PathConstrainer DownCast(BaseHandle handle);
75
76   /**
77    * @brief Create an uninitialized PathConstrainer handle.
78    *
79    * This can be initialized with PathConstrainer::New(). Calling member
80    * functions with an uninitialized Dali::Object is not allowed.
81    */
82   PathConstrainer();
83
84   /**
85    * @brief Destructor
86    *
87    * This is non-virtual since derived Handle types must not contain data or virtual methods.
88    */
89   ~PathConstrainer();
90
91   /**
92    * @brief This copy constructor is required for (smart) pointer semantics.
93    *
94    * @param [in] handle A reference to the copied handle
95    */
96   PathConstrainer(const PathConstrainer& handle);
97
98   /**
99    * @brief This assignment operator is required for (smart) pointer semantics.
100    *
101    * @param [in] rhs  A reference to the copied handle
102    * @return A reference to this
103    */
104   PathConstrainer& operator=(const PathConstrainer& rhs);
105
106   /**
107    * @brief Applies the path constraint to the target property
108    *
109    * @param[in] target Property to be constrained
110    * @param[in] source Property used as parameter for the path
111    * @param[in] range The range of values in the source property which will be mapped to [0,1]
112    * @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]
113    */
114   void Apply(Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap = Vector2(-FLT_MAX, FLT_MAX));
115
116   /**
117    * @brief Removes the path constraint in the target object
118    *
119    * @param[in] target A handle to an object constrained by the PathConstrainer
120    */
121   void Remove(Dali::Handle& target);
122
123 public: // Not intended for application developers
124   /**
125    * @brief This constructor is used by Dali::New() methods.
126    *
127    * @param[in] pathConstrainer A pointer to an internal PathConstrainer resource
128    */
129   explicit DALI_INTERNAL PathConstrainer(Internal::PathConstrainer* pathConstrainer);
130 };
131
132 } // namespace Dali
133
134 #endif // DALI_PATH_CONSTRAINER_H