1 #ifndef DALI_INTERNAL_TAP_GESTURE_DETECTOR_H
2 #define DALI_INTERNAL_TAP_GESTURE_DETECTOR_H
5 * Copyright (c) 2019 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/internal/event/events/gesture-detector-impl.h>
33 class TapGestureDetector;
35 typedef IntrusivePtr<TapGestureDetector> TapGestureDetectorPtr;
36 typedef DerivedGestureDetectorContainer<TapGestureDetector>::type TapGestureDetectorContainer;
39 * @copydoc Dali::TapGestureDetector
41 class TapGestureDetector : public GestureDetector
46 * Create a new gesture detector.
47 * @return A smart-pointer to the newly allocated detector.
49 static TapGestureDetectorPtr New();
52 * Create a new gesture detector with the specified parameters.
53 * @param[in] tapsRequired The number of taps required.
54 * @return A smart-pointer to the newly allocated detector.
56 static TapGestureDetectorPtr New( unsigned int tapsRequired );
59 * Construct a new GestureDetector.
64 * Construct a new GestureDetector with the specified parameters.
65 * @param[in] tapsRequired The number of taps required.
67 TapGestureDetector( unsigned int tapsRequired );
72 * @copydoc Dali::TapGestureDetector::SetTouchesRequired(unsigned int)
74 void SetTouchesRequired(unsigned int touches);
77 * @copydoc Dali::TapGestureDetector::SetMinimumTapsRequired()
79 void SetMinimumTapsRequired( unsigned int minTaps );
82 * @copydoc Dali::TapGestureDetector::SetMaximumTapsRequired()
84 void SetMaximumTapsRequired( unsigned int maxTaps );
87 * @copydoc Dali::TapGestureDetector::GetMinimumTapsRequired()
89 unsigned int GetMinimumTapsRequired() const;
92 * @copydoc Dali::TapGestureDetector::SetMaximumTapsRequired()
94 unsigned int GetMaximumTapsRequired() const;
97 * @copydoc Dali::TapGestureDetector::GetTouchesRequired()
99 unsigned int GetTouchesRequired() const;
104 * Called by the TapGestureProcessor when a tap gesture event occurs within the bounds of our
106 * @param[in] tappedActor The tapped actor.
107 * @param[in] tap The tap gesture.
109 void EmitTapGestureSignal(Dali::Actor tappedActor, const TapGesture& tap);
114 * @copydoc Dali::TapGestureDetector::DetectedSignal()
116 Dali::TapGestureDetector::DetectedSignalType& DetectedSignal()
118 return mDetectedSignal;
122 * Connects a callback function with the object's signals.
123 * @param[in] object The object providing the signal.
124 * @param[in] tracker Used to disconnect the signal.
125 * @param[in] signalName The signal to connect to.
126 * @param[in] functor A newly allocated FunctorDelegate.
127 * @return True if the signal was connected.
128 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
130 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
135 * A reference counted object may only be deleted by calling Unreference()
137 virtual ~TapGestureDetector();
142 TapGestureDetector(const TapGestureDetector&);
143 TapGestureDetector& operator=(const TapGestureDetector& rhs);
145 private: // GestureDetector overrides
148 * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
150 virtual void OnActorAttach(Actor& actor);
153 * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
155 virtual void OnActorDetach(Actor& actor);
158 * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
160 virtual void OnActorDestroyed(Object& object);
164 Dali::TapGestureDetector::DetectedSignalType mDetectedSignal;
166 unsigned int mMinimumTapsRequired;
167 unsigned int mMaximumTapsRequired;
168 unsigned int mTouchesRequired;
171 } // namespace Internal
173 // Helpers for public-api forwarding methods
175 inline Internal::TapGestureDetector& GetImplementation(Dali::TapGestureDetector& detector)
177 DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
179 BaseObject& handle = detector.GetBaseObject();
181 return static_cast<Internal::TapGestureDetector&>(handle);
184 inline const Internal::TapGestureDetector& GetImplementation(const Dali::TapGestureDetector& detector)
186 DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
188 const BaseObject& handle = detector.GetBaseObject();
190 return static_cast<const Internal::TapGestureDetector&>(handle);
195 #endif // DALI_INTERNAL_TAP_GESTURE_DETECTOR_H