Merge remote-tracking branch 'origin/tizen' into new_text
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / constraint-impl.h
1 #ifndef __DALI_INTERNAL_CONSTRAINT_H__
2 #define __DALI_INTERNAL_CONSTRAINT_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
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>
28
29 namespace Dali
30 {
31
32 namespace Internal
33 {
34
35 class ActiveConstraintBase;
36 class Object;
37
38 /**
39  * Constraints are used to constrain a property of an object, after animations have been applied.
40  */
41 class Constraint : public BaseObject
42 {
43 public:
44
45   typedef Any AnyFunction;
46
47   /**
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    */
54   Constraint( Property::Index target,
55               Property::Type targetType,
56               SourceContainer& sources,
57               AnyFunction& func );
58
59   /**
60    * @copydoc Dali::Constraint::SetApplyTime()
61    */
62   void SetApplyTime( TimePeriod timePeriod );
63
64   /**
65    * @copydoc Dali::Constraint::GetApplyTime()
66    */
67   TimePeriod GetApplyTime() const;
68
69   /**
70    * @copydoc Dali::Constraint::SetAlphaFunction( AlphaFunction func )
71    */
72   void SetAlphaFunction( AlphaFunction func );
73
74   /**
75    * @copydoc Dali::Constraint::GetAlphaFunction()
76    */
77   AlphaFunction GetAlphaFunction() const;
78
79   /**
80    * @copydoc Dali::Constraint::SetRemoveAction()
81    */
82   void SetRemoveAction(Dali::Constraint::RemoveAction action);
83
84   /**
85    * @copydoc Dali::Constraint::GetRemoveAction()
86    */
87   Dali::Constraint::RemoveAction GetRemoveAction() const;
88
89   /**
90    * @copydoc Dali::Constraint::SetTag()
91    */
92   void SetTag( const unsigned int tag);
93
94   /**
95    * @copydoc Dali::Constraint::GetTag()
96    */
97   unsigned int GetTag() const;
98
99
100
101
102   /**
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.
106    */
107   ActiveConstraintBase* CreateActiveConstraint();
108
109 protected:
110
111   /**
112    * A reference counted object may only be deleted by calling Unreference()
113    */
114   virtual ~Constraint();
115
116 private:
117
118   // Undefined
119   Constraint(const Constraint&);
120
121   // Undefined
122   Constraint& operator=(const Constraint& rhs);
123
124 protected:
125
126   Dali::ActiveConstraint mActiveConstraintTemplate; ///< Used to create active constraints
127
128   TimePeriod mApplyTime;
129 };
130
131 } // namespace Internal
132
133 // Helpers for public-api forwarding methods
134
135 inline Internal::Constraint& GetImplementation(Dali::Constraint& constraint)
136 {
137   DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
138
139   BaseObject& handle = constraint.GetBaseObject();
140
141   return static_cast<Internal::Constraint&>(handle);
142 }
143
144 inline const Internal::Constraint& GetImplementation(const Dali::Constraint& constraint)
145 {
146   DALI_ASSERT_ALWAYS( constraint && "Constraint handle is empty" );
147
148   const BaseObject& handle = constraint.GetBaseObject();
149
150   return static_cast<const Internal::Constraint&>(handle);
151 }
152
153 } // namespace Dali
154
155 #endif // __DALI_INTERNAL_CONSTRAINT_H__