1 #ifndef DALI_INTERNAL_PAN_GESTURE_DETECTOR_H
2 #define DALI_INTERNAL_PAN_GESTURE_DETECTOR_H
5 * Copyright (c) 2019 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();
66 * @copydoc Dali::PanGestureDetector::SetMinimumTouchesRequired(unsigned int)
68 void SetMinimumTouchesRequired(unsigned int minimum);
71 * @copydoc Dali::PanGestureDetector::SetMaximumTouchesRequired(unsigned int)
73 void SetMaximumTouchesRequired(unsigned int maximum);
76 * @copydoc Dali::PanGestureDetector::GetMinimumTouchesRequired() const
78 uint32_t GetMinimumTouchesRequired() const;
81 * @copydoc Dali::PanGestureDetector::GetMaximumTouchesRequired() const
83 uint32_t GetMaximumTouchesRequired() const;
86 * @copydoc Dali::PanGestureDetector::AddAngle()
88 void AddAngle( Radian angle, Radian threshold );
91 * @copydoc Dali::PanGestureDetector::AddDirection()
93 void AddDirection( Radian direction, Radian threshold );
96 * @copydoc Dali::PanGestureDetector::GetAngleCount()
98 uint32_t GetAngleCount() const;
101 * @copydoc Dali::PanGestureDetector::GetAngle()
103 AngleThresholdPair GetAngle(uint32_t index) 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);
145 * @copydoc Dali::PanGestureDetector::DetectedSignal()
147 Dali::PanGestureDetector::DetectedSignalType& DetectedSignal()
149 return mDetectedSignal;
153 * Connects a callback function with the object's signals.
154 * @param[in] object The object providing the signal.
155 * @param[in] tracker Used to disconnect the signal.
156 * @param[in] signalName The signal to connect to.
157 * @param[in] functor A newly allocated FunctorDelegate.
158 * @return True if the signal was connected.
159 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
161 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
163 public: // Override Pan Gesture
166 * @copydoc Dali::PanGestureDetector::SetPanGestureProperties()
168 static void SetPanGestureProperties( const PanGesture& pan );
173 * Construct a new PanGestureDetector.
174 * @param sceneObject the scene object
176 PanGestureDetector( const SceneGraph::PanGesture& sceneObject );
179 * A reference counted object may only be deleted by calling Unreference()
181 virtual ~PanGestureDetector();
186 PanGestureDetector() = delete;
187 PanGestureDetector(const PanGestureDetector&) = delete;
188 PanGestureDetector& operator=(const PanGestureDetector& rhs) = delete;
191 * @return the pan gesture scene object
193 const SceneGraph::PanGesture& GetPanGestureSceneObject() const;
195 // From GestureDetector
198 * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
200 virtual void OnActorAttach(Actor& actor);
203 * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
205 virtual void OnActorDetach(Actor& actor);
208 * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
210 virtual void OnActorDestroyed(Object& object);
213 // Default property extensions from Object
216 * @copydoc Dali::Internal::Object::SetDefaultProperty()
218 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
221 * @copydoc Dali::Internal::Object::GetDefaultProperty()
223 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
226 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
228 virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
231 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
233 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
237 Dali::PanGestureDetector::DetectedSignalType mDetectedSignal;
239 unsigned int mMinimumTouches; ///< The minimum number of fingers required to be touching for pan.
240 unsigned int mMaximumTouches; ///< The maximum number of fingers required to be touching for pan.
242 AngleContainer mAngleContainer; ///< A container of all angles allowed for pan to occur.
246 } // namespace Internal
248 // Helpers for public-api forwarding methods
250 inline Internal::PanGestureDetector& GetImplementation(Dali::PanGestureDetector& detector)
252 DALI_ASSERT_ALWAYS( detector && "PanGestureDetector handle is empty" );
254 BaseObject& handle = detector.GetBaseObject();
256 return static_cast<Internal::PanGestureDetector&>(handle);
259 inline const Internal::PanGestureDetector& GetImplementation(const Dali::PanGestureDetector& detector)
261 DALI_ASSERT_ALWAYS( detector && "PanGestureDetector handle is empty" );
263 const BaseObject& handle = detector.GetBaseObject();
265 return static_cast<const Internal::PanGestureDetector&>(handle);
270 #endif // DALI_INTERNAL_PAN_GESTURE_DETECTOR_H