[dali_2.3.26] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / event / animation / constraint-source-impl.h
1 #ifndef DALI_INTERNAL_CONSTRAINT_SOURCE_H
2 #define DALI_INTERNAL_CONSTRAINT_SOURCE_H
3
4 /*
5  * Copyright (c) 2021 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/internal/event/common/object-impl.h>
23 #include <dali/public-api/animation/constraint-source.h>
24 #include <dali/public-api/common/vector-wrapper.h>
25
26 namespace Dali
27 {
28 namespace Internal
29 {
30 struct Source;
31 using SourceContainer = std::vector<Source>;
32 using SourceIter      = SourceContainer::iterator;
33
34 /**
35  * The source of an input property for a constraint.
36  */
37 struct Source
38 {
39   /**
40    * Default constructor
41    */
42   Source()
43   : sourceType(OBJECT_PROPERTY),
44     propertyIndex(Property::INVALID_INDEX),
45     object(nullptr)
46   {
47   }
48
49   /**
50    * Create a constraint source from a public handle.
51    * The internal object is not referenced by the Internal::Source; therefore
52    * the owner of this object is responsible for observing the Object's lifetime.
53    */
54   Source(Dali::ConstraintSource& source)
55   : sourceType(source.sourceType),
56     propertyIndex(source.propertyIndex),
57     object(nullptr)
58   {
59     if(source.object)
60     {
61       object = &dynamic_cast<Object&>(GetImplementation(source.object));
62     }
63   }
64
65   SourceType sourceType; ///< The source type
66
67   Property::Index propertyIndex; ///< The index of the source property
68
69   Object* object; ///< The target object; only valid if sourceType == OBJECT_PROPERTY
70 };
71
72 } // namespace Internal
73
74 } // namespace Dali
75
76 #endif // DALI_INTERNAL_CONSTRAINT_SOURCE_H