Merge "Allow multiple renderers per Actor and sharing renderers between actors" into...
[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    * @return A smart-pointer to the newly allocated detector.
55    */
56   static TapGestureDetectorPtr New( unsigned int tapsRequired );
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    */
67   TapGestureDetector( unsigned int tapsRequired );
68
69 public:
70
71   /**
72    * @copydoc Dali::TapGestureDetector::SetTouchesRequired(unsigned int)
73    */
74   void SetTouchesRequired(unsigned int touches);
75
76   /**
77    * @copydoc Dali::TapGestureDetector::SetMinimumTapsRequired()
78    */
79   void SetMinimumTapsRequired( unsigned int minTaps );
80
81   /**
82    * @copydoc Dali::TapGestureDetector::SetMaximumTapsRequired()
83    */
84   void SetMaximumTapsRequired( unsigned int maxTaps );
85
86   /**
87    * @copydoc Dali::TapGestureDetector::GetMinimumTapsRequired()
88    */
89   unsigned int GetMinimumTapsRequired() const;
90
91   /**
92    * @copydoc Dali::TapGestureDetector::SetMaximumTapsRequired()
93    */
94   unsigned int GetMaximumTapsRequired() const;
95
96   /**
97    * @copydoc Dali::TapGestureDetector::GetTouchesRequired()
98    */
99   unsigned int GetTouchesRequired() const;
100
101 public:
102
103   /**
104    * Called by the TapGestureProcessor when a tap gesture event occurs within the bounds of our
105    * attached actor.
106    * @param[in]  tappedActor  The tapped actor.
107    * @param[in]  tap          The tap gesture.
108    */
109   void EmitTapGestureSignal(Dali::Actor tappedActor, const TapGesture& tap);
110
111 public: // Signals
112
113   /**
114    * @copydoc Dali::TapGestureDetector::DetectedSignal()
115    */
116   Dali::TapGestureDetector::DetectedSignalType& DetectedSignal()
117   {
118     return mDetectedSignal;
119   }
120
121   /**
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.
129    */
130   static bool DoConnectSignal( BaseObject* object, ConnectionTrackerInterface* tracker, const std::string& signalName, FunctorDelegate* functor );
131
132 protected:
133
134   /**
135    * A reference counted object may only be deleted by calling Unreference()
136    */
137   virtual ~TapGestureDetector();
138
139 private:
140
141   // Undefined
142   TapGestureDetector(const TapGestureDetector&);
143   TapGestureDetector& operator=(const TapGestureDetector& rhs);
144
145 private: // GestureDetector overrides
146
147   /**
148    * @copydoc Dali::Internal::GestureDetector::OnActorAttach(Actor&)
149    */
150   virtual void OnActorAttach(Actor& actor);
151
152   /**
153    * @copydoc Dali::Internal::GestureDetector::OnActorDetach(Actor&)
154    */
155   virtual void OnActorDetach(Actor& actor);
156
157   /**
158    * @copydoc Dali::Internal::GestureDetector::OnActorDestroyed(Object&)
159    */
160   virtual void OnActorDestroyed(Object& object);
161
162 private:
163
164   Dali::TapGestureDetector::DetectedSignalType mDetectedSignal;
165
166   unsigned int mMinimumTapsRequired;
167   unsigned int mMaximumTapsRequired;
168   unsigned int mTouchesRequired;
169 };
170
171 } // namespace Internal
172
173 // Helpers for public-api forwarding methods
174
175 inline Internal::TapGestureDetector& GetImplementation(Dali::TapGestureDetector& detector)
176 {
177   DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
178
179   BaseObject& handle = detector.GetBaseObject();
180
181   return static_cast<Internal::TapGestureDetector&>(handle);
182 }
183
184 inline const Internal::TapGestureDetector& GetImplementation(const Dali::TapGestureDetector& detector)
185 {
186   DALI_ASSERT_ALWAYS( detector && "TapGestureDetector handle is empty" );
187
188   const BaseObject& handle = detector.GetBaseObject();
189
190   return static_cast<const Internal::TapGestureDetector&>(handle);
191 }
192
193 } // namespace Dali
194
195 #endif // __DALI_INTERNAL_TAP_GESTURE_DETECTOR_H__