1 #ifndef __DALI_INTERNAL_CONSTRAINER_H__
2 #define __DALI_INTERNAL_CONSTRAINER_H__
5 * Copyright (c) 2015 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::GetDefaultPropertyCount()
58 virtual unsigned int GetDefaultPropertyCount() const{return 0;}
61 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
63 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const{}
66 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
68 virtual const char* GetDefaultPropertyName( Property::Index index ) const{return 0;}
71 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
73 virtual Property::Index GetDefaultPropertyIndex( const std::string& name ) const{return Property::INVALID_INDEX;}
76 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
78 virtual bool IsDefaultPropertyWritable( Property::Index index ) const{return false;}
81 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
83 virtual bool IsDefaultPropertyAnimatable( Property::Index index ) const{return false;}
86 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
88 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const{return false;}
91 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
93 virtual Property::Type GetDefaultPropertyType( Property::Index index ) const{return Property::NONE;}
96 * @copydoc Dali::Internal::Object::SetDefaultProperty()
98 virtual void SetDefaultProperty( Property::Index index, const Property::Value& propertyValue ){}
101 * @copydoc Dali::Internal::Object::GetDefaultProperty()
103 virtual Property::Value GetDefaultProperty( Property::Index index ) const{return Property::Value();}
106 * @copydoc Dali::Internal::Object::GetSceneObject()
108 virtual const SceneGraph::PropertyOwner* GetSceneObject() const{return 0;}
111 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
113 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const{return 0;}
116 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
118 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const{return 0;}
120 public: // Object::Observer methods
123 * @copydoc Object::Observer::SceneObjectAdded()
125 virtual void SceneObjectAdded( Object& object ){}
128 * @copydoc Object::Observer::SceneObjectRemoved()
130 virtual void SceneObjectRemoved( Object& object ){}
133 * @copydoc Object::Observer::ObjectDestroyed()
135 virtual void ObjectDestroyed( Object& object );
140 * @brief Applies the constraint to the target property
142 * @param[in] target Property to be constrained
143 * @param[in] source Property used as parameter for the path
144 * @param[in] range The range of values in the source property which will be mapped to [0,1]
145 * @param[in] wrap Wrapping domain. Source property will be wrapped in the domain [wrap.x,wrap.y] before mapping to [0,1]
147 virtual void Apply( Property target, Property source, const Vector2& range, const Vector2& wrap) = 0;
150 * @brief Removes the constraint in the target object
152 * @param[in] target A handle to an object constrained by the Constrainer
154 void Remove( Dali::Handle& target );
159 * @brief Adds an object to the list of observed objects
161 * @param[in] handle A handle to the object to be observed
163 void Observe( Dali::Handle& handle );
167 ObjectContainer mObservedObjects; ///< The list of object which have been constrained by the Constrainer
170 } // namespace Internal
174 #endif // __DALI_INTERNAL_CONSTRAINER_H__