Merge "Remove use of boost thread local storage from debug" into 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.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  * Signals
54  * | %Signal Name | Method                |
55  * |--------------|-----------------------|
56  * | tap-detected | @ref DetectedSignal() |
57  */
58 class DALI_IMPORT_API TapGestureDetector : public GestureDetector
59 {
60 public: // Typedefs
61
62   /**
63    * @brief Signal type for detected signal.
64    */
65   typedef Signal< void ( Actor, const TapGesture& ) > DetectedSignalType;
66
67 public: // Creation & Destruction
68
69   /**
70    * @brief Create an uninitialized TapGestureDetector; this can be initialized with TapGestureDetector::New().
71    *
72    * Calling member functions with an uninitialized Dali::Object is not allowed.
73    */
74   TapGestureDetector();
75
76   /**
77    * @brief Create an initialized TapGestureDetector.
78    *
79    * By default, this would create a gesture detector which requires one tap with one touch.
80    * @return A handle to a newly allocated Dali resource.
81    */
82   static TapGestureDetector New();
83
84   /**
85    * @brief Create an initialized TapGestureDetector with the specified parameters.
86    *
87    * @param[in]  tapsRequired     The number of taps required.
88    * @param[in]  touchesRequired  The number of touches required.
89    * @return A handle to a newly allocated Dali resource.
90    */
91   static TapGestureDetector New(unsigned int tapsRequired, unsigned int touchesRequired);
92
93   /**
94    * @brief Downcast an Object handle to TapGestureDetector handle.
95    *
96    * If handle points to a TapGestureDetector object the
97    * downcast produces valid handle. If not the returned handle is left uninitialized.
98    * @param[in] handle to An object
99    * @return handle to a TapGestureDetector object or an uninitialized handle
100    */
101   static TapGestureDetector DownCast( BaseHandle handle );
102
103   /**
104    * @brief Destructor
105    *
106    * This is non-virtual since derived Handle types must not contain data or virtual methods.
107    */
108   ~TapGestureDetector();
109
110   /**
111    * @brief This copy constructor is required for (smart) pointer semantics.
112    *
113    * @param [in] handle A reference to the copied handle
114    */
115   TapGestureDetector(const TapGestureDetector& handle);
116
117   /**
118    * @brief This assignment operator is required for (smart) pointer semantics.
119    *
120    * @param [in] rhs  A reference to the copied handle
121    * @return A reference to this
122    */
123   TapGestureDetector& operator=(const TapGestureDetector& rhs);
124
125 public: // Setters
126
127   /**
128    * @brief Set the number of taps required.
129    *
130    * The tap count is the number of times a user should "tap" the screen.
131    * @param[in]  taps  Taps required.
132    * @pre The gesture detector has been initialized.
133    * @note The default is '1'.
134    */
135   void SetTapsRequired(unsigned int taps);
136
137   /**
138    * @brief Set the number of touches required.
139    *
140    * The number of touches corresponds to the number of fingers a user has on the screen.
141    * @param[in]  touches  Touches required.
142    * @pre The gesture detector has been initialized.
143    * @note The default is '1'.
144    */
145   void SetTouchesRequired(unsigned int touches);
146
147 public: // Getters
148
149   /**
150    * @brief Retrieves the number of taps required.
151    *
152    * @return The taps required.
153    * @pre The gesture detector has been initialized.
154    */
155   unsigned int GetTapsRequired() const;
156
157   /**
158    * @brief Retrieves the number of touches required.
159    *
160    * @return The number of touches required.
161    * @pre The gesture detector has been initialized.
162    */
163   unsigned int GetTouchesRequired() const;
164
165 public: // Signals
166
167   /**
168    * @brief This signal is emitted when the specified tap is detected on the attached actor.
169    *
170    * A callback of the following type may be connected:
171    * @code
172    *   void YourCallbackName( Actor actor, const TapGesture& gesture );
173    * @endcode
174    * @pre The gesture detector has been initialized.
175    * @return The signal to connect to.
176    */
177   DetectedSignalType& DetectedSignal();
178
179 public: // Not intended for Application developers
180
181   /**
182    * @brief This constructor is used by Dali New() methods.
183    *
184    * @param [in]  internal  A pointer to a newly allocated Dali resource.
185    */
186   explicit DALI_INTERNAL TapGestureDetector(Internal::TapGestureDetector* internal);
187 };
188
189 } // namespace Dali
190
191 #endif // __DALI_TAP_GESTURE_DETECTOR_H__