1 #ifndef DALI_INTERNAL_TAP_GESTURE_DETECTOR_H
2 #define DALI_INTERNAL_TAP_GESTURE_DETECTOR_H
5 * Copyright (c) 2021 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/internal/event/events/gesture-detector-impl.h>
23 #include <dali/public-api/events/tap-gesture-detector.h>
24 #include <dali/public-api/events/tap-gesture.h>
30 class TapGestureDetector;
32 using TapGestureDetectorPtr = IntrusivePtr<TapGestureDetector>;
33 using TapGestureDetectorContainer = DerivedGestureDetectorContainer<TapGestureDetector>::type;
36 * @copydoc Dali::TapGestureDetector
38 class TapGestureDetector : public GestureDetector
42 * Create a new gesture detector.
43 * @return A smart-pointer to the newly allocated detector.
45 static TapGestureDetectorPtr New();
48 * Create a new gesture detector with the specified parameters.
49 * @param[in] tapsRequired The number of taps required.
50 * @return A smart-pointer to the newly allocated detector.
52 static TapGestureDetectorPtr New(unsigned int tapsRequired);
55 * Construct a new GestureDetector.
60 * Construct a new GestureDetector with the specified parameters.
61 * @param[in] tapsRequired The number of taps required.
63 TapGestureDetector(unsigned int tapsRequired);
67 * @copydoc Dali::TapGestureDetector::SetTouchesRequired(unsigned int)
69 void SetTouchesRequired(unsigned int touches);
72 * @copydoc Dali::TapGestureDetector::SetMinimumTapsRequired()
74 void SetMinimumTapsRequired(unsigned int minTaps);
77 * @copydoc Dali::TapGestureDetector::SetMaximumTapsRequired()
79 void SetMaximumTapsRequired(unsigned int maxTaps);
82 * @copydoc Dali::TapGestureDetector::GetMinimumTapsRequired()
84 unsigned int GetMinimumTapsRequired() const;
87 * @copydoc Dali::TapGestureDetector::SetMaximumTapsRequired()
89 unsigned int GetMaximumTapsRequired() const;
92 * @copydoc Dali::TapGestureDetector::GetTouchesRequired()
94 unsigned int GetTouchesRequired() const;
97 * @copydoc Dali::TapGestureDetector::ReceiveAllTapEvents()
99 void ReceiveAllTapEvents(bool receive);
103 * Called by the TapGestureProcessor when a tap gesture event occurs within the bounds of our
105 * @param[in] tappedActor The tapped actor.
106 * @param[in] tap The tap gesture.
108 void EmitTapGestureSignal(Dali::Actor tappedActor, const Dali::TapGesture& tap);
112 * @copydoc Dali::TapGestureDetector::DetectedSignal()
114 Dali::TapGestureDetector::DetectedSignalType& DetectedSignal()
116 return mDetectedSignal;
120 * Connects a callback function with the object's signals.
121 * @param[in] object The object providing the signal.
122 * @param[in] tracker Used to disconnect the signal.
123 * @param[in] signalName The signal to connect to.
124 * @param[in] functor A newly allocated FunctorDelegate.
125 * @return True if the signal was connected.
126 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
128 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
132 * A reference counted object may only be deleted by calling Unreference()
134 ~TapGestureDetector() override;
138 TapGestureDetector(const TapGestureDetector&);
139 TapGestureDetector& operator=(const TapGestureDetector& rhs);
143 * @return will return false; one-shot timer.
145 bool TimerCallback();
147 private: // GestureDetector overrides
149 * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
151 void OnActorAttach(Actor& actor) override;
154 * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
156 void OnActorDetach(Actor& actor) override;
159 * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
161 void OnActorDestroyed(Object& object) override;
164 Dali::TapGestureDetector::DetectedSignalType mDetectedSignal;
166 unsigned int mMinimumTapsRequired;
167 unsigned int mMaximumTapsRequired;
168 unsigned int mTouchesRequired;
170 Dali::Actor mTappedActor;
171 Dali::TapGesture mTap;
172 bool mReceiveAllTapEvents;
175 } // namespace Internal
177 // Helpers for public-api forwarding methods
179 inline Internal::TapGestureDetector& GetImplementation(Dali::TapGestureDetector& detector)
181 DALI_ASSERT_ALWAYS(detector && "TapGestureDetector handle is empty");
183 BaseObject& handle = detector.GetBaseObject();
185 return static_cast<Internal::TapGestureDetector&>(handle);
188 inline const Internal::TapGestureDetector& GetImplementation(const Dali::TapGestureDetector& detector)
190 DALI_ASSERT_ALWAYS(detector && "TapGestureDetector handle is empty");
192 const BaseObject& handle = detector.GetBaseObject();
194 return static_cast<const Internal::TapGestureDetector&>(handle);
199 #endif // DALI_INTERNAL_TAP_GESTURE_DETECTOR_H