2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Flora License, Version 1.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://floralicense.org/license/
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.
18 * @file FUi_TouchGestureDetector.h
19 * @brief This is the header file for the %_TouchGestureDetector class.
21 * This header file contains the declarations of the %_TouchGestureDetector class.
23 #ifndef _FUI_INTERNAL_TOUCH_GESTURE_DETECTOR_H_
24 #define _FUI_INTERNAL_TOUCH_GESTURE_DETECTOR_H_
27 #include <FBaseColIList.h>
28 #include <FBaseObject.h>
29 #include <FBaseSysLog.h>
30 #include "FUi_Types.h"
31 #include "FUi_UiTouchEvent.h"
32 #include "FUi_ITouchEventListener.h"
33 #include "FUi_ITouchGestureEventListener.h"
34 #include "FUi_ITouchGestureDelegate.h"
35 #include "FUi_ITouchGestureStateChangedListener.h"
37 namespace Tizen { namespace Ui
42 T Distance(T x1, T y1, T x2, T y2)
44 return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
47 enum _TouchGestureDetectorState
49 _TOUCH_GESTURE_DETECTOR_STATE_READY,
50 _TOUCH_GESTURE_DETECTOR_STATE_STARTED,
51 _TOUCH_GESTURE_DETECTOR_STATE_CHANGED,
52 _TOUCH_GESTURE_DETECTOR_STATE_FINISHED,
53 _TOUCH_GESTURE_DETECTOR_STATE_FAILED,
54 _TOUCH_GESTURE_DETECTOR_STATE_CANCELED,
55 _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS_AND_WAIT,
56 _TOUCH_GESTURE_DETECTOR_STATE_SUCCESS = _TOUCH_GESTURE_DETECTOR_STATE_FINISHED
59 enum _TouchGestureDetectorType
61 _TOUCH_GESTURE_DETECTOR_TYPE_CUSTOM,
62 _TOUCH_GESTURE_DETECTOR_TYPE_TAP,
63 _TOUCH_GESTURE_DETECTOR_TYPE_LONG_PRESS,
64 _TOUCH_GESTURE_DETECTOR_TYPE_PINCH,
65 _TOUCH_GESTURE_DETECTOR_TYPE_FLICK,
66 _TOUCH_GESTURE_DETECTOR_TYPE_ROTATION,
67 _TOUCH_GESTURE_DETECTOR_TYPE_PANNING
70 enum _TouchGestureDetectorEventType
72 _TOUCH_GESTURE_DETECTOR_EVENT_TYPE_DISCRETE,
73 _TOUCH_GESTURE_DETECTOR_EVENT_TYPE_CONTINUOUS
76 class _OSP_EXPORT_ _TouchGestureDetector
77 : public Tizen::Base::Object
78 , virtual public _ITouchGestureStateChangedListener
79 , virtual public _ITouchGestureDelegate
82 _TouchGestureDetector(void);
83 virtual ~_TouchGestureDetector(void);
85 void SetDetectorState(_TouchGestureDetectorState state);
86 _TouchGestureDetectorState GetDetectorState(void) const;
88 void SetDelayTouchEventEnabled(bool enable);
89 bool IsDelayTouchEventEnabled(void) const;
91 void SetCancelTouchEventOnSuccessEnabled(bool enable);
92 bool IsCancelTouchEventOnSuccessEnabled(void) const;
94 result AddGestureListener(const Tizen::Ui::_ITouchGestureEventListener& listener);
95 result RemoveGestureListener(const Tizen::Ui::_ITouchGestureEventListener& listener);
96 Tizen::Base::Collection::IListT <Tizen::Ui::_ITouchGestureEventListener*>* GetGestureListenerList(void) const;
98 result StartOnFailureOf(const _TouchGestureDetector& gesture);
100 void SetDetectorType(_TouchGestureDetectorType type);
101 _TouchGestureDetectorType GetDetectorType(void) const;
103 result SetControl(const Tizen::Ui::_Control& control);
104 _Control* GetControl(void) const;
106 void SetUserData(void* pUserData);
107 void* GetUserData(void) const;
109 void SetDelegate(const _ITouchGestureDelegate& delegator);
110 _ITouchGestureDelegate* GetDelegate(void) const;
112 bool IsSentDelayedEvent(void) const;
113 void SetSentDelayedEvent(bool sent);
114 bool IsSendingDelayedEvent(void) const;
116 void AddTouchInfo(const _TouchInfo& touchInfo);
117 void ClearTouchInfo(void);
119 void SetGestureStart(bool start);
120 bool IsGestureStarted(void) const;
122 virtual bool OnTouchPressed(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
123 virtual bool OnTouchMoved(const Tizen::Ui:: _Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
124 virtual bool OnTouchReleased(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
125 virtual bool OnTouchCanceled(const Tizen::Ui::_Control& source, const Tizen::Ui::_TouchInfo& touchinfo);
127 virtual void OnGestureDetectorStateChanged(const _TouchGestureDetector& gestureDetector);
129 void ProcessPublicListener(_TouchGestureDetector& gesture);
130 void ProcessCoreListener(_TouchGestureDetector& gesture);
132 Tizen::Base::String GetDescription(void);
135 Tizen::Base::Collection::IListT <_TouchGestureDetector*>* GetWantToFailList(void) const;
136 Tizen::Base::Collection::IListT <_TouchGestureDetector*>* GetCurrentWantToFailList(void) const;
137 bool ExistWaitingList(void) const;
138 void NotifyStateChanged(void);
139 Tizen::Base::Collection::IListT<_TouchInfo*>* GetTouchInfoList(void);
140 bool IsPossibleToAddFailList(const _TouchGestureDetector& gesture);
141 void SetToDefaultState(void);
142 _TouchGestureDetectorEventType GetGestureDetectorEventType(void);
143 void SendDelayedTouchEvent(_Control* pControl);
144 void ProcessGestureCondition(void);
146 _TouchGestureDetector(const _TouchGestureDetector&);
147 _TouchGestureDetector& operator =(const _TouchGestureDetector&);
150 bool __isTouchEventDelayed;
151 bool __isTouchCanceledOnSuccess;
152 bool __isDetectionStarted;
153 _TouchGestureDetectorState __currentState;
154 _TouchGestureDetectorType __type;
155 _ControlHandle __gestureContol;
157 _ITouchGestureDelegate* __pDelegator;
158 Tizen::Base::Collection::IListT <_TouchGestureDetector*>* __pWantToFailList;
159 Tizen::Base::Collection::IListT <_TouchGestureDetector*>* __pCurrentWantToFailList;
160 Tizen::Base::Collection::IListT <Tizen::Ui::_ITouchGestureEventListener*>* __pEventListenerList;
161 }; // _TouchGestureDetector
165 #endif //_FUI_INTERNAL_TOUCH_GESTURE_DETECTOR_H_