Use modern construct 'using' instead of typedef.
[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) 2020 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 class 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 = GestureState::STARTED) i.e. when fingers held down for the required time.
48  * - Second identifying the ending (state = GestureState::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   using DetectedSignalType = Signal<void( Actor, const LongPressGesture& )>; ///< Gesture detected signal type @SINCE_1_0.0
68
69 public: // Creation & Destruction
70
71   /**
72    * @brief Creates an uninitialized LongPressGestureDetector; this can be initialized with LongPressGestureDetector::New().
73    *
74    * Calling member functions with an uninitialized LongPressGestureDetector handle is not allowed.
75    * @SINCE_1_0.0
76    */
77   LongPressGestureDetector();
78
79   /**
80    * @brief Creates an initialized LongPressGestureDetector.
81    *
82    * By default, this would create a gesture detector that requires only one touch.
83    * @SINCE_1_0.0
84    * @return A handle to a newly allocated Dali resource
85    */
86   static LongPressGestureDetector New();
87
88   /**
89    * @brief Creates an initialized LongPressGestureDetector with the number of touches required.
90    *
91    * A long press gesture will be emitted from this detector if the number of fingers touching the
92    * screen is equal to the touches required.
93    * @SINCE_1_0.0
94    * @param[in] touchesRequired The number of touches required
95    * @return A handle to a newly allocated Dali resource
96    */
97   static LongPressGestureDetector New(uint32_t touchesRequired);
98
99   /**
100    * @brief Creates an initialized LongPressGestureDetector with the minimum and maximum number of touches required.
101    *
102    * A long press gesture will be emitted from this detector if the number of fingers touching the screen
103    * falls between the minimum and maximum touches set.
104    * @SINCE_1_0.0
105    * @param[in] minTouches The minimum number of touches required
106    * @param[in] maxTouches The maximum number of touches required
107    * @return A handle to a newly allocated Dali resource
108    */
109   static LongPressGestureDetector New(uint32_t minTouches, uint32_t maxTouches);
110
111   /**
112    * @brief Downcasts a handle to LongPressGestureDetector handle.
113    *
114    * If handle points to a LongPressGestureDetector object, the
115    * downcast produces valid handle. If not, the returned handle is left uninitialized.
116    * @SINCE_1_0.0
117    * @param[in] handle Handle to an object
118    * @return Handle to a LongPressGestureDetector object or an uninitialized handle
119    */
120   static LongPressGestureDetector DownCast( BaseHandle handle );
121
122   /**
123    * @brief Destructor.
124    *
125    * This is non-virtual since derived Handle types must not contain data or virtual methods.
126    * @SINCE_1_0.0
127    */
128   ~LongPressGestureDetector();
129
130   /**
131    * @brief This copy constructor is required for (smart) pointer semantics.
132    *
133    * @SINCE_1_0.0
134    * @param[in] handle A reference to the copied handle
135    */
136   LongPressGestureDetector(const LongPressGestureDetector& handle);
137
138   /**
139    * @brief This assignment operator is required for (smart) pointer semantics.
140    *
141    * @SINCE_1_0.0
142    * @param[in] rhs A reference to the copied handle
143    * @return A reference to this
144    */
145   LongPressGestureDetector& operator=(const LongPressGestureDetector& rhs);
146
147 public: // Setters
148
149   /**
150    * @brief Sets the number of touches required.
151    *
152    * The number of touches corresponds to the number of fingers a user
153    * has on the screen.  This sets the minimum and maximum touches to
154    * the input parameter.
155    *
156    * @SINCE_1_0.0
157    * @param[in] touches Touches required
158    * @pre The gesture detector has been initialized.
159    * @note The default is '1'.
160    */
161   void SetTouchesRequired(uint32_t touches);
162
163   /**
164    * @brief Sets the minimum and maximum touches required.
165    *
166    * The number of touches corresponds to the number of fingers a user
167    * has on the screen.
168    *
169    * @SINCE_1_0.0
170    * @param[in] minTouches Minimum Touches required
171    * @param[in] maxTouches Maximum Touches required
172    * @pre The gesture detector has been initialized.
173    * @note The default is '1'.
174    */
175   void SetTouchesRequired(uint32_t minTouches, uint32_t maxTouches);
176
177 public: // Getters
178
179   /**
180    * @brief Retrieves the minimum number of touches required.
181    *
182    * @SINCE_1_0.0
183    * @return The minimum number of touches required
184    * @pre The gesture detector has been initialized.
185    */
186   uint32_t GetMinimumTouchesRequired() const;
187
188   /**
189    * @brief Retrieves the maximum number of touches required.
190    *
191    * @SINCE_1_0.0
192    * @return The maximum number of touches required
193    * @pre The gesture detector has been initialized.
194    */
195   uint32_t GetMaximumTouchesRequired() const;
196
197 public: // Signals
198
199   /**
200    * @brief This signal is emitted when the specified long press is detected on the attached actor.
201    *
202    * A callback of the following type may be connected:
203    * @code
204    *   void YourCallbackName( Actor actor, const LongPressGesture& gesture );
205    * @endcode
206    * @SINCE_1_0.0
207    * @return The signal to connect to
208    * @pre The gesture detector has been initialized.
209    */
210   DetectedSignalType& DetectedSignal();
211
212 public: // Not intended for Application developers
213
214   /// @cond internal
215   /**
216    * @brief This constructor is used by LongPressGestureDetector::New() methods.
217    *
218    * @SINCE_1_0.0
219    * @param[in] internal A pointer to a newly allocated Dali resource
220    */
221   explicit DALI_INTERNAL LongPressGestureDetector(Internal::LongPressGestureDetector* internal);
222   /// @endcond
223
224 };
225
226 /**
227  * @}
228  */
229 } // namespace Dali
230
231 #endif // DALI_LONG_PRESS_GESTURE_DETECTOR_H