[SRUK] Initial copy from Tizen 2.2 version
[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 Flora License, Version 1.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://floralicense.org/license/
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 // INTERNAL INCLUDES
21 #include <dali/public-api/events/tap-gesture-detector.h>
22 #include <dali/internal/event/events/gesture-detector-impl.h>
23
24 namespace Dali
25 {
26
27 struct TapGesture;
28
29 namespace Internal
30 {
31
32 class TapGestureDetector;
33
34 typedef IntrusivePtr<TapGestureDetector> TapGestureDetectorPtr;
35 typedef DerivedGestureDetectorContainer<TapGestureDetector>::type TapGestureDetectorContainer;
36
37 /**
38  * @copydoc Dali::TapGestureDetector
39  */
40 class TapGestureDetector : public GestureDetector
41 {
42 public: // Creation
43
44   /**
45    * Create a new gesture detector.
46    * @return A smart-pointer to the newly allocated detector.
47    */
48   static TapGestureDetectorPtr New();
49
50   /**
51    * Create a new gesture detector with the specified parameters.
52    * @param[in]  tapsRequired     The number of taps required.
53    * @param[in]  touchesRequired  The number of touches required.
54    * @return A smart-pointer to the newly allocated detector.
55    */
56   static TapGestureDetectorPtr New(unsigned int tapsRequired, unsigned int touchesRequired);
57
58   /**
59    * Construct a new GestureDetector.
60    */
61   TapGestureDetector();
62
63   /**
64    * Construct a new GestureDetector with the specified parameters.
65    * @param[in]  tapsRequired     The number of taps required.
66    * @param[in]  touchesRequired  The number of touches required.
67    */
68   TapGestureDetector(unsigned int tapsRequired, unsigned int touchesRequired);
69
70 public:
71
72   /**
73    * @copydoc Dali::TapGestureDetector::SetTapsRequired(unsigned int)
74    */
75   void SetTapsRequired(unsigned int taps);
76   /**
77    * @copydoc Dali::TapGestureDetector::SetTouchesRequired(unsigned int)
78    */
79   void SetTouchesRequired(unsigned int touches);
80
81   /**
82    * @copydoc Dali::TapGestureDetector::GetTapsRequired()
83    */
84   unsigned int GetTapsRequired() const;
85
86   /**
87    * @copydoc Dali::TapGestureDetector::GetTouchesRequired()
88    */
89   unsigned int GetTouchesRequired() const;
90
91 public:
92
93   /**
94    * Called by the TapGestureProcessor when a tap gesture event occurs within the bounds of our
95    * attached actor.
96    * @param[in]  tappedActor  The tapped actor.
97    * @param[in]  tap          The tap gesture.
98    */
99   void EmitTapGestureSignal(Dali::Actor tappedActor, const TapGesture& tap);
100
101 public: // Signals
102
103   /**
104    * @copydoc Dali::TapGestureDetector::DetectedSignal()
105    */
106   Dali::TapGestureDetector::DetectedSignalV2& DetectedSignal()
107   {
108     return mDetectedSignalV2;
109   }
110
111   /**
112    * Connects a callback function with the object's signals.
113    * @param[in] object The object providing the signal.
114    * @param[in] tracker Used to disconnect the signal.
115    * @param[in] signalName The signal to connect to.
116    * @param[in] functor A newly allocated FunctorDelegate.
117    * @return True if the signal was connected.
118    * @post If a signal was connected, ownership of functor was passed to CallbackBase. Otherwise the caller is responsible for deleting the unused functor.
119    */
120   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
121
122 protected:
123
124   /**
125    * A reference counted object may only be deleted by calling Unreference()
126    */
127   virtual ~TapGestureDetector();
128
129 private:
130
131   // Undefined
132   TapGestureDetector(const TapGestureDetector&);
133   TapGestureDetector& operator=(const TapGestureDetector& rhs);
134
135 private: // GestureDetector overrides
136
137   /**
138    * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
139    */
140   virtual void OnActorAttach(Actor& actor);
141
142   /**
143    * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
144    */
145   virtual void OnActorDetach(Actor& actor);
146
147   /**
148    * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
149    */
150   virtual void OnActorDestroyed(Object& object);
151
152 private:
153
154   Dali::TapGestureDetector::DetectedSignalV2 mDetectedSignalV2;
155
156   unsigned int mTapsRequired;
157   unsigned int mTouchesRequired;
158 };
159
160 } // namespace Internal
161
162 // Helpers for public-api forwarding methods
163
164 inline Internal::TapGestureDetector& GetImplementation(Dali::TapGestureDetector& detector)
165 {
166   DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
167
168   BaseObject& handle = detector.GetBaseObject();
169
170   return static_cast<Internal::TapGestureDetector&>(handle);
171 }
172
173 inline const Internal::TapGestureDetector& GetImplementation(const Dali::TapGestureDetector& detector)
174 {
175   DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
176
177   const BaseObject& handle = detector.GetBaseObject();
178
179   return static_cast<const Internal::TapGestureDetector&>(handle);
180 }
181
182 } // namespace Dali
183
184 #endif // __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__