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