1 #ifndef DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_IMPL_H
2 #define DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_IMPL_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/long-press-gesture-detector.h>
23 #include <dali/internal/event/events/gesture-detector-impl.h>
31 class LongPressGestureDetector;
33 typedef IntrusivePtr<LongPressGestureDetector> LongPressGestureDetectorPtr;
34 typedef DerivedGestureDetectorContainer<LongPressGestureDetector>::type LongPressGestureDetectorContainer;
37 * @copydoc Dali::LongPressGestureDetector
39 class LongPressGestureDetector : public GestureDetector
44 * Create a new gesture detector.
45 * @return A smart-pointer to the newly allocated detector.
47 static LongPressGestureDetectorPtr New();
50 * Create a new gesture detector with the specified touches.
51 * @param[in] touchesRequired The number of touches required.
52 * @return A smart-pointer to the newly allocated detector.
54 static LongPressGestureDetectorPtr New(unsigned int touchesRequired);
57 * Create a new gesture detector with the specified minimum and maximum touches.
58 * @param[in] minTouches The minimum number of touches required.
59 * @param[in] maxTouches The maximum number of touches required.
60 * @return A smart-pointer to the newly allocated detector.
62 static LongPressGestureDetectorPtr New(unsigned int minTouches, unsigned int maxTouches);
65 * Construct a new GestureDetector.
67 LongPressGestureDetector();
70 * Create a new gesture detector with the specified minimum and maximum touches.
71 * @param[in] minTouches The minimum number of touches required.
72 * @param[in] maxTouches The maximum number of touches required.
74 LongPressGestureDetector(unsigned int minTouches, unsigned int maxTouches);
79 * @copydoc Dali::LongPressGestureDetector::SetTouchesRequired(unsigned int)
81 void SetTouchesRequired(unsigned int touches);
84 * @copydoc Dali::LongPressGestureDetector::SetTouchesRequired(unsigned int, unsigned int)
86 void SetTouchesRequired(unsigned int minTouches, unsigned int maxTouches);
89 * @copydoc Dali::LongPressGestureDetector::GetMinimumTouchesRequired()
91 unsigned int GetMinimumTouchesRequired() const;
94 * @copydoc Dali::LongPressGestureDetector::GetMaximumTouchesRequired()
96 unsigned int GetMaximumTouchesRequired() const;
99 * @return The minimum holding time required to be recognized as a long press gesture in milliseconds
101 uint32_t GetMinimumHoldingTime() const;
106 * Called by the LongPressGestureProcessor when a tap gesture event occurs within the bounds of our
108 * @param[in] pressedActor The pressed actor.
109 * @param[in] longPress The long press
111 void EmitLongPressGestureSignal(Dali::Actor pressedActor, const Dali::LongPressGesture& longPress);
116 * @copydoc Dali::LongPressGestureDetector::DetectedSignal()
118 Dali::LongPressGestureDetector::DetectedSignalType& DetectedSignal()
120 return mDetectedSignal;
124 * Connects a callback function with the object's signals.
125 * @param[in] object The object providing the signal.
126 * @param[in] tracker Used to disconnect the signal.
127 * @param[in] signalName The signal to connect to.
128 * @param[in] functor A newly allocated FunctorDelegate.
129 * @return True if the signal was connected.
130 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
132 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
137 * A reference counted object may only be deleted by calling Unreference()
139 virtual ~LongPressGestureDetector();
144 LongPressGestureDetector(const LongPressGestureDetector&);
145 LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs);
147 private: // GestureDetector overrides
150 * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
152 virtual void OnActorAttach(Actor& actor);
155 * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
157 virtual void OnActorDetach(Actor& actor);
160 * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
162 virtual void OnActorDestroyed(Object& object);
166 Dali::LongPressGestureDetector::DetectedSignalType mDetectedSignal;
168 unsigned int mMinimumTouchesRequired;
169 unsigned int mMaximumTouchesRequired;
172 } // namespace Internal
174 // Helpers for public-api forwarding methods
176 inline Internal::LongPressGestureDetector& GetImplementation(Dali::LongPressGestureDetector& detector)
178 DALI_ASSERT_ALWAYS( detector && "LongPressGestureDetector handle is empty" );
180 BaseObject& handle = detector.GetBaseObject();
182 return static_cast<Internal::LongPressGestureDetector&>(handle);
185 inline const Internal::LongPressGestureDetector& GetImplementation(const Dali::LongPressGestureDetector& detector)
187 DALI_ASSERT_ALWAYS( detector && "LongPressGestureDetector handle is empty" );
189 const BaseObject& handle = detector.GetBaseObject();
191 return static_cast<const Internal::LongPressGestureDetector&>(handle);
196 #endif // DALI_INTERNAL_LONG_PRESS_GESTURE_DETECTOR_IMPL_H