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::AngleThresholdPair AngleThresholdPair;
53 typedef std::vector<AngleThresholdPair> AngleContainer;
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::GetAngleCount()
103 size_t GetAngleCount() const;
106 * @copydoc Dali::PanGestureDetector::GetAngle()
108 AngleThresholdPair GetAngle(size_t index) const;
111 * @copydoc Dali::PanGestureDetector::ClearAngles()
116 * @copydoc Dali::PanGestureDetector::RemoveAngle()
118 void RemoveAngle( Radian angle );
121 * @copydoc Dali::PanGestureDetector::RemoveDirection()
123 void RemoveDirection( Radian direction );
126 * Checks whether the pan gesture detector requires a directional pan for emission.
127 * @return true, if directional panning required, false otherwise.
129 bool RequiresDirectionalPan() const;
132 * Checks whether the given pan angle is allowed for this gesture detector.
133 * @param[in] angle The angle to check.
135 bool CheckAngleAllowed( Radian angle ) const;
140 * Called by the PanGestureProcessor when a pan gesture event occurs within the bounds of our
142 * @param[in] actor The panned actor.
143 * @param[in] pan The pan gesture.
145 void EmitPanGestureSignal(Dali::Actor actor, const PanGesture& pan);
148 * Called by the PanGestureProcessor to set the scene object.
149 * @param[in] object The scene object.
151 void SetSceneObject( const SceneGraph::PanGesture* object );
156 * @copydoc Dali::PanGestureDetector::DetectedSignal()
158 Dali::PanGestureDetector::DetectedSignalType& DetectedSignal()
160 return mDetectedSignal;
164 * Connects a callback function with the object's signals.
165 * @param[in] object The object providing the signal.
166 * @param[in] tracker Used to disconnect the signal.
167 * @param[in] signalName The signal to connect to.
168 * @param[in] functor A newly allocated FunctorDelegate.
169 * @return True if the signal was connected.
170 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
172 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
174 public: // Override Pan Gesture
177 * @copydoc Dali::PanGestureDetector::SetPanGestureProperties()
179 static void SetPanGestureProperties( const PanGesture& pan );
184 * A reference counted object may only be deleted by calling Unreference()
186 virtual ~PanGestureDetector();
191 PanGestureDetector(const PanGestureDetector&);
194 PanGestureDetector& operator=(const PanGestureDetector& rhs);
196 // From GestureDetector
199 * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
201 virtual void OnActorAttach(Actor& actor);
204 * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
206 virtual void OnActorDetach(Actor& actor);
209 * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
211 virtual void OnActorDestroyed(Object& object);
214 // Default property extensions from Object
217 * @copydoc Dali::Internal::Object::GetDefaultPropertyCount()
219 virtual unsigned int GetDefaultPropertyCount() const;
222 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndices()
224 virtual void GetDefaultPropertyIndices( Property::IndexContainer& indices ) const;
227 * @copydoc Dali::Internal::Object::GetDefaultPropertyName()
229 virtual const char* GetDefaultPropertyName(Property::Index index) const;
232 * @copydoc Dali::Internal::Object::GetDefaultPropertyIndex()
234 virtual Property::Index GetDefaultPropertyIndex(const std::string& name) const;
237 * @copydoc Dali::Internal::Object::IsDefaultPropertyWritable()
239 virtual bool IsDefaultPropertyWritable(Property::Index index) const;
242 * @copydoc Dali::Internal::Object::IsDefaultPropertyAnimatable()
244 virtual bool IsDefaultPropertyAnimatable(Property::Index index) const;
247 * @copydoc Dali::Internal::Object::IsDefaultPropertyAConstraintInput()
249 virtual bool IsDefaultPropertyAConstraintInput( Property::Index index ) const;
252 * @copydoc Dali::Internal::Object::GetDefaultPropertyType()
254 virtual Property::Type GetDefaultPropertyType(Property::Index index) const;
257 * @copydoc Dali::Internal::Object::SetDefaultProperty()
259 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
262 * @copydoc Dali::Internal::Object::GetDefaultProperty()
264 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
267 * @copydoc Dali::Internal::Object::GetSceneObject()
269 virtual const SceneGraph::PropertyOwner* GetSceneObject() const;
272 * @copydoc Dali::Internal::Object::GetSceneObjectAnimatableProperty()
274 virtual const SceneGraph::PropertyBase* GetSceneObjectAnimatableProperty( Property::Index index ) const;
277 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
279 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
283 Dali::PanGestureDetector::DetectedSignalType mDetectedSignal;
285 unsigned int mMinimumTouches; ///< The minimum number of fingers required to be touching for pan.
286 unsigned int mMaximumTouches; ///< The maximum number of fingers required to be touching for pan.
288 AngleContainer mAngleContainer; ///< A container of all angles allowed for pan to occur.
290 const SceneGraph::PanGesture* mSceneObject; ///< Not owned
294 } // namespace Internal
296 // Helpers for public-api forwarding methods
298 inline Internal::PanGestureDetector& GetImplementation(Dali::PanGestureDetector& detector)
300 DALI_ASSERT_ALWAYS( detector && "PanGestureDetector handle is empty" );
302 BaseObject& handle = detector.GetBaseObject();
304 return static_cast<Internal::PanGestureDetector&>(handle);
307 inline const Internal::PanGestureDetector& GetImplementation(const Dali::PanGestureDetector& detector)
309 DALI_ASSERT_ALWAYS( detector && "PanGestureDetector handle is empty" );
311 const BaseObject& handle = detector.GetBaseObject();
313 return static_cast<const Internal::PanGestureDetector&>(handle);
318 #endif // __DALI_INTERNAL_PAN_GESTURE_DETECTOR_H__