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.
54 Constraint( Property::Index target,
55 Property::Type targetType,
56 SourceContainer& sources,
60 * @copydoc Dali::Constraint::SetApplyTime()
62 void SetApplyTime( TimePeriod timePeriod );
65 * @copydoc Dali::Constraint::GetApplyTime()
67 TimePeriod GetApplyTime() const;
70 * @copydoc Dali::Constraint::SetAlphaFunction( AlphaFunction func )
72 void SetAlphaFunction( AlphaFunction func );
75 * @copydoc Dali::Constraint::GetAlphaFunction()
77 AlphaFunction GetAlphaFunction() const;
80 * @copydoc Dali::Constraint::SetRemoveAction()
82 void SetRemoveAction(Dali::Constraint::RemoveAction action);
85 * @copydoc Dali::Constraint::GetRemoveAction()
87 Dali::Constraint::RemoveAction GetRemoveAction() const;
90 * @copydoc Dali::Constraint::SetTag()
92 void SetTag( const unsigned int tag);
95 * @copydoc Dali::Constraint::GetTag()
97 unsigned int GetTag() const;
103 * Create an active constraint.
104 * An active constraint is created each time the constraint is applied to an object.
105 * @return A newly allocated active-constraint.
107 ActiveConstraintBase* CreateActiveConstraint();
112 * A reference counted object may only be deleted by calling Unreference()
114 virtual ~Constraint();
119 Constraint(const Constraint&);
122 Constraint& operator=(const Constraint& rhs);
126 Dali::ActiveConstraint mActiveConstraintTemplate; ///< Used to create active constraints
128 TimePeriod mApplyTime;
131 } // namespace Internal
133 // Helpers for public-api forwarding methods
135 inline Internal::Constraint& GetImplementation(Dali::Constraint& constraint)
137 DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
139 BaseObject& handle = constraint.GetBaseObject();
141 return static_cast<Internal::Constraint&>(handle);
144 inline const Internal::Constraint& GetImplementation(const Dali::Constraint& constraint)
146 DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
148 const BaseObject& handle = constraint.GetBaseObject();
150 return static_cast<const Internal::Constraint&>(handle);
155 #endif // __DALI_INTERNAL_CONSTRAINT_H__