|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the License "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef GESTUREENGINE_H_ |
|
19 #define GESTUREENGINE_H_ |
|
20 |
|
21 #include <coemain.h> |
|
22 #include <e32property.h> |
|
23 #include <w32std.h> |
|
24 |
|
25 #include "rt_gestureengineif.h" |
|
26 #include "rt_uievent.h" |
|
27 |
|
28 namespace stmGesture |
|
29 { |
|
30 |
|
31 /*! |
|
32 * CGEstureEngine handles the processing of the UI events. |
|
33 * It acts as a stmUiEventEngine::MUiEventObserver to receive the UI events. |
|
34 * The gesture recognisers are stored in a list, and at each HandleUiEventL the |
|
35 * list of gesture recognisers is processed. The first one to return EGestureActive |
|
36 * from the recognise method "owns" the gesture. If some other recogniser owned it |
|
37 * previously, its release method is called. Gesture recogniser can also lock the gesture |
|
38 * by returning ELockToThisGesture. Then only that gesture recogniser will be called |
|
39 * until release is detected or the recogniser returns something else than ELockToThisGesture. |
|
40 */ |
|
41 NONSHARABLE_CLASS( CGestureEngine ): public CBase, |
|
42 public MGestureEngineIf, |
|
43 public stmUiEventEngine::MUiEventObserver |
|
44 { |
|
45 public: |
|
46 CGestureEngine(); |
|
47 virtual ~CGestureEngine(); |
|
48 |
|
49 /*! |
|
50 * add gesture to the end of the list of gestures |
|
51 */ |
|
52 virtual bool addGesture(const MGestureRecogniserIf* aNewGesture) ; |
|
53 /*! |
|
54 * inset a gesture to the beginning of the list of gestures |
|
55 */ |
|
56 virtual bool insertGesture(const MGestureRecogniserIf* aNewGesture) ; |
|
57 /*! |
|
58 * inset a gesture to the specific position |
|
59 */ |
|
60 virtual bool insertGestureAt(const MGestureRecogniserIf* aNewGesture, int position) ; |
|
61 /*! |
|
62 * remove a gesture from the list |
|
63 */ |
|
64 virtual bool removeGesture(const MGestureRecogniserIf* aOldGesture) ; |
|
65 /*! |
|
66 * get the number of non-empty event streams. |
|
67 * Event streams correspond UI events generated by one touch pointer (=finger). |
|
68 * The low level state machine handles the necessary filtering etc. |
|
69 * so that it is safe to remove the event stream after UI Release event has been processed. |
|
70 */ |
|
71 virtual int activeStreamCount() const ; |
|
72 /*! |
|
73 * get the UI events of stream X |
|
74 * \param indexOfActiveStream defines which active stream is used. |
|
75 * Note that MUiEvent contains all the events from down up to the current event. |
|
76 * Assumption: the UI events contain the target "window handle", i.e. |
|
77 * the gesture recognition needs to be aware of all possible windows of the application. |
|
78 */ |
|
79 virtual const stmUiEventEngine::MUiEvent* getUiEvents(int indexOfActiveStream) const ; |
|
80 /*! |
|
81 * enable/disable logging |
|
82 */ |
|
83 virtual void enableLogging(bool aLoggingEnabled) {m_loggingEnabled = aLoggingEnabled;} ; |
|
84 /*! |
|
85 * The stmUiEventEngine::MUiEventObserver interface |
|
86 */ |
|
87 virtual void HandleUiEventL( const stmUiEventEngine::MUiEvent& aEvent ) ; |
|
88 private: |
|
89 /*! |
|
90 * The list of available gesture recognisers |
|
91 */ |
|
92 RPointerArray< MGestureRecogniserIf > m_gestures; |
|
93 /*! |
|
94 * Is 5 UI event streams enough? Jos tulee Torvisen voittaja? |
|
95 * We need to store only the latest event since the interface has |
|
96 * methods to walk trough the events. The current (sept 2009) 9.2 seems to have dual-touch support |
|
97 */ |
|
98 const stmUiEventEngine::MUiEvent* m_uiEventStream[stmUiEventEngine::KMaxNumberOfPointers] ; |
|
99 |
|
100 void storeUiEvent(const stmUiEventEngine::MUiEvent& aEvent) ; |
|
101 void walkTroughGestures() ; |
|
102 void updateUiEvents() ; |
|
103 int m_numOfActiveStreams ; |
|
104 int m_currentGestureOwner ; |
|
105 int m_currentLockedGesture ; |
|
106 bool m_loggingEnabled ; |
|
107 }; |
|
108 |
|
109 } |
|
110 |
|
111 #endif /* GESTUREENGINE_H_ */ |