1 #ifndef __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
2 #define __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
5 * Copyright (c) 2014 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 * @param[in] touchesRequired The number of touches required.
55 * @return A smart-pointer to the newly allocated detector.
57 static TapGestureDetectorPtr New(unsigned int tapsRequired, unsigned int touchesRequired);
60 * Construct a new GestureDetector.
65 * Construct a new GestureDetector with the specified parameters.
66 * @param[in] tapsRequired The number of taps required.
67 * @param[in] touchesRequired The number of touches required.
69 TapGestureDetector(unsigned int tapsRequired, unsigned int touchesRequired);
74 * @copydoc Dali::TapGestureDetector::SetTapsRequired(unsigned int)
76 void SetTapsRequired(unsigned int taps);
78 * @copydoc Dali::TapGestureDetector::SetTouchesRequired(unsigned int)
80 void SetTouchesRequired(unsigned int touches);
83 * @copydoc Dali::TapGestureDetector::GetTapsRequired()
85 unsigned int GetTapsRequired() const;
88 * @copydoc Dali::TapGestureDetector::GetTouchesRequired()
90 unsigned int GetTouchesRequired() const;
95 * Called by the TapGestureProcessor when a tap gesture event occurs within the bounds of our
97 * @param[in] tappedActor The tapped actor.
98 * @param[in] tap The tap gesture.
100 void EmitTapGestureSignal(Dali::Actor tappedActor, const TapGesture& tap);
105 * @copydoc Dali::TapGestureDetector::DetectedSignal()
107 Dali::TapGestureDetector::DetectedSignalType& DetectedSignal()
109 return mDetectedSignal;
113 * Connects a callback function with the object's signals.
114 * @param[in] object The object providing the signal.
115 * @param[in] tracker Used to disconnect the signal.
116 * @param[in] signalName The signal to connect to.
117 * @param[in] functor A newly allocated FunctorDelegate.
118 * @return True if the signal was connected.
119 * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
121 static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
126 * A reference counted object may only be deleted by calling Unreference()
128 virtual ~TapGestureDetector();
133 TapGestureDetector(const TapGestureDetector&);
134 TapGestureDetector& operator=(const TapGestureDetector& rhs);
136 private: // GestureDetector overrides
139 * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
141 virtual void OnActorAttach(Actor& actor);
144 * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
146 virtual void OnActorDetach(Actor& actor);
149 * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
151 virtual void OnActorDestroyed(Object& object);
155 Dali::TapGestureDetector::DetectedSignalType mDetectedSignal;
157 unsigned int mTapsRequired;
158 unsigned int mTouchesRequired;
161 } // namespace Internal
163 // Helpers for public-api forwarding methods
165 inline Internal::TapGestureDetector& GetImplementation(Dali::TapGestureDetector& detector)
167 DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
169 BaseObject& handle = detector.GetBaseObject();
171 return static_cast<Internal::TapGestureDetector&>(handle);
174 inline const Internal::TapGestureDetector& GetImplementation(const Dali::TapGestureDetector& detector)
176 DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
178 const BaseObject& handle = detector.GetBaseObject();
180 return static_cast<const Internal::TapGestureDetector&>(handle);
185 #endif // __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__