Merge "Move memory pool class internal" into tizen
[platform/core/uifw/dali-core.git] / dali / public-api / animation / active-constraint.h
1 #ifndef __DALI_ACTIVE_CONSTRAINT_H__
2 #define __DALI_ACTIVE_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-declarations.h>
23 #include <dali/public-api/object/any.h>
24 #include <dali/public-api/object/handle.h>
25 #include <dali/public-api/object/property.h>
26 #include <dali/public-api/object/property-index-ranges.h>
27
28 namespace Dali
29 {
30
31 namespace Internal DALI_INTERNAL
32 {
33 class ActiveConstraintBase;
34 }
35
36 /**
37  * @brief A constraint which is being applied to an object.
38  *
39  * Signals
40  * | %Signal Name | Method                |
41  * |--------------|-----------------------|
42  * | applied      | @ref AppliedSignal()  |
43  */
44 class DALI_IMPORT_API ActiveConstraint : public Handle
45 {
46 public:
47
48   /**
49    * @brief An enumeration of properties belonging to the ActiveConstraint class.
50    */
51   struct Property
52   {
53     enum
54     {
55       WEIGHT = DEFAULT_DERIVED_HANDLE_PROPERTY_START_INDEX, ///< name "weight", type Float
56     };
57   };
58
59   static const float FINAL_WEIGHT;   ///< 1.0f means the constraint is fully-applied, unless weight is still being animated
60   static const float DEFAULT_WEIGHT; ///< 1.0f
61
62   /**
63    * @brief Create an uninitialized Constraint; this can be initialized with Constraint::New().
64    *
65    * Calling member functions with an uninitialized Dali::Object is not allowed.
66    */
67   ActiveConstraint();
68
69   /**
70    * @brief Dali::ActiveConstraint is intended as a base class
71    *
72    * This is non-virtual since derived Handle types must not contain data or virtual methods.
73    */
74   ~ActiveConstraint();
75
76   /**
77    * @brief This copy constructor is required for (smart) pointer semantics.
78    *
79    * @param [in] handle A reference to the copied handle
80    */
81   ActiveConstraint(const ActiveConstraint& handle);
82
83   /**
84    * @brief This assignment operator is required for (smart) pointer semantics.
85    *
86    * @param [in] rhs  A reference to the copied handle
87    * @return A reference to this
88    */
89   ActiveConstraint& operator=(const ActiveConstraint& rhs);
90
91   /**
92    * @brief Retrieve the object which this constraint is targeting.
93    *
94    * @return The target object.
95    */
96   Handle GetTargetObject();
97
98   /**
99    * @brief Retrieve the property which this constraint is targeting.
100    *
101    * @return The target property.
102    */
103   Dali::Property::Index GetTargetProperty();
104
105   /**
106    * @brief Set the weight of the constraint; this is a value clamped between 0.
107    * 0f and 1.0f.
108    * The default is 1.0f.
109    * 0.0f means the constraint has no effect, and 1.0f means the constraint is fully-applied.
110    * @note This is an asynchronous method; the value written may not match a value subsequently read with GetCurrentWeight().
111    * @param [in] weight The weight.
112    */
113   void SetWeight( float weight );
114
115   /**
116    * @brief Retrieve the current weight of the constraint.
117    *
118    * @return The current weight.
119    */
120   float GetCurrentWeight() const;
121
122   /**
123    * @brief This signal is emitted after the apply-time of the constraint has expired.
124    *
125    * @note A non-zero apply-time must have been set using Constraint::SetApplyTime().
126    * @return A signal object to Connect() with.
127    */
128   ActiveConstraintSignalType& AppliedSignal();
129
130 public: // Not intended for use by Application developers
131
132   /**
133    * @brief This constructor is used by Dali New() methods.
134    *
135    * @param [in] constraint A pointer to a newly allocated Dali resource
136    */
137   explicit DALI_INTERNAL ActiveConstraint( Internal::ActiveConstraintBase* constraint );
138 };
139
140 } // namespace Dali
141
142 #endif // __DALI_ACTIVE_CONSTRAINT_H__