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