Merge branch 'devel/master' into tizen
[platform/core/uifw/dali-core.git] / dali / public-api / animation / constraint-source.h
1 #ifndef DALI_CONSTRAINT_SOURCE_H
2 #define DALI_CONSTRAINT_SOURCE_H
3
4 /*
5  * Copyright (c) 2020 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/object/handle.h>
23 #include <dali/public-api/object/property.h>
24
25 namespace Dali
26 {
27 /**
28  * @addtogroup dali_core_animation
29  * @{
30  */
31
32 /**
33  * @brief Enumeration for constraint source types.
34  *
35  * This specifies the location of a property, which is used as an input for a constraint function.
36  * @SINCE_1_0.0
37  */
38 enum SourceType
39 {
40   OBJECT_PROPERTY, ///< The property comes from an arbitrary object. @SINCE_1_0.0
41   LOCAL_PROPERTY,  ///< The property comes from the object which the constraint is applied to. @SINCE_1_0.0
42   PARENT_PROPERTY  ///< The property comes from the parent of the object, which the constraint is applied to. @SINCE_1_0.0
43 };
44
45 /**
46  * @brief Identifies a property from an object.
47  * @SINCE_1_0.0
48  */
49 struct DALI_CORE_API LocalSource
50 {
51   /**
52    * @brief Creates a local constraint source.
53    *
54    * @SINCE_1_0.0
55    * @param[in] index The index of a property provided by the constrained object
56    */
57   LocalSource(Property::Index index);
58
59   Property::Index propertyIndex; ///< The index of a property provided by the constrained object.
60 };
61
62 /**
63  * @brief Identifies a property from the parent of an object.
64  * @SINCE_1_0.0
65  */
66 struct DALI_CORE_API ParentSource
67 {
68   /**
69    * @brief Creates a parent constraint source.
70    *
71    * @SINCE_1_0.0
72    * @param[in] index The index of a property, provided by the parent of the constrained object
73    */
74   ParentSource(Property::Index index);
75
76   Property::Index propertyIndex; ///< The index of a property provided by the parent of the constrained object.
77 };
78
79 /**
80  * @brief Identifies a property from any object.
81  * @SINCE_1_0.0
82  */
83 struct DALI_CORE_API Source
84 {
85   /**
86    * @brief Creates a constraint source.
87    *
88    * @SINCE_1_0.0
89    * @param[in] object The object providing the property
90    * @param[in] index The index of a property provided by object
91    */
92   Source(Handle& object, Property::Index index);
93
94   Property::Index propertyIndex; ///< The index of a property provided by object.
95
96   Handle object; ///< The target object
97 };
98
99 /**
100  * @brief The source of an input property for a constraint.
101  * @SINCE_1_0.0
102  */
103 struct DALI_CORE_API ConstraintSource
104 {
105   /**
106    * @brief Creates a constraint source.
107    *
108    * @SINCE_1_0.0
109    * @param[in] source A constraint source from an arbitrary object
110    */
111   ConstraintSource(Source source);
112
113   /**
114    * @brief Creates a constraint source.
115    *
116    * @SINCE_1_0.0
117    * @param[in] local A local constraint source
118    */
119   ConstraintSource(LocalSource local);
120
121   /**
122    * @brief Creates a constraint source.
123    *
124    * @SINCE_1_0.0
125    * @param[in] parent A parent constraint source
126    */
127   ConstraintSource(ParentSource parent);
128
129   SourceType sourceType; ///< The source type
130
131   Property::Index propertyIndex; ///< The index of the source property
132
133   Handle object; ///< The target object; only valid if sourceType == OBJECT_PROPERTY
134 };
135
136 /**
137  * @}
138  */
139 } // namespace Dali
140
141 #endif // DALI_CONSTRAINT_SOURCE_H