1 #ifndef DALI_INTERNAL_TAP_GESTURE_DETECTOR_H
2 #define DALI_INTERNAL_TAP_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/tap-gesture-detector.h>
23 #include <dali/public-api/events/tap-gesture.h>
24 #include <dali/internal/event/events/gesture-detector-impl.h>
32 class TapGestureDetector;
34 using TapGestureDetectorPtr = IntrusivePtr<TapGestureDetector>;
35 using TapGestureDetectorContainer = DerivedGestureDetectorContainer<TapGestureDetector>::type;
38 * @copydoc Dali::TapGestureDetector
40 class TapGestureDetector : public GestureDetector
45 * Create a new gesture detector.
46 * @return A smart-pointer to the newly allocated detector.
48 static TapGestureDetectorPtr New();
51 * Create a new gesture detector with the specified parameters.
52 * @param[in] tapsRequired The number of taps required.
53 * @return A smart-pointer to the newly allocated detector.
55 static TapGestureDetectorPtr New( unsigned int tapsRequired );
58 * Construct a new GestureDetector.
63 * Construct a new GestureDetector with the specified parameters.
64 * @param[in] tapsRequired The number of taps required.
66 TapGestureDetector( unsigned int tapsRequired );
71 * @copydoc Dali::TapGestureDetector::SetTouchesRequired(unsigned int)
73 void SetTouchesRequired(unsigned int touches);
76 * @copydoc Dali::TapGestureDetector::SetMinimumTapsRequired()
78 void SetMinimumTapsRequired( unsigned int minTaps );
81 * @copydoc Dali::TapGestureDetector::SetMaximumTapsRequired()
83 void SetMaximumTapsRequired( unsigned int maxTaps );
86 * @copydoc Dali::TapGestureDetector::GetMinimumTapsRequired()
88 unsigned int GetMinimumTapsRequired() const;
91 * @copydoc Dali::TapGestureDetector::SetMaximumTapsRequired()
93 unsigned int GetMaximumTapsRequired() const;
96 * @copydoc Dali::TapGestureDetector::GetTouchesRequired()
98 unsigned int GetTouchesRequired() const;
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);
113 * @copydoc Dali::TapGestureDetector::DetectedSignal()
115 Dali::TapGestureDetector::DetectedSignalType& DetectedSignal()
117 return mDetectedSignal;
121 * Connects a callback function with the object's signals.
122 * @param[in] object The object providing the signal.
123 * @param[in] tracker Used to disconnect the signal.
124 * @param[in] signalName The signal to connect to.
125 * @param[in] functor A newly allocated FunctorDelegate.
126 * @return True if the signal was connected.
127 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
129 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
134 * A reference counted object may only be deleted by calling Unreference()
136 ~TapGestureDetector() override;
141 TapGestureDetector(const TapGestureDetector&);
142 TapGestureDetector& operator=(const TapGestureDetector& rhs);
144 private: // GestureDetector overrides
147 * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
149 void OnActorAttach(Actor& actor) override;
152 * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
154 void OnActorDetach(Actor& actor) override;
157 * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
159 void OnActorDestroyed(Object& object) override;
163 Dali::TapGestureDetector::DetectedSignalType mDetectedSignal;
165 unsigned int mMinimumTapsRequired;
166 unsigned int mMaximumTapsRequired;
167 unsigned int mTouchesRequired;
170 } // namespace Internal
172 // Helpers for public-api forwarding methods
174 inline Internal::TapGestureDetector& GetImplementation(Dali::TapGestureDetector& detector)
176 DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
178 BaseObject& handle = detector.GetBaseObject();
180 return static_cast<Internal::TapGestureDetector&>(handle);
183 inline const Internal::TapGestureDetector& GetImplementation(const Dali::TapGestureDetector& detector)
185 DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
187 const BaseObject& handle = detector.GetBaseObject();
189 return static_cast<const Internal::TapGestureDetector&>(handle);
194 #endif // DALI_INTERNAL_TAP_GESTURE_DETECTOR_H