Tizen 2.1 base
[framework/osp/uifw.git] / src / ui / inc / FUi_TouchManager.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://floralicense.org/license/
10 //
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.
16 //
17 /**
18  * @file                        FUi_TouchManager.h
19  * @brief               This is the header file for the _TouchManager class.
20  *
21  * This header file contains the declarations of the _TouchManager class. @n
22  */
23
24 #ifndef _FUI_INTERNAL_TOUCH_MANAGER_H_
25 #define _FUI_INTERNAL_TOUCH_MANAGER_H_
26
27 #include "FUi_ControlImpl.h"
28 #include "FUi_FingerInfo.h"
29
30 namespace Tizen { namespace Base { namespace Collection {
31 template<class T> class IListT;
32 template<class KeyType, class ValueType> class HashMapT;
33 }}}
34
35 namespace Tizen { namespace Ui
36 {
37
38 class _MultiFingerInfo
39 {
40 public:
41         /**
42         * This is the default class constructor.
43         *
44         */
45         _MultiFingerInfo(void);
46
47         /**
48          * This is the default class destructor.
49          *
50          */
51         ~_MultiFingerInfo(void);
52
53 public:
54         /**
55          * This method returns point id.
56          *
57          * @since 2.0
58          * @return      The point Id
59          */
60         unsigned long GetPointId(unsigned long deviceId) const;
61
62         /**
63          * This method returns current cursor id.
64          *
65          * @since 2.0
66          * @return      The cursor Id
67          */
68         unsigned long GetCurrentPointId(void) const;
69
70         /**
71          * This method convert efl point id to cursor id.
72          *
73          * @since 2.0
74          * @return      The cursor Id
75          */
76         unsigned long GeneratePointId(unsigned long deviceId);
77
78         /**
79          * This method returns the touch position of specific pointId.
80          *
81          * @since 2.0
82          * @return      The touch position
83          */
84         Tizen::Graphics::Point GetPosition(unsigned long id) const;
85
86         /**
87          * This method returns the touch position of specific pointId.
88          *
89          * @since 2.0
90          * @return      The touch position
91          */
92         Tizen::Graphics::Point GetScreenPoint(unsigned long id) const;
93
94         /**
95          * This method returns the touch status of specific pointId.
96          *
97          * @since 2.0
98          * @return      The touch status
99          */
100         _TouchStatus GetStatus(unsigned long id) const;
101
102         /**
103          * This method returns the touch start position.
104          *
105          * @since 2.0
106          * @return      The touch start position
107          */
108         Tizen::Graphics::Point GetStartPoint(unsigned long id) const;
109
110         /**
111          * This method returns the touch count
112          *
113          * @since 2.0
114          * @return              The touch count
115          */
116         int GetPointCount(void) const;
117
118         /**
119          * This method returns the touch info list.
120          *
121          * @since 2.0
122          * @return      The touch info list
123          */
124         Tizen::Base::Collection::IListT<_FingerInfo*>* GetMultiFingerListN(void) const;
125
126         /**
127          * This method sets current finger info
128          *
129          * @since 2.0
130          */
131         result SetFingerInfo(unsigned long pointId, const Tizen::Graphics::Point& point, const Tizen::Graphics::Point& screenPoint, _TouchStatus status);
132
133         /**
134          * This method resets finger info
135          *
136          * @since 2.0
137          */
138         void ResetFingerInfo(void);
139
140 private:
141         /**
142          * This method initializes finger information
143          *
144          * @since 2.0
145          * @return
146          */
147         void InitializeFingerInfo(void);
148
149         /**
150          * This method remove finger informations
151          *
152          * @since 2.0
153          * @return
154          */
155         void RemoveFingerInfoList(void);
156
157         /*
158          * This is the copy constructor for this class.
159          */
160         _MultiFingerInfo(const _MultiFingerInfo&);
161
162         /**
163          * This is the assignment operator for this class.
164          */
165         _MultiFingerInfo& operator =(const _MultiFingerInfo&);
166
167 private:
168         unsigned long __currentPointId;
169         unsigned long __generatedPointId;
170         int __pointCount;
171         Tizen::Base::Collection::HashMapT<int, _FingerInfo*>* __pFingerInfoMap;
172 }; //_MultiFingerInfo
173
174 class _Control;
175 class _TouchEventArg;
176 class _ITouchEventListener;
177
178 class _OSP_EXPORT_ _TouchManager
179 {
180 public:
181         static void Initialize(void);
182         static _TouchManager* GetInstance(void);
183
184 public:
185         /**
186          * This method adds current position to multi touch list
187          *
188          * @since 2.0
189          * @return
190          */
191         result AddPoint(unsigned long pointId, const Tizen::Graphics::Point& point, _TouchStatus status);
192
193         /**
194          * This method returns the touch point count.
195          *
196          * @since 2.0
197          * @return              The touch point count
198          */
199         int GetPointCount(void) const;
200
201         /**
202          * This method returns the touch position.
203          *
204          * @since 2.0
205          * @return              The touch position
206          */
207         Tizen::Graphics::Point GetScreenPoint(unsigned long id) const;
208
209         /**
210          * This method returns the touch position.
211          *
212          * @since 2.0
213          * @return              The touch position
214          */
215         Tizen::Graphics::Point GetPosition(unsigned long id) const;
216
217         /**
218          * This method returns the touch status of specific pointId.
219          *
220          * @since 2.0
221          * @return              The touch status
222          */
223         TouchStatus GetTouchStatus(unsigned long id) const;
224
225         /**
226          * This method converts device id to point id.
227          *
228          * @since 2.0
229          * @return              The point Id
230          */
231         unsigned long GetPointId(unsigned long deviceId) const;
232
233         /**
234          * This method generates pointId.
235          *
236          * @since 2.0
237          * @return              The point Id
238          */
239         unsigned long GeneratePointId(unsigned long deviceId) const;
240
241         /**
242          * This method returns the current pointId for multi touch
243          *
244          * @since 2.0
245          * @return              The point Id
246          */
247         unsigned long GetCurrentPointId(void) const;
248
249         /**
250          * This method returns touch start point
251          *
252          * @since 2.0
253          * @return              The touch start point(means touch pressed point)
254          */
255         Tizen::Graphics::Point GetStartPoint(unsigned long pointId) const;
256
257         /**
258          * This method makes touch event and send touch event through event manager
259          *
260          * @since 2.0
261          */
262         result SendEvent(_Control* pControl, const _TouchInfo& touchInfo);
263
264         /**
265          * This method sets touch cancelled status
266          *
267          * @since 2.0
268          */
269         void SetTouchCanceled(bool canceled, bool onlyTouchEvent = false);;
270
271         /**
272          * This method sets touch allowed status
273          *
274          * @since 2.0
275          */
276         void SetTouchAllowed(bool allowed);
277
278         /**
279          * This method returns touch allowed status
280          *
281          * @since 2.0
282          * @return              touch allowed status
283          */
284         bool IsTouchAllowed(void);
285
286         /**
287          * This method returns touch move allowed status
288          * Whenever starting touch move, checking this value if it allows to move.
289          *
290          * @since 2.0
291          * @return              touch move allowed status
292          */
293          bool IsInTouchMoveAllowanceBounds(const _Control& source, const _TouchInfo& touchInfo);
294
295         /**
296          * This method sets the touch control source. - common control of focus, drag.
297          * It's the control touch press occurred.
298          *
299          * @since 2.0
300          */
301         void SetTouchControlSource(const _Control& source);
302
303         /**
304          * This method returns the touch control source,
305          *
306          * @since 2.0
307          * @return      The first touched control source
308          */
309         _Control* GetTouchControlSource(void) const;
310
311         /**
312          * This method sets the touch focused control source. - common control of focus, drag.
313          * It's the control touch press occurred.
314          *
315          * @since 2.0
316          */
317         void SetFocusedControlSource(const _Control& source);
318
319         /**
320          * This method returns the touch focused control source,
321          *
322          * @since 2.0
323          * @return      The first touched control source
324          */
325         _Control* GetFocusedControlSource(void) const;
326
327         /**
328          * This method sets touch captured control
329          * If you set the captured control, all touch events are sent to captured control.
330          *
331          * @since 2.0
332          */
333         void SetCapturedControl(const _Control* pControl, bool allowOutOfBounds);
334
335         /**
336          * This method returns touch captured control
337          *
338          * @since 2.0
339          * @return      The captured control
340          */
341         _Control* GetCapturedControl(void) const;
342
343         bool IsCaptureAllowedOutOfBounds(void) const;
344
345         /**
346         * This method resets touch information, point count and cursorID etc.
347         *
348         * @since 2.0
349         */
350         void ResetTouchInfo(void);
351
352         /**
353         * This method sets touch is canceled by gesture success.
354         *
355         * @since 2.0
356         */
357         void SetTouchCanceledOnGestureSuccess(bool cancel);
358
359         /**
360         * This method returns whether touch is canceled on gesture success.
361         *
362         * @since 2.0
363         */
364         bool IsTouchCanceledOnGestureSuccess(void) const;
365
366         Tizen::Base::Collection::IListT<_FingerInfo*>* GetMultiFingerInfoListN(void) const;
367
368         bool IsSendingDelayedEvent(void) const;
369
370         static void ReleaseInstance(void);
371
372 private:
373         /**
374         * This is the default class constructor.
375         *
376         */
377         _TouchManager(void);
378
379         /**
380          * This is the default class destructor.
381          *
382          */
383         ~_TouchManager(void);
384
385         /*
386          * This is the copy constructor for this class.
387          */
388         _TouchManager(const _TouchManager&);
389
390         /**
391          * This is the assignment operator for this class.
392          */
393         _TouchManager& operator =(const _TouchManager&);
394
395         static void InitializeInstance(void);
396
397 private:
398         static _TouchManager* __pInstance;
399         _MultiFingerInfo* __pMultiFingerInfo;
400         _ControlHandle __touchControlHandle;
401         _ControlHandle __capturedControlHandle;
402         _ControlHandle __focusedControlHandle;
403         bool __touchCanceled;
404         bool __touchAllowed;
405         _ITouchEventListener* __pTouchEventListener;
406         bool __captureAllowOutOfBounds; //will be deleted
407         bool __isSendingDelayedEvent;
408         bool __touchCanceledOnGestureSuccess;
409 }; // _TouchManager
410
411 } } // Tizen::Ui
412
413 #endif // _FUI_INTERNAL_TOUCH_MANAGER_H_