Purge underscored header file barriers
[platform/core/uifw/dali-core.git] / dali / public-api / events / long-press-gesture-detector.h
1 #ifndef DALI_LONG_PRESS_GESTURE_DETECTOR_H
2 #define DALI_LONG_PRESS_GESTURE_DETECTOR_H
3
4 /*
5  * Copyright (c) 2019 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 // EXTERNAL INCLUDES
22 #include <cstdint> // uint32_t
23
24 // INTERNAL INCLUDES
25 #include <dali/public-api/events/gesture-detector.h>
26 #include <dali/public-api/signals/dali-signal.h>
27
28 namespace Dali
29 {
30 /**
31  * @addtogroup dali_core_events
32  * @{
33  */
34
35 namespace Internal DALI_INTERNAL
36 {
37 class LongPressGestureDetector;
38 }
39
40 struct LongPressGesture;
41
42 /**
43  * @brief This class emits a signals when a long press gesture occurs that meets the requirements set by the application.
44  * @SINCE_1_0.0
45  *
46  * For any valid long press, two signals will be emitted:
47  * - First identifying the beginning (state = Started) i.e. when fingers held down for the required time.
48  * - Second identifying the ending (state = Finished) i.e. when fingers are released.
49  *
50  * The application programmer can use this gesture detector as follows:
51  * @code
52  * LongPressGestureDetector detector = LongPressGestureDetector::New();
53  * detector.Attach(myActor);
54  * detector.DetectedSignal().Connect(this, &MyApplication::OnLongPress);
55  * @endcode
56  *
57  * @see LongPressGesture
58  *
59  * Signals
60  * | %Signal Name      | Method                |
61  * |-------------------|-----------------------|
62  * | longPressDetected | @ref DetectedSignal() |
63  */
64 class DALI_CORE_API LongPressGestureDetector : public GestureDetector
65 {
66 public: // Typedefs
67
68   typedef Signal< void ( Actor, const LongPressGesture& ) > DetectedSignalType; ///< Gesture detected signal type @SINCE_1_0.0
69
70 public: // Creation & Destruction
71
72   /**
73    * @brief Creates an uninitialized LongPressGestureDetector; this can be initialized with LongPressGestureDetector::New().
74    *
75    * Calling member functions with an uninitialized LongPressGestureDetector handle is not allowed.
76    * @SINCE_1_0.0
77    */
78   LongPressGestureDetector();
79
80   /**
81    * @brief Creates an initialized LongPressGestureDetector.
82    *
83    * By default, this would create a gesture detector that requires only one touch.
84    * @SINCE_1_0.0
85    * @return A handle to a newly allocated Dali resource
86    */
87   static LongPressGestureDetector New();
88
89   /**
90    * @brief Creates an initialized LongPressGestureDetector with the number of touches required.
91    *
92    * A long press gesture will be emitted from this detector if the number of fingers touching the
93    * screen is equal to the touches required.
94    * @SINCE_1_0.0
95    * @param[in] touchesRequired The number of touches required
96    * @return A handle to a newly allocated Dali resource
97    */
98   static LongPressGestureDetector New(uint32_t touchesRequired);
99
100   /**
101    * @brief Creates an initialized LongPressGestureDetector with the minimum and maximum number of touches required.
102    *
103    * A long press gesture will be emitted from this detector if the number of fingers touching the screen
104    * falls between the minimum and maximum touches set.
105    * @SINCE_1_0.0
106    * @param[in] minTouches The minimum number of touches required
107    * @param[in] maxTouches The maximum number of touches required
108    * @return A handle to a newly allocated Dali resource
109    */
110   static LongPressGestureDetector New(uint32_t minTouches, uint32_t maxTouches);
111
112   /**
113    * @brief Downcasts a handle to LongPressGestureDetector handle.
114    *
115    * If handle points to a LongPressGestureDetector object, the
116    * downcast produces valid handle. If not, the returned handle is left uninitialized.
117    * @SINCE_1_0.0
118    * @param[in] handle Handle to an object
119    * @return Handle to a LongPressGestureDetector object or an uninitialized handle
120    */
121   static LongPressGestureDetector DownCast( BaseHandle handle );
122
123   /**
124    * @brief Destructor.
125    *
126    * This is non-virtual since derived Handle types must not contain data or virtual methods.
127    * @SINCE_1_0.0
128    */
129   ~LongPressGestureDetector();
130
131   /**
132    * @brief This copy constructor is required for (smart) pointer semantics.
133    *
134    * @SINCE_1_0.0
135    * @param[in] handle A reference to the copied handle
136    */
137   LongPressGestureDetector(const LongPressGestureDetector& handle);
138
139   /**
140    * @brief This assignment operator is required for (smart) pointer semantics.
141    *
142    * @SINCE_1_0.0
143    * @param[in] rhs A reference to the copied handle
144    * @return A reference to this
145    */
146   LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs);
147
148 public: // Setters
149
150   /**
151    * @brief Sets the number of touches required.
152    *
153    * The number of touches corresponds to the number of fingers a user
154    * has on the screen.  This sets the minimum and maximum touches to
155    * the input parameter.
156    *
157    * @SINCE_1_0.0
158    * @param[in] touches Touches required
159    * @pre The gesture detector has been initialized.
160    * @note The default is '1'.
161    */
162   void SetTouchesRequired(uint32_t touches);
163
164   /**
165    * @brief Sets the minimum and maximum touches required.
166    *
167    * The number of touches corresponds to the number of fingers a user
168    * has on the screen.
169    *
170    * @SINCE_1_0.0
171    * @param[in] minTouches Minimum Touches required
172    * @param[in] maxTouches Maximum Touches required
173    * @pre The gesture detector has been initialized.
174    * @note The default is '1'.
175    */
176   void SetTouchesRequired(uint32_t minTouches, uint32_t maxTouches);
177
178 public: // Getters
179
180   /**
181    * @brief Retrieves the minimum number of touches required.
182    *
183    * @SINCE_1_0.0
184    * @return The minimum number of touches required
185    * @pre The gesture detector has been initialized.
186    */
187   uint32_t GetMinimumTouchesRequired() const;
188
189   /**
190    * @brief Retrieves the maximum number of touches required.
191    *
192    * @SINCE_1_0.0
193    * @return The maximum number of touches required
194    * @pre The gesture detector has been initialized.
195    */
196   uint32_t GetMaximumTouchesRequired() const;
197
198 public: // Signals
199
200   /**
201    * @brief This signal is emitted when the specified long press is detected on the attached actor.
202    *
203    * A callback of the following type may be connected:
204    * @code
205    *   void YourCallbackName( Actor actor, const LongPressGesture& gesture );
206    * @endcode
207    * @SINCE_1_0.0
208    * @return The signal to connect to
209    * @pre The gesture detector has been initialized.
210    */
211   DetectedSignalType& DetectedSignal();
212
213 public: // Not intended for Application developers
214
215   /// @cond internal
216   /**
217    * @brief This constructor is used by LongPressGestureDetector::New() methods.
218    *
219    * @SINCE_1_0.0
220    * @param[in] internal A pointer to a newly allocated Dali resource
221    */
222   explicit DALI_INTERNAL LongPressGestureDetector(Internal::LongPressGestureDetector* internal);
223   /// @endcond
224
225 };
226
227 /**
228  * @}
229  */
230 } // namespace Dali
231
232 #endif // DALI_LONG_PRESS_GESTURE_DETECTOR_H