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