1 #ifndef __DALI_INTERNAL_CONSTRAINT_H__
2 #define __DALI_INTERNAL_CONSTRAINT_H__
5 * Copyright (c) 2014 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 <dali/public-api/animation/active-constraint.h>
23 #include <dali/public-api/animation/alpha-functions.h>
24 #include <dali/public-api/animation/constraint.h>
25 #include <dali/public-api/animation/time-period.h>
26 #include <dali/public-api/object/base-object.h>
27 #include <dali/internal/event/animation/constraint-source-impl.h>
35 class ActiveConstraintBase;
39 * Constraints are used to constrain a property of an object, after animations have been applied.
41 class Constraint : public BaseObject
45 typedef Any AnyFunction;
48 * Construct a new constraint which targets a property.
49 * @param [in] target The index of the property to constrain.
50 * @param [in] targetType The type of the constrained property.
51 * @param [in] sources The objects which provide parameters for func.
52 * @param [in] func The constraint function.
53 * @param [in] interpolator A function used to interpolate between the start value, and the value returned by func.
55 Constraint( Property::Index target,
56 Property::Type targetType,
57 SourceContainer& sources,
59 AnyFunction& interpolator );
62 * @copydoc Dali::Constraint::SetApplyTime()
64 void SetApplyTime( TimePeriod timePeriod );
67 * @copydoc Dali::Constraint::GetApplyTime()
69 TimePeriod GetApplyTime() const;
72 * @copydoc Dali::Constraint::SetAlphaFunction( AlphaFunction func )
74 void SetAlphaFunction( AlphaFunction func );
77 * @copydoc Dali::Constraint::GetAlphaFunction()
79 AlphaFunction GetAlphaFunction() const;
82 * @copydoc Dali::Constraint::SetRemoveAction()
84 void SetRemoveAction(Dali::Constraint::RemoveAction action);
87 * @copydoc Dali::Constraint::GetRemoveAction()
89 Dali::Constraint::RemoveAction GetRemoveAction() const;
92 * @copydoc Dali::Constraint::SetTag()
94 void SetTag( const unsigned int tag);
97 * @copydoc Dali::Constraint::GetTag()
99 unsigned int GetTag() const;
105 * Create an active constraint.
106 * An active constraint is created each time the constraint is applied to an object.
107 * @return A newly allocated active-constraint.
109 ActiveConstraintBase* CreateActiveConstraint();
114 * A reference counted object may only be deleted by calling Unreference()
116 virtual ~Constraint();
121 Constraint(const Constraint&);
124 Constraint& operator=(const Constraint& rhs);
128 Dali::ActiveConstraint mActiveConstraintTemplate; ///< Used to create active constraints
130 TimePeriod mApplyTime;
133 } // namespace Internal
135 // Helpers for public-api forwarding methods
137 inline Internal::Constraint& GetImplementation(Dali::Constraint& constraint)
139 DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
141 BaseObject& handle = constraint.GetBaseObject();
143 return static_cast<Internal::Constraint&>(handle);
146 inline const Internal::Constraint& GetImplementation(const Dali::Constraint& constraint)
148 DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
150 const BaseObject& handle = constraint.GetBaseObject();
152 return static_cast<const Internal::Constraint&>(handle);
157 #endif // __DALI_INTERNAL_CONSTRAINT_H__