1 #ifndef DALI_INTERNAL_CONSTRAINER_H
2 #define DALI_INTERNAL_CONSTRAINER_H
5 * Copyright (c) 2019 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/internal/event/common/object-impl.h>
23 #include <dali/public-api/common/dali-vector.h>
31 typedef Dali::Vector<Object*> ObjectContainer;
32 using ObjectIter = ObjectContainer::Iterator;
35 * An abstract base class for constrainers.
36 * Constrainer base class is responsible or observing constrained objects and remove all the constraints created
37 * when it is destroyed
39 class Constrainer : public Object, public Object::Observer
51 ~Constrainer() override;
53 public: // Object::Observer methods
56 * @copydoc Object::Observer::SceneObjectAdded()
58 void SceneObjectAdded( Object& object ) override{}
61 * @copydoc Object::Observer::SceneObjectRemoved()
63 void SceneObjectRemoved( Object& object ) override{}
66 * @copydoc Object::Observer::ObjectDestroyed()
68 void ObjectDestroyed( Object& object ) override;
73 * @brief Applies the constraint to the target property
75 * @param[in] target Property to be constrained
76 * @param[in] source Property used as parameter for the path
77 * @param[in] range The range of values in the source property which will be mapped to [0,1]
78 * @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]
80 virtual void Apply( Property target, Property source, const Vector2& range, const Vector2& wrap) = 0;
83 * @brief Removes the constraint in the target object
85 * @param[in] target A handle to an object constrained by the Constrainer
87 void Remove( Dali::Handle& target );
92 * @brief Adds an object to the list of observed objects
94 * @param[in] handle A handle to the object to be observed
96 void Observe( Dali::Handle& handle );
100 ObjectContainer mObservedObjects; ///< The list of object which have been constrained by the Constrainer
103 } // namespace Internal
107 #endif // DALI_INTERNAL_CONSTRAINER_H