1 #ifndef __DALI_INTERNAL_PAN_GESTURE_DETECTOR_H__
2 #define __DALI_INTERNAL_PAN_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/events/gesture.h>
23 #include <dali/public-api/events/pan-gesture-detector.h>
24 #include <dali/public-api/math/vector2.h>
25 #include <dali/internal/event/events/gesture-detector-impl.h>
36 class PanGestureDetector;
37 typedef IntrusivePtr<PanGestureDetector> PanGestureDetectorPtr;
38 typedef DerivedGestureDetectorContainer<PanGestureDetector>::type PanGestureDetectorContainer;
46 * @copydoc Dali::PanGestureDetector
48 class PanGestureDetector : public GestureDetector
52 typedef Dali::PanGestureDetector::AngleContainer AngleContainer;
53 typedef Dali::PanGestureDetector::AngleThresholdPair AngleThresholdPair;
58 * Create a new gesture detector.
59 * @return A smart-pointer to the newly allocated detector.
61 static PanGestureDetectorPtr New();
64 * Construct a new PanGestureDetector.
71 * @copydoc Dali::PanGestureDetector::SetMinimumTouchesRequired(unsigned int)
73 void SetMinimumTouchesRequired(unsigned int minimum);
76 * @copydoc Dali::PanGestureDetector::SetMaximumTouchesRequired(unsigned int)
78 void SetMaximumTouchesRequired(unsigned int maximum);
81 * @copydoc Dali::PanGestureDetector::GetMinimumTouchesRequired() const
83 unsigned int GetMinimumTouchesRequired() const;
86 * @copydoc Dali::PanGestureDetector::GetMaximumTouchesRequired() const
88 unsigned int GetMaximumTouchesRequired() const;
91 * @copydoc Dali::PanGestureDetector::AddAngle()
93 void AddAngle( Radian angle, Radian threshold );
96 * @copydoc Dali::PanGestureDetector::AddDirection()
98 void AddDirection( Radian direction, Radian threshold );
101 * @copydoc Dali::PanGestureDetector::GetAngles()
103 const AngleContainer& GetAngles() const;
106 * @copydoc Dali::PanGestureDetector::ClearAngles()
111 * @copydoc Dali::PanGestureDetector::RemoveAngle()
113 void RemoveAngle( Radian angle );
116 * @copydoc Dali::PanGestureDetector::RemoveDirection()
118 void RemoveDirection( Radian direction );
121 * Checks whether the pan gesture detector requires a directional pan for emission.
122 * @return true, if directional panning required, false otherwise.
124 bool RequiresDirectionalPan() const;
127 * Checks whether the given pan angle is allowed for this gesture detector.
128 * @param[in] angle The angle to check.
130 bool CheckAngleAllowed( Radian angle ) const;
135 * Called by the PanGestureProcessor when a pan gesture event occurs within the bounds of our
137 * @param[in] actor The panned actor.
138 * @param[in] pan The pan gesture.
140 void EmitPanGestureSignal(Dali::Actor actor, const PanGesture& pan);
143 * Called by the PanGestureProcessor to set the scene object.
144 * @param[in] object The scene object.
146 void SetSceneObject( const SceneGraph::PanGesture* object );
151 * @copydoc Dali::PanGestureDetector::DetectedSignal()
153 Dali::PanGestureDetector::DetectedSignalV2& DetectedSignal()
155 return mDetectedSignalV2;
159 * Connects a callback function with the object's signals.
160 * @param[in] object The object providing the signal.
161 * @param[in] tracker Used to disconnect the signal.
162 * @param[in] signalName The signal to connect to.
163 * @param[in] functor A newly allocated FunctorDelegate.
164 * @return True if the signal was connected.
165 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
167 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
169 public: // Override Pan Gesture
172 * @copydoc Dali::PanGestureDetector::SetPanGestureProperties()
174 static void SetPanGestureProperties( const PanGesture& pan );
179 * A reference counted object may only be deleted by calling Unreference()
181 virtual ~PanGestureDetector();
186 PanGestureDetector(const PanGestureDetector&);
189 PanGestureDetector& operator=(const PanGestureDetector& rhs);
191 // From GestureDetector
194 * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
196 virtual void OnActorAttach(Actor& actor);
199 * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
201 virtual void OnActorDetach(Actor& actor);
204 * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
206 virtual void OnActorDestroyed(Object& object);
209 // Default property extensions from ProxyObject
212 * @copydoc Dali::Internal::ProxyObject::IsSceneObjectRemovable()
214 virtual bool IsSceneObjectRemovable() const;
217 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyCount()
219 virtual unsigned int GetDefaultPropertyCount() const;
222 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndices()
224 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
227 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyName()
229 virtual const char* GetDefaultPropertyName(Property::Index index) const;
232 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyIndex()
234 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
237 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyWritable()
239 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
242 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAnimatable()
244 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
247 * @copydoc Dali::Internal::ProxyObject::IsDefaultPropertyAConstraintInput()
249 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
252 * @copydoc Dali::Internal::ProxyObject::GetDefaultPropertyType()
254 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
257 * @copydoc Dali::Internal::ProxyObject::SetDefaultProperty()
259 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
262 * @copydoc Dali::Internal::ProxyObject::SetCustomProperty()
264 virtual void SetCustomProperty( Property::Index index, const CustomProperty& entry, const Property::Value& value );
267 * @copydoc Dali::Internal::ProxyObject::GetDefaultProperty()
269 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
272 * @copydoc Dali::Internal::ProxyObject::InstallSceneObjectProperty()
274 virtual void InstallSceneObjectProperty( SceneGraph::PropertyBase& newProperty, const std::string& name, unsigned int index );
277 * @copydoc Dali::Internal::ProxyObject::GetSceneObject()
279 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
282 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectAnimatableProperty()
284 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
287 * @copydoc Dali::Internal::ProxyObject::GetSceneObjectInputProperty()
289 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
293 Dali::PanGestureDetector::DetectedSignalV2 mDetectedSignalV2;
295 unsigned int mMinimumTouches; ///< The minimum number of fingers required to be touching for pan.
296 unsigned int mMaximumTouches; ///< The maximum number of fingers required to be touching for pan.
298 AngleContainer mAngleContainer; ///< A container of all angles allowed for pan to occur.
300 const SceneGraph::PanGesture* mSceneObject; ///< Not owned
304 } // namespace Internal
306 // Helpers for public-api forwarding methods
308 inline Internal::PanGestureDetector& GetImplementation(Dali::PanGestureDetector& detector)
310 DALI_ASSERT_ALWAYS( detector && "PanGestureDetector handle is empty" );
312 BaseObject& handle = detector.GetBaseObject();
314 return static_cast<Internal::PanGestureDetector&>(handle);
317 inline const Internal::PanGestureDetector& GetImplementation(const Dali::PanGestureDetector& detector)
319 DALI_ASSERT_ALWAYS( detector && "PanGestureDetector handle is empty" );
321 const BaseObject& handle = detector.GetBaseObject();
323 return static_cast<const Internal::PanGestureDetector&>(handle);
328 #endif // __DALI_INTERNAL_PAN_GESTURE_DETECTOR_H__