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;
98 * Called by the TapGestureProcessor when a tap gesture event occurs within the bounds of our
100 * @param[in] tappedActor The tapped actor.
101 * @param[in] tap The tap gesture.
103 void EmitTapGestureSignal(Dali::Actor tappedActor, const Dali::TapGesture& tap);
107 * @copydoc Dali::TapGestureDetector::DetectedSignal()
109 Dali::TapGestureDetector::DetectedSignalType& DetectedSignal()
111 return mDetectedSignal;
115 * Connects a callback function with the object's signals.
116 * @param[in] object The object providing the signal.
117 * @param[in] tracker Used to disconnect the signal.
118 * @param[in] signalName The signal to connect to.
119 * @param[in] functor A newly allocated FunctorDelegate.
120 * @return True if the signal was connected.
121 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
123 static bool DoConnectSignal(BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor);
127 * A reference counted object may only be deleted by calling Unreference()
129 ~TapGestureDetector() override;
133 TapGestureDetector(const TapGestureDetector&);
134 TapGestureDetector& operator=(const TapGestureDetector& rhs);
136 private: // GestureDetector overrides
138 * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
140 void OnActorAttach(Actor& actor) override;
143 * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
145 void OnActorDetach(Actor& actor) override;
148 * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
150 void OnActorDestroyed(Object& object) override;
153 Dali::TapGestureDetector::DetectedSignalType mDetectedSignal;
155 unsigned int mMinimumTapsRequired;
156 unsigned int mMaximumTapsRequired;
157 unsigned int mTouchesRequired;
160 } // namespace Internal
162 // Helpers for public-api forwarding methods
164 inline Internal::TapGestureDetector& GetImplementation(Dali::TapGestureDetector& detector)
166 DALI_ASSERT_ALWAYS(detector && "TapGestureDetector handle is empty");
168 BaseObject& handle = detector.GetBaseObject();
170 return static_cast<Internal::TapGestureDetector&>(handle);
173 inline const Internal::TapGestureDetector& GetImplementation(const Dali::TapGestureDetector& detector)
175 DALI_ASSERT_ALWAYS(detector && "TapGestureDetector handle is empty");
177 const BaseObject& handle = detector.GetBaseObject();
179 return static_cast<const Internal::TapGestureDetector&>(handle);
184 #endif // DALI_INTERNAL_TAP_GESTURE_DETECTOR_H