1 #ifndef DALI_INTERNAL_PAN_GESTURE_DETECTOR_H
2 #define DALI_INTERNAL_PAN_GESTURE_DETECTOR_H
5 * Copyright (c) 2020 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>
26 #include <dali/public-api/events/pan-gesture.h>
37 class PanGestureDetector;
38 typedef IntrusivePtr<PanGestureDetector> PanGestureDetectorPtr;
39 typedef DerivedGestureDetectorContainer<PanGestureDetector>::type PanGestureDetectorContainer;
47 * @copydoc Dali::PanGestureDetector
49 class PanGestureDetector : public GestureDetector
53 typedef Dali::PanGestureDetector::AngleThresholdPair AngleThresholdPair;
54 typedef std::vector<AngleThresholdPair> AngleContainer;
59 * Create a new gesture detector.
60 * @return A smart-pointer to the newly allocated detector.
62 static PanGestureDetectorPtr New();
67 * @copydoc Dali::PanGestureDetector::SetMinimumTouchesRequired(unsigned int)
69 void SetMinimumTouchesRequired(unsigned int minimum);
72 * @copydoc Dali::PanGestureDetector::SetMaximumTouchesRequired(unsigned int)
74 void SetMaximumTouchesRequired(unsigned int maximum);
77 * @copydoc Dali::PanGestureDetector::GetMinimumTouchesRequired() const
79 uint32_t GetMinimumTouchesRequired() const;
82 * @copydoc Dali::PanGestureDetector::GetMaximumTouchesRequired() const
84 uint32_t GetMaximumTouchesRequired() const;
87 * @copydoc Dali::PanGestureDetector::AddAngle()
89 void AddAngle( Radian angle, Radian threshold );
92 * @copydoc Dali::PanGestureDetector::AddDirection()
94 void AddDirection( Radian direction, Radian threshold );
97 * @copydoc Dali::PanGestureDetector::GetAngleCount()
99 uint32_t GetAngleCount() const;
102 * @copydoc Dali::PanGestureDetector::GetAngle()
104 AngleThresholdPair GetAngle(uint32_t index) const;
107 * @copydoc Dali::PanGestureDetector::ClearAngles()
112 * @copydoc Dali::PanGestureDetector::RemoveAngle()
114 void RemoveAngle( Radian angle );
117 * @copydoc Dali::PanGestureDetector::RemoveDirection()
119 void RemoveDirection( Radian direction );
122 * Checks whether the pan gesture detector requires a directional pan for emission.
123 * @return true, if directional panning required, false otherwise.
125 bool RequiresDirectionalPan() const;
128 * Checks whether the given pan angle is allowed for this gesture detector.
129 * @param[in] angle The angle to check.
131 bool CheckAngleAllowed( Radian angle ) const;
136 * Called by the PanGestureProcessor when a pan gesture event occurs within the bounds of our
138 * @param[in] actor The panned actor.
139 * @param[in] pan The pan gesture.
141 void EmitPanGestureSignal(Dali::Actor actor, const Dali::PanGesture& pan);
146 * @copydoc Dali::PanGestureDetector::DetectedSignal()
148 Dali::PanGestureDetector::DetectedSignalType& DetectedSignal()
150 return mDetectedSignal;
154 * Connects a callback function with the object's signals.
155 * @param[in] object The object providing the signal.
156 * @param[in] tracker Used to disconnect the signal.
157 * @param[in] signalName The signal to connect to.
158 * @param[in] functor A newly allocated FunctorDelegate.
159 * @return True if the signal was connected.
160 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
162 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
164 public: // Override Pan Gesture
167 * @copydoc Dali::PanGestureDetector::SetPanGestureProperties()
169 static void SetPanGestureProperties( const Dali::PanGesture& pan );
174 * Construct a new PanGestureDetector.
175 * @param sceneObject the scene object
177 PanGestureDetector( const SceneGraph::PanGesture& sceneObject );
180 * A reference counted object may only be deleted by calling Unreference()
182 virtual ~PanGestureDetector();
187 PanGestureDetector() = delete;
188 PanGestureDetector(const PanGestureDetector&) = delete;
189 PanGestureDetector& operator=(const PanGestureDetector& rhs) = delete;
192 * @return the pan gesture scene object
194 const SceneGraph::PanGesture& GetPanGestureSceneObject() const;
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::SetDefaultProperty()
219 virtual void SetDefaultProperty(Property::Index index, const Property::Value& propertyValue);
222 * @copydoc Dali::Internal::Object::GetDefaultProperty()
224 virtual Property::Value GetDefaultProperty( Property::Index index ) const;
227 * @copydoc Dali::Internal::Object::GetDefaultPropertyCurrentValue()
229 virtual Property::Value GetDefaultPropertyCurrentValue( Property::Index index ) const;
232 * @copydoc Dali::Internal::Object::GetSceneObjectInputProperty()
234 virtual const PropertyInputImpl* GetSceneObjectInputProperty( Property::Index index ) const;
238 Dali::PanGestureDetector::DetectedSignalType mDetectedSignal;
240 unsigned int mMinimumTouches; ///< The minimum number of fingers required to be touching for pan.
241 unsigned int mMaximumTouches; ///< The maximum number of fingers required to be touching for pan.
243 AngleContainer mAngleContainer; ///< A container of all angles allowed for pan to occur.
247 } // namespace Internal
249 // Helpers for public-api forwarding methods
251 inline Internal::PanGestureDetector& GetImplementation(Dali::PanGestureDetector& detector)
253 DALI_ASSERT_ALWAYS( detector && "PanGestureDetector handle is empty" );
255 BaseObject& handle = detector.GetBaseObject();
257 return static_cast<Internal::PanGestureDetector&>(handle);
260 inline const Internal::PanGestureDetector& GetImplementation(const Dali::PanGestureDetector& detector)
262 DALI_ASSERT_ALWAYS( detector && "PanGestureDetector handle is empty" );
264 const BaseObject& handle = detector.GetBaseObject();
266 return static_cast<const Internal::PanGestureDetector&>(handle);
271 #endif // DALI_INTERNAL_PAN_GESTURE_DETECTOR_H