1 #ifndef __DALI_PATH_CONSTRAINER_H__
2 #define __DALI_PATH_CONSTRAINER_H__
5 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <cfloat> //For FLT_MAX
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>
32 namespace Internal DALI_INTERNAL
34 class PathConstrainer;
39 * PathConstrainer applies constraints to objects to follow a path.
40 * A Vector3 property will be constrained to the position of the path and a Rotation property will be constrained to follow
41 * the tangent of the path given a forward vector in object's local space.
44 class DALI_IMPORT_API PathConstrainer : public Handle
49 * @brief An enumeration of properties belonging to the PathConstrainer class.
55 FORWARD = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "forward" type Vector3
56 POINTS, ///< name "points" type Array of Vector3
57 CONTROL_POINTS ///< name "controlPoints" type Array of Vector3
62 * @brief Create an initialized PathConstrainer handle.
64 * @return a handle to a newly allocated Dali resource.
66 static PathConstrainer New();
69 * @brief Downcast an Object handle to PathConstrainer handle.
71 * If handle points to a PathConstrainer object the downcast produces
72 * valid handle. If not the returned handle is left uninitialized.
73 * @param[in] handle to An object
74 * @return handle to a PathConstrainer object or an uninitialized handle
76 static PathConstrainer DownCast( BaseHandle handle );
79 * @brief Create an uninitialized PathConstrainer handle.
81 * This can be initialized with PathConstrainer::New(). Calling member
82 * functions with an uninitialized Dali::Object is not allowed.
89 * This is non-virtual since derived Handle types must not contain data or virtual methods.
94 * @brief This copy constructor is required for (smart) pointer semantics.
96 * @param [in] handle A reference to the copied handle
98 PathConstrainer(const PathConstrainer& handle);
101 * @brief This assignment operator is required for (smart) pointer semantics.
103 * @param [in] rhs A reference to the copied handle
104 * @return A reference to this
106 PathConstrainer& operator=(const PathConstrainer& rhs);
109 * @brief Applies the path constraint to the target property
111 * @param[in] target Property to be constrained
112 * @param[in] source Property used as parameter for the path
113 * @param[in] range The range of values in the source property which will be mapped to [0,1]
114 * @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]
116 void Apply( Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap = Vector2(-FLT_MAX, FLT_MAX) );
119 * @brief Removes the path constraint in the target object
121 * @param[in] target A handle to an object constrained by the PathConstrainer
123 void Remove( Dali::Handle& target );
125 public: // Not intended for application developers
127 * @brief This constructor is used by Dali::New() methods.
129 * @param[in] pathConstrainer A pointer to an internal PathConstrainer resource
131 explicit DALI_INTERNAL PathConstrainer(Internal::PathConstrainer* pathConstrainer);
136 #endif // __DALI_PATH_CONSTRAINER_H__