1 #ifndef __DALI_LINEAR_CONSTRAINER_H__
2 #define __DALI_LINEAR_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/object/handle.h>
26 #include <dali/public-api/object/property-index-ranges.h>
31 * @addtogroup dali_core_animation
35 namespace Internal DALI_INTERNAL
37 class LinearConstrainer;
41 * @brief LinearConstrainer applies constraints to objects given a linear map.
43 * A linear map is defined by a set of value-progress pairs.
44 * Progress must be normalized between [0,1]. If no progress is defined, the values
45 * are considered to be equally spaced along the x axis.
48 class DALI_IMPORT_API LinearConstrainer : public Handle
53 * @brief An enumeration of properties belonging to the LinearConstrainer class.
60 VALUE = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< type Array of float @since_tizen 2.4
61 PROGRESS, ///< type Array of float @since_tizen 2.4
66 * @brief Create an initialized LinearConstrainer handle.
69 * @return A handle to a newly allocated Dali resource.
71 static LinearConstrainer New();
74 * @brief Downcast a handle to LinearConstrainer handle.
76 * If handle points to a LinearConstrainer object the downcast produces
77 * valid handle. If not the returned handle is left uninitialized.
79 * @param[in] handle Handle to an object
80 * @return Handle to a LinearConstrainer object or an uninitialized handle
82 static LinearConstrainer DownCast( BaseHandle handle );
85 * @brief Create an uninitialized LinearConstrainer handle.
87 * This can be initialized with @ref PathConstrainer::New
88 * Calling member functions with an uninitialized LinearConstrainer handle is not allowed.
96 * This is non-virtual since derived Handle types must not contain data or virtual methods.
102 * @brief This copy constructor is required for (smart) pointer semantics.
105 * @param [in] handle A reference to the copied handle
107 LinearConstrainer(const LinearConstrainer& handle);
110 * @brief This assignment operator is required for (smart) pointer semantics.
113 * @param [in] rhs A reference to the copied handle
114 * @return A reference to this
116 LinearConstrainer& operator=(const LinearConstrainer& rhs);
119 * @brief Applies the linear constraint to the target property
122 * @param[in] target Property to be constrained
123 * @param[in] source Property used as parameter for the path
124 * @param[in] range The range of values in the source property which will be mapped to [0,1]
125 * @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]. See cfloat.h for FLT_MAX
127 void Apply( Dali::Property target, Dali::Property source, const Vector2& range, const Vector2& wrap = Vector2(-FLT_MAX, FLT_MAX) );
130 * @brief Removes the linear constraint in the target object
133 * @param[in] target A handle to an object constrained by the LinearConstrainer
135 void Remove( Dali::Handle& target );
137 public: // Not intended for application developers
139 * @brief This constructor is used by LinearConstrainer::New() methods.
142 * @param[in] pathConstrainer A pointer to an internal PathConstrainer resource
144 explicit DALI_INTERNAL LinearConstrainer(Internal::LinearConstrainer* pathConstrainer);
152 #endif // __DALI_LINEAR_CONSTRAINER_H__