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 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/public-api/common/vector-wrapper.h>
23 #include <dali/public-api/common/dali-common.h>
24 #include <dali/public-api/events/gesture.h>
25 #include <dali/public-api/signals/slot-delegate.h>
26 #include <dali/public-api/events/gesture-detector.h>
27 #include <dali/internal/event/actors/actor-impl.h>
40 class GestureDetector;
41 class GestureEventProcessor;
43 typedef IntrusivePtr<GestureDetector> GestureDetectorPtr;
44 typedef std::vector<GestureDetector*> GestureDetectorContainer;
45 typedef std::vector<Actor*> GestureDetectorActorContainer;
48 * This is a type trait that should be used by deriving gesture detectors for their container type.
50 template< typename Detector >
51 struct DerivedGestureDetectorContainer
53 typedef std::vector<Detector*> type;
57 * @copydoc Dali::GestureDetector
59 class GestureDetector : public ProxyObject, public ProxyObject::Observer
64 * @copydoc Dali::GestureDetector::Attach()
66 void Attach(Actor& actor);
69 * @copydoc Dali::GestureDetector::Detach()
71 void Detach(Actor& actor);
74 * @copydoc Dali::GestureDetector::DetachAll()
79 * @copydoc Dali::GestureDetector::GetAttachedActors() const
81 std::vector<Dali::Actor> GetAttachedActors() const;
84 * Returns a const reference to the container of attached actor pointers.
85 * @return A const reference to the attached internal actors.
87 const GestureDetectorActorContainer& GetAttachedActorPointers() const
89 return mAttachedActors;
93 * Retrieves the type of GestureDetector
94 * @return The GestureDetector Type
96 Gesture::Type GetType() const
102 * Checks if the specified actor is still attached.
103 * @param[in] actor The actor to check.
104 * @return true, if the actor is attached, false otherwise.
106 bool IsAttached(Actor& actor) const;
108 protected: // Creation & Destruction
111 * Construct a new GestureDetector.
113 GestureDetector(Gesture::Type mType);
116 * A reference counted object may only be deleted by calling Unreference()
118 virtual ~GestureDetector();
123 GestureDetector(const GestureDetector&);
126 GestureDetector& operator=(const GestureDetector& rhs);
129 * @copydoc Dali::Internal::ProxyObject::Observer::SceneObjectAdded()
131 virtual void SceneObjectAdded(ProxyObject& proxy) {}
134 * @copydoc Dali::Internal::ProxyObject::Observer::SceneObjectAdded()
136 virtual void SceneObjectRemoved(ProxyObject& proxy) {}
139 * @copydoc Dali::Internal::ProxyObject::Observer::ProxyDestroyed()
141 virtual void ProxyDestroyed(ProxyObject& proxy);
144 * For use in derived classes, called after an actor is attached.
145 * @param[in] actor The actor that is being attached.
147 virtual void OnActorAttach(Actor& actor) = 0;
150 * For use in derived classes, called after an actor is detached.
151 * @param[in] actor The actor that is being detached.
153 virtual void OnActorDetach(Actor& actor) = 0;
156 * For use in derived classes, called when an attached actor is destroyed.
157 * @param[in] object The object (Actor's base class) that has been destroyed.
158 * @note Derived classes should not call any Actor specific APIs in this method as the Actor's
159 * destructor would have already been called.
161 virtual void OnActorDestroyed(Object& object) = 0;
163 private: // Default property extensions from ProxyObject
166 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
168 virtual unsigned int GetDefaultPropertyCount() const;
171 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
173 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
176 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
178 virtual const char* GetDefaultPropertyName(Property::Index index) const;
181 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
183 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
186 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
188 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
191 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
193 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
196 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
198 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
201 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
203 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
206 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
208 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
211 * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
213 virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
216 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
218 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
221 * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
223 virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
226 * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
228 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
231 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
233 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
236 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
238 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
242 Gesture::Type mType; ///< The gesture detector will detect this type of gesture.
243 GestureDetectorActorContainer mAttachedActors; ///< Proxy<Node>::Observer is used to provide weak-pointer behaviour
244 GestureEventProcessor& mGestureEventProcessor; ///< A reference to the gesture event processor.
247 } // namespace Internal
249 // Helpers for public-api forwarding methods
251 inline Internal::GestureDetector& GetImplementation(Dali::GestureDetector& detector)
253 DALI_ASSERT_ALWAYS( detector && "GestureDetector handle is empty" );
255 BaseObject& handle = detector.GetBaseObject();
257 return static_cast<Internal::GestureDetector&>(handle);
260 inline const Internal::GestureDetector& GetImplementation(const Dali::GestureDetector& detector)
262 DALI_ASSERT_ALWAYS( detector && "GestureDetector handle is empty" );
264 const BaseObject& handle = detector.GetBaseObject();
266 return static_cast<const Internal::GestureDetector&>(handle);
271 #endif // __DALI_INTERNAL_GESTURE_DETECTOR_H__