1 #ifndef __DALI_INTERNAL_GESTURE_DETECTOR_H__
2 #define __DALI_INTERNAL_GESTURE_DETECTOR_H__
5 * Copyright (c) 2017 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 Object, public Object::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::GetAttachedActorCount() const
81 size_t GetAttachedActorCount() const;
84 * @copydoc Dali::GestureDetector::GetAttachedActor() const
86 Dali::Actor GetAttachedActor(size_t index) const;
89 * Returns a const reference to the container of attached actor pointers.
90 * @return A const reference to the attached internal actors.
92 const GestureDetectorActorContainer& GetAttachedActorPointers() const
94 return mAttachedActors;
98 * Retrieves the type of GestureDetector
99 * @return The GestureDetector Type
101 Gesture::Type GetType() const
107 * Checks if the specified actor is still attached.
108 * @param[in] actor The actor to check.
109 * @return true, if the actor is attached, false otherwise.
111 bool IsAttached(Actor& actor) const;
113 protected: // Creation & Destruction
116 * Construct a new GestureDetector.
118 GestureDetector(Gesture::Type mType);
121 * A reference counted object may only be deleted by calling Unreference()
123 virtual ~GestureDetector();
128 GestureDetector(const GestureDetector&);
131 GestureDetector& operator=(const GestureDetector& rhs);
134 * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded()
136 virtual void SceneObjectAdded(Object& object) {}
139 * @copydoc Dali::Internal::Object::Observer::SceneObjectAdded()
141 virtual void SceneObjectRemoved(Object& object) {}
144 * @copydoc Dali::Internal::Object::Observer::ObjectDestroyed()
146 virtual void ObjectDestroyed(Object& object);
149 * For use in derived classes, called after an actor is attached.
150 * @param[in] actor The actor that is being attached.
152 virtual void OnActorAttach(Actor& actor) = 0;
155 * For use in derived classes, called after an actor is detached.
156 * @param[in] actor The actor that is being detached.
158 virtual void OnActorDetach(Actor& actor) = 0;
161 * For use in derived classes, called when an attached actor is destroyed.
162 * @param[in] object The object (Actor's base class) that has been destroyed.
163 * @note Derived classes should not call any Actor specific APIs in this method as the Actor's
164 * destructor would have already been called.
166 virtual void OnActorDestroyed(Object& object) = 0;
168 private: // Default property extensions from Object
171 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
173 virtual unsigned int GetDefaultPropertyCount() const;
176 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
178 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
181 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
183 virtual const char* GetDefaultPropertyName(Property::Index index) const;
186 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
188 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
191 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
193 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
196 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
198 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
201 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
203 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
206 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
208 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
211 * @copydoc Dali::Internal::Object::SetDefaultProperty()
213 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
216 * @copydoc Dali::Internal::Object::GetDefaultProperty()
218 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
221 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
223 virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
226 * @copydoc Dali::Internal::Object::GetSceneObject()
228 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
231 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
233 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
236 * @copydoc Dali::Internal::Object::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; ///< Object::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__