License conversion from Flora to Apache 2.0
[platform/core/uifw/dali-core.git] / dali / internal / event / events / tap-gesture-detector-impl.h
1 #ifndef __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
2 #define __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__
3
4 /*
5  * Copyright (c) 2014 Samsung Electronics Co., Ltd.
6  *
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
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  *
19  */
20
21 // INTERNAL INCLUDES
22 #include <dali/public-api/events/tap-gesture-detector.h>
23 #include <dali/internal/event/events/gesture-detector-impl.h>
24
25 namespace Dali
26 {
27
28 struct TapGesture;
29
30 namespace Internal
31 {
32
33 class TapGestureDetector;
34
35 typedef IntrusivePtr<TapGestureDetector> TapGestureDetectorPtr;
36 typedef DerivedGestureDetectorContainer<TapGestureDetector>::type TapGestureDetectorContainer;
37
38 /**
39  * @copydoc Dali::TapGestureDetector
40  */
41 class TapGestureDetector : public GestureDetector
42 {
43 public: // Creation
44
45   /**
46    * Create a new gesture detector.
47    * @return A smart-pointer to the newly allocated detector.
48    */
49   static TapGestureDetectorPtr New();
50
51   /**
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.
56    */
57   static TapGestureDetectorPtr New(unsigned int tapsRequired, unsigned int touchesRequired);
58
59   /**
60    * Construct a new GestureDetector.
61    */
62   TapGestureDetector();
63
64   /**
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.
68    */
69   TapGestureDetector(unsigned int tapsRequired, unsigned int touchesRequired);
70
71 public:
72
73   /**
74    * @copydoc Dali::TapGestureDetector::SetTapsRequired(unsigned int)
75    */
76   void SetTapsRequired(unsigned int taps);
77   /**
78    * @copydoc Dali::TapGestureDetector::SetTouchesRequired(unsigned int)
79    */
80   void SetTouchesRequired(unsigned int touches);
81
82   /**
83    * @copydoc Dali::TapGestureDetector::GetTapsRequired()
84    */
85   unsigned int GetTapsRequired() const;
86
87   /**
88    * @copydoc Dali::TapGestureDetector::GetTouchesRequired()
89    */
90   unsigned int GetTouchesRequired() const;
91
92 public:
93
94   /**
95    * Called by the TapGestureProcessor when a tap gesture event occurs within the bounds of our
96    * attached actor.
97    * @param[in]  tappedActor  The tapped actor.
98    * @param[in]  tap          The tap gesture.
99    */
100   void EmitTapGestureSignal(Dali::Actor tappedActor, const TapGesture& tap);
101
102 public: // Signals
103
104   /**
105    * @copydoc Dali::TapGestureDetector::DetectedSignal()
106    */
107   Dali::TapGestureDetector::DetectedSignalV2& DetectedSignal()
108   {
109     return mDetectedSignalV2;
110   }
111
112   /**
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.
120    */
121   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
122
123 protected:
124
125   /**
126    * A reference counted object may only be deleted by calling Unreference()
127    */
128   virtual ~TapGestureDetector();
129
130 private:
131
132   // Undefined
133   TapGestureDetector(const TapGestureDetector&);
134   TapGestureDetector& operator=(const TapGestureDetector& rhs);
135
136 private: // GestureDetector overrides
137
138   /**
139    * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
140    */
141   virtual void OnActorAttach(Actor& actor);
142
143   /**
144    * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
145    */
146   virtual void OnActorDetach(Actor& actor);
147
148   /**
149    * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
150    */
151   virtual void OnActorDestroyed(Object& object);
152
153 private:
154
155   Dali::TapGestureDetector::DetectedSignalV2 mDetectedSignalV2;
156
157   unsigned int mTapsRequired;
158   unsigned int mTouchesRequired;
159 };
160
161 } // namespace Internal
162
163 // Helpers for public-api forwarding methods
164
165 inline Internal::TapGestureDetector& GetImplementation(Dali::TapGestureDetector& detector)
166 {
167   DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
168
169   BaseObject& handle = detector.GetBaseObject();
170
171   return static_cast<Internal::TapGestureDetector&>(handle);
172 }
173
174 inline const Internal::TapGestureDetector& GetImplementation(const Dali::TapGestureDetector& detector)
175 {
176   DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
177
178   const BaseObject& handle = detector.GetBaseObject();
179
180   return static_cast<const Internal::TapGestureDetector&>(handle);
181 }
182
183 } // namespace Dali
184
185 #endif // __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__