1 #ifndef __DALI_INTERNAL_GESTURE_DETECTOR_H__
2 #define __DALI_INTERNAL_GESTURE_DETECTOR_H__
5 // Copyright (c) 2014 Samsung Electronics Co., Ltd.
7 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
21 #include <dali/public-api/common/vector-wrapper.h>
22 #include <dali/public-api/common/dali-common.h>
23 #include <dali/public-api/events/gesture.h>
24 #include <dali/public-api/signals/slot-delegate.h>
25 #include <dali/public-api/events/gesture-detector.h>
26 #include <dali/internal/event/actors/actor-impl.h>
39 class GestureDetector;
40 class GestureEventProcessor;
42 typedef IntrusivePtr<GestureDetector> GestureDetectorPtr;
43 typedef std::vector<GestureDetector*> GestureDetectorContainer;
44 typedef std::vector<Actor*> GestureDetectorActorContainer;
47 * This is a type trait that should be used by deriving gesture detectors for their container type.
49 template< typename Detector >
50 struct DerivedGestureDetectorContainer
52 typedef std::vector<Detector*> type;
56 * @copydoc Dali::GestureDetector
58 class GestureDetector : public ProxyObject, public ProxyObject::Observer
63 * @copydoc Dali::GestureDetector::Attach()
65 void Attach(Actor& actor);
68 * @copydoc Dali::GestureDetector::Detach()
70 void Detach(Actor& actor);
73 * @copydoc Dali::GestureDetector::DetachAll()
78 * @copydoc Dali::GestureDetector::GetAttachedActors() const
80 std::vector<Dali::Actor> GetAttachedActors() const;
83 * Returns a const reference to the container of attached actor pointers.
84 * @return A const reference to the attached internal actors.
86 const GestureDetectorActorContainer& GetAttachedActorPointers() const
88 return mAttachedActors;
92 * Retrieves the type of GestureDetector
93 * @return The GestureDetector Type
95 Gesture::Type GetType() const
101 * Checks if the specified actor is still attached.
102 * @param[in] actor The actor to check.
103 * @return true, if the actor is attached, false otherwise.
105 bool IsAttached(Actor& actor) const;
107 protected: // Creation & Destruction
110 * Construct a new GestureDetector.
112 GestureDetector(Gesture::Type mType);
115 * A reference counted object may only be deleted by calling Unreference()
117 virtual ~GestureDetector();
122 GestureDetector(const GestureDetector&);
125 GestureDetector& operator=(const GestureDetector& rhs);
128 * @copydoc Dali::Internal::ProxyObject::Observer::SceneObjectAdded()
130 virtual void SceneObjectAdded(ProxyObject& proxy) {}
133 * @copydoc Dali::Internal::ProxyObject::Observer::SceneObjectAdded()
135 virtual void SceneObjectRemoved(ProxyObject& proxy) {}
138 * @copydoc Dali::Internal::ProxyObject::Observer::ProxyDestroyed()
140 virtual void ProxyDestroyed(ProxyObject& proxy);
143 * For use in derived classes, called after an actor is attached.
144 * @param[in] actor The actor that is being attached.
146 virtual void OnActorAttach(Actor& actor) = 0;
149 * For use in derived classes, called after an actor is detached.
150 * @param[in] actor The actor that is being detached.
152 virtual void OnActorDetach(Actor& actor) = 0;
155 * For use in derived classes, called when an attached actor is destroyed.
156 * @param[in] object The object (Actor's base class) that has been destroyed.
157 * @note Derived classes should not call any Actor specific APIs in this method as the Actor's
158 * destructor would have already been called.
160 virtual void OnActorDestroyed(Object& object) = 0;
162 private: // Default property extensions from ProxyObject
165 * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable()
167 virtual bool IsSceneObjectRemovable() const;
170 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
172 virtual unsigned int GetDefaultPropertyCount() const;
175 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
177 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
180 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
182 virtual const std::string& GetDefaultPropertyName(Property::Index index) const;
185 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
187 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
190 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
192 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
195 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
197 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
200 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
202 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
205 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
207 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
210 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
212 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
215 * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
217 virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
220 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
222 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
225 * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
227 virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
230 * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
232 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
235 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
237 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
240 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
242 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
246 Gesture::Type mType; ///< The gesture detector will detect this type of gesture.
247 GestureDetectorActorContainer mAttachedActors; ///< Proxy<Node>::Observer is used to provide weak-pointer behaviour
248 GestureEventProcessor& mGestureEventProcessor; ///< A reference to the gesture event processor.
251 } // namespace Internal
253 // Helpers for public-api forwarding methods
255 inline Internal::GestureDetector& GetImplementation(Dali::GestureDetector& detector)
257 DALI_ASSERT_ALWAYS( detector && "GestureDetector handle is empty" );
259 BaseObject& handle = detector.GetBaseObject();
261 return static_cast<Internal::GestureDetector&>(handle);
264 inline const Internal::GestureDetector& GetImplementation(const Dali::GestureDetector& detector)
266 DALI_ASSERT_ALWAYS( detector && "GestureDetector handle is empty" );
268 const BaseObject& handle = detector.GetBaseObject();
270 return static_cast<const Internal::GestureDetector&>(handle);
275 #endif // __DALI_INTERNAL_GESTURE_DETECTOR_H__