[dali_1.0.16] Merge branch 'tizen'
[platform/core/uifw/dali-core.git] / dali / public-api / events / tap-gesture-detector.h
1 #ifndef __DALI_TAP_GESTURE_DETECTOR_H__
2 #define __DALI_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/gesture-detector.h>
23 #include <dali/public-api/signals/dali-signal-v2.h>
24
25 namespace Dali
26 {
27
28 namespace Internal DALI_INTERNAL
29 {
30 class TapGestureDetector;
31 }
32
33 struct TapGesture;
34
35 /**
36  * @brief This class emits a signal when a tap gesture occurs that meets the requirements set by the
37  * application.
38  *
39  * See TapGestureDetector::SetTapsRequired and TapGestureDetector::SetTouchesRequired.
40  *
41  * A Tap Gesture is a discrete gesture, which means it does not have any state information attached
42  * to it.  Please see TapGesture for more information.
43  *
44  * The application programmer can use this gesture detector as follows:
45  * @code
46  * TapGestureDetector detector = TapGestureDetector::New();
47  * detector.Attach(myActor);
48  * detector.DetectedSignal().Connect(this, &MyApplication::OnTap);
49  * @endcode
50  *
51  * @see TapGesture
52  */
53 class DALI_IMPORT_API TapGestureDetector : public GestureDetector
54 {
55 public: // Typedefs
56
57   /**
58    * @brief Signal type for detected signal.
59    */
60   typedef SignalV2< void (Actor, TapGesture) > DetectedSignalV2;
61
62   //Signal Names
63   static const char* const SIGNAL_TAP_DETECTED; ///< name "tap-detected"
64
65 public: // Creation & Destruction
66
67   /**
68    * @brief Create an uninitialized TapGestureDetector; this can be initialized with TapGestureDetector::New().
69    *
70    * Calling member functions with an uninitialized Dali::Object is not allowed.
71    */
72   TapGestureDetector();
73
74   /**
75    * @brief Create an initialized TapGestureDetector.
76    *
77    * By default, this would create a gesture detector which requires one tap with one touch.
78    * @return A handle to a newly allocated Dali resource.
79    */
80   static TapGestureDetector New();
81
82   /**
83    * @brief Create an initialized TapGestureDetector with the specified parameters.
84    *
85    * @param[in]  tapsRequired     The number of taps required.
86    * @param[in]  touchesRequired  The number of touches required.
87    * @return A handle to a newly allocated Dali resource.
88    */
89   static TapGestureDetector New(unsigned int tapsRequired, unsigned int touchesRequired);
90
91   /**
92    * @brief Downcast an Object handle to TapGestureDetector handle.
93    *
94    * If handle points to a TapGestureDetector object the
95    * downcast produces valid handle. If not the returned handle is left uninitialized.
96    * @param[in] handle to An object
97    * @return handle to a TapGestureDetector object or an uninitialized handle
98    */
99   static TapGestureDetector DownCast( BaseHandle handle );
100
101   /**
102    * @brief Destructor
103    *
104    * This is non-virtual since derived Handle types must not contain data or virtual methods.
105    */
106   ~TapGestureDetector();
107
108   /**
109    * @brief This copy constructor is required for (smart) pointer semantics.
110    *
111    * @param [in] handle A reference to the copied handle
112    */
113   TapGestureDetector(const TapGestureDetector& handle);
114
115   /**
116    * @brief This assignment operator is required for (smart) pointer semantics.
117    *
118    * @param [in] rhs  A reference to the copied handle
119    * @return A reference to this
120    */
121   TapGestureDetector& operator=(const TapGestureDetector& rhs);
122
123   /**
124    * @brief This method is defined to allow assignment of the NULL value,
125    * and will throw an exception if passed any other value.
126    *
127    * Assigning to NULL is an alias for Reset().
128    * @param [in] rhs  A NULL pointer
129    * @return A reference to this handle
130    */
131   TapGestureDetector& operator=(BaseHandle::NullType* rhs);
132
133 public: // Setters
134
135   /**
136    * @brief Set the number of taps required.
137    *
138    * The tap count is the number of times a user should "tap" the screen.
139    * @param[in]  taps  Taps required.
140    * @pre The gesture detector has been initialized.
141    * @note The default is '1'.
142    */
143   void SetTapsRequired(unsigned int taps);
144
145   /**
146    * @brief Set the number of touches required.
147    *
148    * The number of touches corresponds to the number of fingers a user has on the screen.
149    * @param[in]  touches  Touches required.
150    * @pre The gesture detector has been initialized.
151    * @note The default is '1'.
152    */
153   void SetTouchesRequired(unsigned int touches);
154
155 public: // Getters
156
157   /**
158    * @brief Retrieves the number of taps required.
159    *
160    * @return The taps required.
161    * @pre The gesture detector has been initialized.
162    */
163   unsigned int GetTapsRequired() const;
164
165   /**
166    * @brief Retrieves the number of touches required.
167    *
168    * @return The number of touches required.
169    * @pre The gesture detector has been initialized.
170    */
171   unsigned int GetTouchesRequired() const;
172
173 public: // Signals
174
175   /**
176    * @brief This signal is emitted when the specified tap is detected on the attached actor.
177    *
178    * A callback of the following type may be connected:
179    * @code
180    *   void YourCallbackName(Actor actor, TapGesture gesture);
181    * @endcode
182    * @pre The gesture detector has been initialized.
183    * @return The signal to connect to.
184    */
185   DetectedSignalV2& DetectedSignal();
186
187 public: // Not intended for Application developers
188
189   /**
190    * @brief This constructor is used by Dali New() methods.
191    *
192    * @param [in]  internal  A pointer to a newly allocated Dali resource.
193    */
194   explicit DALI_INTERNAL TapGestureDetector(Internal::TapGestureDetector* internal);
195 };
196
197 } // namespace Dali
198
199 #endif // __DALI_TAP_GESTURE_DETECTOR_H__