1 /* |
|
2 * ============================================================================ |
|
3 * Name : hgteleporteventcontroler.cpp |
|
4 * Part of : Hg Teleport |
|
5 * Description : Gesture and physics helper declaration |
|
6 * Version : %version: 5 % |
|
7 * |
|
8 * Copyright © 2008 Nokia. All rights reserved. |
|
9 * This material, including documentation and any related computer |
|
10 * programs, is protected by copyright controlled by Nokia. All |
|
11 * rights are reserved. Copying, including reproducing, storing, |
|
12 * adapting or translating, any or all of this material requires the |
|
13 * prior written consent of Nokia. This material also contains |
|
14 * confidential information which may not be disclosed to others |
|
15 * without the prior written consent of Nokia. |
|
16 * ============================================================================ |
|
17 * |
|
18 */ |
|
19 #include "hgteleporteventcontroler.h" |
|
20 #include "hgteleportphysicsengine.h" |
|
21 |
|
22 // ----------------------------------------------------------------------------- |
|
23 // NewLC |
|
24 // ----------------------------------------------------------------------------- |
|
25 // |
|
26 CHgTeleportEventControler* CHgTeleportEventControler::NewLC( |
|
27 MHgTeleportEventControlerObserver& aObserver, |
|
28 CCoeControl& aEventSrc) |
|
29 { |
|
30 CHgTeleportEventControler* self = |
|
31 new(ELeave)CHgTeleportEventControler(aObserver); |
|
32 CleanupStack::PushL(self); |
|
33 self->ConstructL(aEventSrc); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // NewL |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CHgTeleportEventControler* CHgTeleportEventControler::NewL( |
|
42 MHgTeleportEventControlerObserver& aObserver, |
|
43 CCoeControl& aEventSrc) |
|
44 { |
|
45 CHgTeleportEventControler* self = |
|
46 CHgTeleportEventControler::NewLC(aObserver, aEventSrc); |
|
47 CleanupStack::Pop(self); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // ~CHgTeleportPointerHandler |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CHgTeleportEventControler::~CHgTeleportEventControler() |
|
56 { |
|
57 delete iGestureHelper; |
|
58 delete iPhysicsHelper; |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CHgTeleportPointerHandler |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CHgTeleportEventControler::CHgTeleportEventControler( |
|
66 MHgTeleportEventControlerObserver& aObserver) |
|
67 : |
|
68 CBase(), |
|
69 iObserver(aObserver) |
|
70 { |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CHgTeleportEventControler::ConstructL(CCoeControl& aEventSrc) |
|
78 { |
|
79 iGestureHelper = |
|
80 AknTouchGestureFw::CAknTouchGestureFw::NewL(*this, aEventSrc); |
|
81 iGestureHelper->SetGestureInterestL(EAknTouchGestureFwAll); |
|
82 iPhysicsHelper = CHgTeleportPhysicsEngine::NewL(*this, aEventSrc); |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // HandleTouchGestureL |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void CHgTeleportEventControler::HandleTouchGestureL( |
|
90 AknTouchGestureFw::MAknTouchGestureFwEvent& aEvent) |
|
91 { |
|
92 if (AknTouchGestureFwEventDrag(aEvent)) |
|
93 { |
|
94 HandleDragEventL(*AknTouchGestureFwEventDrag(aEvent)); |
|
95 } |
|
96 else if (AknTouchGestureFwEventTap(aEvent)) |
|
97 { |
|
98 HandleTapEventL(*AknTouchGestureFwEventTap(aEvent)); |
|
99 } |
|
100 //ignore flick and pinch events |
|
101 } |
|
102 |
|
103 // ----------------------------------------------------------------------------- |
|
104 // HandleTapEventL |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 void CHgTeleportEventControler::HandleTapEventL( |
|
108 MAknTouchGestureFwTapEvent& aEvent) |
|
109 { |
|
110 if(EAknTouchGestureFwLongTap == aEvent.Type()) |
|
111 { |
|
112 iObserver.LongTapL(aEvent.Position()); |
|
113 } |
|
114 else if(EAknTouchGestureFwTap == aEvent.Type()) |
|
115 { |
|
116 if( iPhysicsHelper->IsRunning()) |
|
117 { |
|
118 iPhysicsHelper->Stop(); |
|
119 } |
|
120 else |
|
121 { |
|
122 iObserver.TapL(aEvent.Position()); |
|
123 } |
|
124 } |
|
125 } |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // HandleDragEventL |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CHgTeleportEventControler::HandleDragEventL( |
|
132 MAknTouchGestureFwDragEvent& aEvent) |
|
133 { |
|
134 iObserver.Drag(aEvent); |
|
135 iPhysicsHelper->HandleDragEvent(aEvent); |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // PhysicEmulationEnded |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 void CHgTeleportEventControler::ViewPositionChanged(const TPoint& aNewPosition, |
|
143 TBool /*aDrawNow*/, |
|
144 TUint /*aFlags*/) |
|
145 { |
|
146 iObserver.MoveOffset(aNewPosition); |
|
147 } |
|
148 |
|
149 // ----------------------------------------------------------------------------- |
|
150 // PhysicEmulationEnded |
|
151 // ----------------------------------------------------------------------------- |
|
152 // |
|
153 void CHgTeleportEventControler::PhysicEmulationEnded() |
|
154 { |
|
155 iObserver.Stop(); |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // ViewPosition |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 TPoint CHgTeleportEventControler::ViewPosition() const |
|
163 { |
|
164 return iObserver.ViewPos(); |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // Animate |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CHgTeleportEventControler::Animate(const TPoint& aPoint) |
|
172 { |
|
173 iPhysicsHelper->AnimateToTarget(aPoint); |
|
174 } |
|
175 |
|
176 // ----------------------------------------------------------------------------- |
|
177 // ReInitPhysicL |
|
178 // ----------------------------------------------------------------------------- |
|
179 // |
|
180 void CHgTeleportEventControler::ReInitPhysicsL(const TSize& aWorldSize, |
|
181 const TSize& aViewSize, TBool aLandscape) |
|
182 { |
|
183 iPhysicsHelper->ReInitPhysicsL( aWorldSize, aViewSize, aLandscape); |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // StopAnimation |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 void CHgTeleportEventControler::StopAnimation() |
|
191 { |
|
192 iPhysicsHelper->Stop(); |
|
193 } |
|
194 |
|
195 // end of file |
|