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