1 #ifndef __DALI_INTERNAL_CONSTRAINT_H__
2 #define __DALI_INTERNAL_CONSTRAINT_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/public-api/animation/active-constraint.h>
22 #include <dali/public-api/animation/alpha-functions.h>
23 #include <dali/public-api/animation/constraint.h>
24 #include <dali/public-api/animation/time-period.h>
25 #include <dali/public-api/object/base-object.h>
26 #include <dali/internal/event/animation/constraint-source-impl.h>
34 class ActiveConstraintBase;
38 * Constraints are used to constrain a property of an object, after animations have been applied.
40 class Constraint : public BaseObject
44 typedef Any AnyFunction;
47 * Construct a new constraint which targets a property.
48 * @param [in] target The index of the property to constrain.
49 * @param [in] targetType The type of the constrained property.
50 * @param [in] sources The proxy objects which provide parameters for func.
51 * @param [in] func The constraint function.
52 * @param [in] interpolator A function used to interpolate between the start value, and the value returned by func.
54 Constraint( Property::Index target,
55 Property::Type targetType,
56 SourceContainer& sources,
58 AnyFunction& interpolator );
61 * @copydoc Dali::Constraint::SetApplyTime()
63 void SetApplyTime( TimePeriod timePeriod );
66 * @copydoc Dali::Constraint::GetApplyTime()
68 TimePeriod GetApplyTime() const;
71 * @copydoc Dali::Constraint::SetRemoveTime()
73 void SetRemoveTime( TimePeriod timePeriod );
76 * @copydoc Dali::Constraint::GetRemoveTime()
78 TimePeriod GetRemoveTime() const;
81 * @copydoc Dali::Constraint::SetAlphaFunction( AlphaFunction func )
83 void SetAlphaFunction( AlphaFunction func );
86 * @copydoc Dali::Constraint::GetAlphaFunction()
88 AlphaFunction GetAlphaFunction() const;
91 * @copydoc Dali::Constraint::SetRemoveAction()
93 void SetRemoveAction(Dali::Constraint::RemoveAction action);
96 * @copydoc Dali::Constraint::GetRemoveAction()
98 Dali::Constraint::RemoveAction GetRemoveAction() const;
101 * Create an active constraint.
102 * An active constraint is created each time the constraint is applied to an object.
103 * @return A newly allocated active-constraint.
105 ActiveConstraintBase* CreateActiveConstraint();
110 * A reference counted object may only be deleted by calling Unreference()
112 virtual ~Constraint();
117 Constraint(const Constraint&);
120 Constraint& operator=(const Constraint& rhs);
124 Dali::ActiveConstraint mActiveConstraintTemplate; ///< Used to create active constraints
126 TimePeriod mApplyTime;
129 } // namespace Internal
131 // Helpers for public-api forwarding methods
133 inline Internal::Constraint& GetImplementation(Dali::Constraint& constraint)
135 DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
137 BaseObject& handle = constraint.GetBaseObject();
139 return static_cast<Internal::Constraint&>(handle);
142 inline const Internal::Constraint& GetImplementation(const Dali::Constraint& constraint)
144 DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
146 const BaseObject& handle = constraint.GetBaseObject();
148 return static_cast<const Internal::Constraint&>(handle);
153 #endif // __DALI_INTERNAL_CONSTRAINT_H__