1 #ifndef __DALI_INTERNAL_CONSTRAINER_H__
2 #define __DALI_INTERNAL_CONSTRAINER_H__
5 * Copyright (c) 2018 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 typedef ObjectContainer::Iterator ObjectIter;
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 virtual ~Constrainer();
53 public: // Object methods
56 * @copydoc Dali::Internal::Object::SetDefaultProperty()
58 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ){}
61 * @copydoc Dali::Internal::Object::GetDefaultProperty()
63 virtual Property::Value GetDefaultProperty( Property::Index index ) const{return Property::Value();}
66 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
68 virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const{return Property::Value();}
71 * @copydoc Dali::Internal::Object::GetSceneObject()
73 virtual const SceneGraph::PropertyOwner* GetSceneObject() const{return 0;}
76 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
78 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const{return 0;}
81 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
83 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const{return 0;}
85 public: // Object::Observer methods
88 * @copydoc Object::Observer::SceneObjectAdded()
90 virtual void SceneObjectAdded( Object& object ){}
93 * @copydoc Object::Observer::SceneObjectRemoved()
95 virtual void SceneObjectRemoved( Object& object ){}
98 * @copydoc Object::Observer::ObjectDestroyed()
100 virtual void ObjectDestroyed( Object& object );
105 * @brief Applies the constraint to the target property
107 * @param[in] target Property to be constrained
108 * @param[in] source Property used as parameter for the path
109 * @param[in] range The range of values in the source property which will be mapped to [0,1]
110 * @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]
112 virtual void Apply( Property target, Property source, const Vector2& range, const Vector2& wrap) = 0;
115 * @brief Removes the constraint in the target object
117 * @param[in] target A handle to an object constrained by the Constrainer
119 void Remove( Dali::Handle& target );
124 * @brief Adds an object to the list of observed objects
126 * @param[in] handle A handle to the object to be observed
128 void Observe( Dali::Handle& handle );
132 ObjectContainer mObservedObjects; ///< The list of object which have been constrained by the Constrainer
135 } // namespace Internal
139 #endif // __DALI_INTERNAL_CONSTRAINER_H__