2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0/
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FUiTouchGestureDetector.h
20 * @brief This is the header file for the %TouchGestureDetector class.
22 * This header file contains the declarations of the %TouchGestureDetector class.
25 #ifndef _FUI_TOUCH_GESTURE_DETECTOR_H_
26 #define _FUI_TOUCH_GESTURE_DETECTOR_H_
28 #include <FBaseObject.h>
31 namespace Tizen { namespace Ui
35 * @enum TouchGestureDetectorState
37 * Defines the state of a gesture detector.
41 enum TouchGestureDetectorState
43 GESTURE_DETECTOR_STATE_READY, /**< The gesture detector is ready to recognize the gesture */
44 GESTURE_DETECTOR_STATE_STARTED, /**< The gesture detector first recognizes the continuous gesture */
45 GESTURE_DETECTOR_STATE_CHANGED, /**< A subsequent change happens to the continuous gesture */
46 GESTURE_DETECTOR_STATE_FINISHED, /**< The discrete gesture is recognized or the continuous gesture ends */
47 GESTURE_DETECTOR_STATE_FAILED, /**< The gesture detector fails in recognizing the gesture */
51 class ITouchGestureEventListener;
52 class _TouchGestureDetectorImpl;
55 * @class TouchGestureDetector
56 * @brief This class stores the information of a gesture detector.
60 * The %TouchGestureDetector class defines a common behavior for gesture detectors and provides information about gesture detector.
63 class _OSP_EXPORT_ TouchGestureDetector
64 : public Tizen::Base::Object
68 * The object is not fully constructed after this constructor is called. For full construction, the Construct() method must be called right after calling this constructor.
72 TouchGestureDetector(void);
75 * This destructor overrides Tizen::Base::Object::~Object().
79 virtual ~TouchGestureDetector(void);
83 * Initializes this instance of %TouchGestureDetector.
87 * @exception E_SUCCESS The method is successful.
89 result Construct(void);
92 * Gets the control to which the gesture detector is attached. @n
93 * If an error occurs, this method returns @c null.
97 * @return The control to which the gesture detector is attached
98 * @exception E_SUCCESS The method is successful.
100 Control* GetControl(void) const;
103 * Enables or disables delaying touch event on Control. @n
104 * The %TouchGestureDetector receives touch events prior to a UI control to which it is added.
105 * Depending on a gesture that it tries to recognize, it is decided whether touch events need to be delivered to the UI control.
106 * If touch events must not be delivered to the UI control while gesture recognition is in progress, call this method with @c false argument.
107 * When the recognition finishes as success, delivering delayed touch events is dependent on IsCancelTouchEventOnSuccessEnabled().
108 * When the recognition finishes as fail, all delayed touch events are fired sequentially.
109 * The default value is @c false.
113 * @return An error code
114 * @param[in] enable Whether to delay events
115 * @exception E_SUCCESS The method is successful.
116 * @see IsDelayTouchEventEnabled()
117 * @see SetCancelTouchEventOnSuccessEnabled()
119 result SetDelayTouchEventEnabled(bool enable);
122 * Checks whether delaying touch event to Control is enabled.
126 * @return @c true if delaying touch event is enabled, @n
127 * else @c false if delaying touch event is disabled
128 * @exception E_SUCCESS The method is successful.
129 * @see SetDelayTouchEventEnabled()
131 bool IsDelayTouchEventEnabled(void) const;
134 * Enables or disables canceling touch event after a gesture is recognized. @n
135 * If canceling touch event is enabled and a gesture is recognized, touch events which have been queued are not delivered to a UI control and discarded.
136 * The default value is @c false.
140 * @return An error code
141 * @param[in] enable Whether to cancel touch event
142 * @exception E_SUCCESS The method is successful.
143 * @see IsCancelTouchEventOnSuccessEnabled()
144 * @see SetDelayTouchEventEnabled()
146 result SetCancelTouchEventOnSuccessEnabled(bool enable);
149 * Checks whether touch events are canceled after a gesture is recognized.
153 * @return @c true if canceling touch event is enabled, @n
155 * @exception E_SUCCESS The method is successful.
156 * @see SetCancelTouchEventOnSuccessEnabled()
158 bool IsCancelTouchEventOnSuccessEnabled(void) const;
161 * Sets priority between gesture detectors.
163 * @brief <i> [Deprecated] </i>
164 * @deprecated This method is deprecated.
167 * @return An error code
168 * @param[in] gestureDetector The gesture detector
169 * @exception E_SUCCESS The method is successful.
170 * @exception E_INVALID_ARG The specified @c gestureDetector is invalid.
171 * @remarks If you want to set relationship between gesture detectors, call this method.
172 * If @c gestureDetector fails in recognizing a gesture, the gesture detector which waits for it starts the processing of recognizing.
173 * If @c gestureDetector succeeds in recognizing a gesture,
174 * the state of the gesture detector which waits for it changes to @c GESTURE_DETECTOR_STATE_FAIL.
176 result StartOnFailureOf(const TouchGestureDetector& gestureDetector);
179 * Sets priority between gesture detectors.
183 * @return An error code
184 * @param[in] pGestureDetector A pointer of gesture detector
185 * @exception E_SUCCESS The method is successful.
186 * @exception E_INVALID_ARG The @c pGestureDetector is null.
187 * @remarks If you want to set relationship between gesture detectors, call this method.
188 * If @c gestureDetector fails in recognizing a gesture, the gesture detector which waits for it starts the processing of recognizing.
189 * If @c gestureDetector succeeds in recognizing a gesture,
190 * the state of the gesture detector which waits for it changes to @c GESTURE_DETECTOR_STATE_FAIL.
192 result StartOnFailureOf(TouchGestureDetector* pGestureDetector);
195 * Called when touch is pressed in the Control to which the gesture detector is attached.
199 * @param[in] source The source of the event
200 * @param[in] touchInfo The touch event information
202 virtual void OnTouchPressed(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo);
205 * Called when touch is moved in the Control to which the gesture detector is attached.
209 * @param[in] source The source of the event
210 * @param[in] touchInfo The touch event information
212 virtual void OnTouchMoved(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo);
215 * Called when touch is released in the Control to which the gesture detector is attached.
219 * @param[in] source The source of the event
220 * @param[in] touchInfo The touch event information
222 virtual void OnTouchReleased(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo);
225 * Called when touch is canceled in the Control to which the gesture detector is attached.
229 * @param[in] source The source of the event
230 * @param[in] touchInfo The touch event information
232 virtual void OnTouchCanceled(Tizen::Ui::Control& source, const Tizen::Ui::TouchEventInfo& touchInfo);
236 * Sets the current state of gesture detector. @n
237 * You can call this method only inherit %TouchGestureDetector directly.
241 * @return An error code
242 * @param[in] state Gesture detector state
243 * @exception E_SUCCESS The method is successful.
244 * @see GetDetectorState()
246 result SetDetectorState(Tizen::Ui::TouchGestureDetectorState state);
249 * Gets the current state of gesture detector. @n
250 * If an error occurs, this method returns @c GESTURE_DETECTOR_STATE_READY.
254 * @return The current state of gesture detector
255 * @exception E_SUCCESS The method is successful.
256 * @see SetDetectorState()
258 Tizen::Ui::TouchGestureDetectorState GetDetectorState(void) const;
261 * Adds the IGestureEventListener instance to the gesture detector instance. @n
262 * The added listener gets notified when a gesture is recognized.
266 * @return An error code
267 * @param[in] listener The event listener to add
268 * @exception E_SUCCESS The method is successful.
269 * @exception E_OBJ_ALREADY_EXIST The listener is already added.
270 * @see RemoveGestureEventListener()
272 result AddGestureEventListener(Tizen::Ui::ITouchGestureEventListener& listener);
275 * Removes the gesture listener instance.
279 * @return An error code
280 * @param[in] listener The listener to remove
281 * @exception E_SUCCESS The method is successful.
282 * @exception E_OBJ_NOT_FOUND The @c listener is not found.
283 * @see AddGestureEventListener()
285 result RemoveGestureEventListener(Tizen::Ui::ITouchGestureEventListener& listener);
289 // The implementation of this copy constructor is intentionally blank and declared as private to prohibit copying of objects.
291 TouchGestureDetector(const TouchGestureDetector& rhs);
294 // The implementation of this copy assignment operator is intentionally blank and declared as private to prohibit copying of objects.
296 TouchGestureDetector& operator =(const TouchGestureDetector& rhs);
299 friend class _TouchGestureDetectorImpl;
302 // This variable is for internal use only. Using this variable can cause behavioral,
303 // security-related, and consistency-related issues in the application.
305 _TouchGestureDetectorImpl* __pTouchGestureDetectorImpl;
306 }; // TouchGestureDetector
310 #endif //_FUI_TOUCH_GESTURE_DETECTOR_H_