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 "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: Gesture and physics helper declaration |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "tseventcontroler.h" |
|
19 #include "tsphysicsengine.h" |
|
20 |
|
21 // ----------------------------------------------------------------------------- |
|
22 // NewLC |
|
23 // ----------------------------------------------------------------------------- |
|
24 // |
|
25 CTsEventControler* CTsEventControler::NewLC( |
|
26 MTsEventControlerObserver& aObserver, |
|
27 CCoeControl& aEventSrc) |
|
28 { |
|
29 CTsEventControler* self = |
|
30 new(ELeave)CTsEventControler(aObserver); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(aEventSrc); |
|
33 return self; |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // NewL |
|
38 // ----------------------------------------------------------------------------- |
|
39 // |
|
40 CTsEventControler* CTsEventControler::NewL( |
|
41 MTsEventControlerObserver& aObserver, |
|
42 CCoeControl& aEventSrc) |
|
43 { |
|
44 CTsEventControler* self = |
|
45 CTsEventControler::NewLC(aObserver, aEventSrc); |
|
46 CleanupStack::Pop(self); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // ~CTsPointerHandler |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 CTsEventControler::~CTsEventControler() |
|
55 { |
|
56 delete iGestureHelper; |
|
57 delete iPhysicsHelper; |
|
58 } |
|
59 |
|
60 // ----------------------------------------------------------------------------- |
|
61 // CTsPointerHandler |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 CTsEventControler::CTsEventControler( |
|
65 MTsEventControlerObserver& aObserver) |
|
66 : |
|
67 CBase(), |
|
68 iObserver(aObserver) |
|
69 { |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // ConstructL |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 void CTsEventControler::ConstructL(CCoeControl& aEventSrc) |
|
77 { |
|
78 iGestureHelper = |
|
79 AknTouchGestureFw::CAknTouchGestureFw::NewL(*this, aEventSrc); |
|
80 iGestureHelper->SetGestureInterestL(EAknTouchGestureFwAll); |
|
81 iPhysicsHelper = CTsPhysicsEngine::NewL(*this, aEventSrc); |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // HandleTouchGestureL |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 void CTsEventControler::HandleTouchGestureL( |
|
89 AknTouchGestureFw::MAknTouchGestureFwEvent& aEvent) |
|
90 { |
|
91 if (AknTouchGestureFwEventDrag(aEvent)) |
|
92 { |
|
93 HandleDragEventL(*AknTouchGestureFwEventDrag(aEvent)); |
|
94 } |
|
95 else if (AknTouchGestureFwEventTap(aEvent)) |
|
96 { |
|
97 HandleTapEventL(*AknTouchGestureFwEventTap(aEvent)); |
|
98 } |
|
99 //ignore flick and pinch events |
|
100 } |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // HandleTapEventL |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 void CTsEventControler::HandleTapEventL( |
|
107 MAknTouchGestureFwTapEvent& aEvent) |
|
108 { |
|
109 if(EAknTouchGestureFwLongTap == aEvent.Type()) |
|
110 { |
|
111 iObserver.LongTapL(aEvent.Position()); |
|
112 } |
|
113 else if(EAknTouchGestureFwTap == aEvent.Type()) |
|
114 { |
|
115 if( iPhysicsHelper->IsRunning()) |
|
116 { |
|
117 iPhysicsHelper->Stop(); |
|
118 } |
|
119 else |
|
120 { |
|
121 iObserver.TapL(aEvent.Position()); |
|
122 } |
|
123 } |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // HandleDragEventL |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 void CTsEventControler::HandleDragEventL( |
|
131 MAknTouchGestureFwDragEvent& aEvent) |
|
132 { |
|
133 iObserver.Drag(aEvent); |
|
134 iPhysicsHelper->HandleDragEvent(aEvent); |
|
135 } |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // PhysicEmulationEnded |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 void CTsEventControler::ViewPositionChanged(const TPoint& aNewPosition, |
|
142 TBool /*aDrawNow*/, |
|
143 TUint /*aFlags*/) |
|
144 { |
|
145 iObserver.MoveOffset(aNewPosition); |
|
146 } |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // PhysicEmulationEnded |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CTsEventControler::PhysicEmulationEnded() |
|
153 { |
|
154 iObserver.Stop(); |
|
155 } |
|
156 |
|
157 // ----------------------------------------------------------------------------- |
|
158 // ViewPosition |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 TPoint CTsEventControler::ViewPosition() const |
|
162 { |
|
163 return iObserver.ViewPos(); |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // Animate |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CTsEventControler::Animate(const TPoint& aPoint) |
|
171 { |
|
172 iPhysicsHelper->AnimateToTarget(aPoint); |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // ReInitPhysicL |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 void CTsEventControler::ReInitPhysicsL(const TSize& aWorldSize, |
|
180 const TSize& aViewSize, TBool aLandscape) |
|
181 { |
|
182 iPhysicsHelper->ReInitPhysicsL( aWorldSize, aViewSize, aLandscape); |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // StopAnimation |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 void CTsEventControler::StopAnimation() |
|
190 { |
|
191 iPhysicsHelper->Stop(); |
|
192 } |
|
193 |
|
194 // end of file |
|