60
|
1 |
/*
|
|
2 |
* Copyright (c) 2008-2009 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: Zoom Event Handler
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
#ifndef GLXZOOMEVENTHANDLER_H_
|
|
19 |
#define GLXZOOMEVENTHANDLER_H_
|
|
20 |
|
|
21 |
#include "glxzoomview.hrh"
|
|
22 |
#include "glxfullscreenview.hrh"
|
|
23 |
#include "glxzoommathsengine.h"
|
|
24 |
|
|
25 |
//Alf Headers
|
|
26 |
#include <alf/alfevent.h> // For Key Events
|
|
27 |
#include <alf/alftimedvalue.h> // for TAlfRealPoint
|
|
28 |
#include <alf/alftypes.h>
|
|
29 |
|
|
30 |
#include <alf/alftypes.h>
|
|
31 |
#include <gesturehelper.h>
|
|
32 |
#include <gestureobserver.h>
|
|
33 |
|
|
34 |
// FORWARD DECLARATIONS
|
|
35 |
class CGlxZoomControl;
|
|
36 |
class TGlxZoomAndPanMathsEngine;
|
|
37 |
class MGlxZoomEventHandlers;
|
|
38 |
|
|
39 |
class CGlxZoomPanEventHandler : public CBase
|
|
40 |
{
|
|
41 |
public:
|
|
42 |
/**
|
|
43 |
* Two-phased constructor.
|
|
44 |
* @param aZoomEventHandler: Handler for ZoomControl commands.
|
|
45 |
*/
|
|
46 |
static CGlxZoomPanEventHandler* NewL(MGlxZoomEventHandlers& aZoomEventHandler );
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Destructor.
|
|
50 |
*/
|
|
51 |
~CGlxZoomPanEventHandler();
|
|
52 |
|
|
53 |
/**
|
|
54 |
* Two stop shop to handle all alf events. [PRASH] Make this a one stop shop
|
|
55 |
*/
|
|
56 |
TBool HandleEventL(const TAlfEvent &aEvent );
|
|
57 |
|
|
58 |
TBool HandleEvent( const TAlfEvent& aEvent );
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Cancel the timer for continous zooming
|
|
62 |
*/
|
|
63 |
void CancelZoomPanTimer();
|
|
64 |
|
|
65 |
void CancelAnimationTimer();
|
|
66 |
|
|
67 |
/**
|
|
68 |
* Stops the timer for showing the UI.
|
|
69 |
*/
|
|
70 |
void CancelUITimer();
|
|
71 |
|
|
72 |
/*
|
|
73 |
* ActivateZoom from the Zoom control
|
|
74 |
*/
|
|
75 |
void ActivateZoom( TInt aInitialZoomRatio,
|
|
76 |
TSize imageSize,
|
|
77 |
TZoomStartMode aStartMode,
|
|
78 |
TInt aMinZoomRatio,
|
|
79 |
TInt aMaxZoomRatio,
|
|
80 |
TPoint* aZoomFocus);
|
|
81 |
|
|
82 |
/*
|
|
83 |
* DeactivateZoom from the Zoom control
|
|
84 |
*/
|
|
85 |
void DeactivateZoom();
|
|
86 |
|
|
87 |
/*
|
|
88 |
* OrientationChanged
|
|
89 |
*/
|
|
90 |
void OrientationChanged(const TRect& aNewScreenRect) ;
|
|
91 |
|
|
92 |
/*
|
|
93 |
* ZoomIsActivated
|
|
94 |
* This is called when the zoom is activated/deactivated from Zoom control
|
|
95 |
*/
|
|
96 |
void SetZoomActivated(TBool aIsActivated = EFalse);
|
|
97 |
|
|
98 |
/*
|
|
99 |
* ZoomUiState
|
|
100 |
* This is called when the zoom state in Zoom control is changed
|
|
101 |
*/
|
|
102 |
void SetZoomUiState(TUiState aZoomUiState);
|
|
103 |
|
|
104 |
/*
|
|
105 |
* ZoomUiState
|
|
106 |
* This is called when the zoom state in Zoom control is changed
|
|
107 |
*/
|
|
108 |
TUiState ZoomUiState();
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Handle the drag events for panning
|
|
112 |
*/
|
|
113 |
void HandleDragEvent(const GestureHelper::MGestureEvent& aEvent );
|
|
114 |
|
|
115 |
/**
|
|
116 |
* Handle the Pinch events for panning
|
|
117 |
*/
|
|
118 |
void HandlePinchEventL(const GestureHelper::MGestureEvent& aEvent);
|
|
119 |
|
|
120 |
/**
|
|
121 |
* Handle the Double Tap events for panning
|
|
122 |
*/
|
|
123 |
void HandleDoubleTap(const GestureHelper::MGestureEvent& aEvent );
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Handle the Single Tap events for panning
|
|
127 |
*/
|
|
128 |
void HandleSingleTap(const GestureHelper::MGestureEvent& aEvent );
|
|
129 |
|
|
130 |
/**
|
|
131 |
* Handle the Gesture Released events for panning
|
|
132 |
*/
|
|
133 |
void HandleGestureReleased(const GestureHelper::MGestureEvent& aEvent );
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Remembers the previous events code.
|
|
137 |
*/
|
|
138 |
void SetPreviousEventCode(const GestureHelper::TGestureCode code );
|
|
139 |
|
|
140 |
/**
|
|
141 |
* Handle a multitouch gesture released event.
|
|
142 |
*/
|
|
143 |
void HandleMultiTouchReleased();
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Bring back zoom state to minimum.
|
|
147 |
*/
|
|
148 |
void ZoomToMinimumL();
|
|
149 |
|
|
150 |
private:
|
|
151 |
/*
|
|
152 |
* Constructor
|
|
153 |
*/
|
|
154 |
CGlxZoomPanEventHandler(MGlxZoomEventHandlers& aZoomEventHandler);
|
|
155 |
|
|
156 |
/*
|
|
157 |
* ConstructL
|
|
158 |
*/
|
|
159 |
void ConstructL();
|
|
160 |
|
|
161 |
/**
|
|
162 |
* This Function handles all the KeyEvents
|
|
163 |
*/
|
|
164 |
TBool HandlekeyEvents(const TAlfEvent &aEvent);
|
|
165 |
|
|
166 |
/**
|
|
167 |
* Callback function for pan
|
|
168 |
*/
|
|
169 |
static TInt PanIntervalExpired(TAny* aPtr);
|
|
170 |
|
|
171 |
// Zoom by the next zoom increment.
|
|
172 |
// aZoomMode is ignored if aExpectedZoomLevel has a positive value
|
|
173 |
void Zoom(TInt aExpectedZoomLevel, TInt aRelativeZoomFactor, TZoomMode aZoomMode = EZoomIn, TPoint* aZoomFocus = NULL);
|
|
174 |
/**
|
|
175 |
* Start Panning continously
|
|
176 |
*/
|
|
177 |
void DoPan();
|
|
178 |
|
|
179 |
/**
|
|
180 |
* Starts the timer for continous Panning
|
|
181 |
*/
|
|
182 |
void StartPanTimer();
|
|
183 |
|
|
184 |
|
|
185 |
/**
|
|
186 |
* Starts the timer for showing the UI.
|
|
187 |
*/
|
|
188 |
void StartUITimer(TTimeIntervalMicroSeconds32 aDelay,
|
|
189 |
TTimeIntervalMicroSeconds32 anInterval,
|
|
190 |
TCallBack aCallBack) ;
|
|
191 |
|
|
192 |
/**
|
|
193 |
*Call back function to Turn off UI/Screen Furniture[Back Key/Slider].
|
|
194 |
*/
|
|
195 |
static TInt UiTimeOut(TAny* aSelf);
|
|
196 |
|
|
197 |
/*
|
|
198 |
* Timer callback for zoomout
|
|
199 |
*/
|
|
200 |
static TInt ZoomOutTimerL(TAny* aSelf);
|
|
201 |
|
|
202 |
/**
|
|
203 |
* Handle the key events for panning
|
|
204 |
* @param aPanDirection: Specifies the pan direction
|
|
205 |
* @param aEvent : Specifies the event values.
|
|
206 |
*/
|
|
207 |
TBool HandlePanKey(const TAlfEvent &aEvent);
|
|
208 |
|
|
209 |
/**
|
|
210 |
* Handle zoom key pressed.
|
|
211 |
* @param aZoomIn :ETrue for Zoom In key, EFalse for Zoom Out key
|
|
212 |
* @param aEventCode :Type of key event.
|
|
213 |
*/
|
|
214 |
void HandleZoomKey(TZoomMode aZoomMode ,TEventCode aEventCode);
|
|
215 |
|
|
216 |
/**
|
|
217 |
* Handle the drag events for panning
|
|
218 |
*/
|
|
219 |
void HandleDragEvent(const TPoint &aTapPoint);
|
|
220 |
|
|
221 |
/*
|
|
222 |
* ShowSliderTillTimeout
|
|
223 |
*/
|
|
224 |
void ShowSliderTillTimeout() ;
|
|
225 |
|
|
226 |
/*
|
|
227 |
* ShowScreenFurniture
|
|
228 |
* aTimeout == 0 means no timeout.
|
|
229 |
*/
|
|
230 |
void ShowScreenFurniture(TTimeIntervalMicroSeconds32 aTimeout);
|
|
231 |
|
|
232 |
/*
|
|
233 |
* HideScreenFurniture
|
|
234 |
*/
|
|
235 |
void HideScreenFurniture();
|
|
236 |
|
|
237 |
/*
|
|
238 |
* SetupPanOperation
|
|
239 |
*/
|
|
240 |
void SetupPanOperation(TPoint& aPanDirection);
|
|
241 |
|
|
242 |
void CallZoomOutL();
|
|
243 |
|
|
244 |
void SetupAnimatedZoom(TZoomMode aZoomMode, TPoint * aZoomFocus = NULL);
|
|
245 |
|
|
246 |
static TInt ActivationIntervalElapsed(TAny* aPtr) ;
|
|
247 |
|
|
248 |
void NextStepAnimatedZoom();
|
|
249 |
|
|
250 |
void SetupAnimatedPan() ;
|
|
251 |
|
|
252 |
static TInt PanInertiaFrameElapsed(TAny* aPtr);
|
|
253 |
|
|
254 |
void NextStepInerticPan();
|
|
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
259 |
private:
|
|
260 |
MGlxZoomEventHandlers& iZoomEventHandler;
|
|
261 |
|
|
262 |
TTime iPanTime; // The Purpose of this Variable is to determine the Time,for how long the key was held
|
|
263 |
TZoomMode iZoomMode; // Says whether we are zooming in or out.
|
|
264 |
TPoint iPanDirection; // This gives the direction of the panning that has to be done
|
|
265 |
TInt iMinZoomRatio; // The minimum value that the Zoom Slider will have
|
|
266 |
TInt iMaxZoomRatio; // The maximum value that the Zoom Slider will have
|
|
267 |
|
|
268 |
CPeriodic* iUiTimer; // The Timer used to Hide the UI/Screen Furniture[Back Key/Slider] after 2 seconds
|
|
269 |
CPeriodic* iZoomPanTimer; // The Timer used for Zooming/Panning the Image Exponentially
|
|
270 |
TPoint iStartDisplayPoint; // The variable holds the starting pointer posistion to determine the Drag Distance
|
|
271 |
TTime iDoubleTap; // This Variable is used to determine the double tap,by using the difference of the time
|
|
272 |
// between subsequent single Tap.
|
|
273 |
TInt iZoomRatio;
|
|
274 |
TRect iDoubleTapRect; // This varaible holds the rect for the Double Tap
|
|
275 |
TBool iDragOngoing; // Is a drag event ongoing
|
|
276 |
TBool iZoomActivated; // To Denote if zoom is activated
|
|
277 |
TUiState iZoomUiState; // To Denote if the Ui is On in zoom
|
|
278 |
TInt iPrevPinchPercentage; // To avoid the bouce while pinch gesture end
|
|
279 |
|
|
280 |
TPoint iPreviousPointerPosition;
|
|
281 |
TPoint iPreviousDragStartPosition;
|
|
282 |
|
|
283 |
TBool iIsZoomingInAnimatedState;
|
|
284 |
TAnimationMode iAnimatedZoomMode;
|
|
285 |
CPeriodic* iZoomAnimationTimer;
|
|
286 |
TInt iZoomPerInterval;
|
|
287 |
TInt iTargetAnimatedZoomRatio;
|
|
288 |
|
|
289 |
|
|
290 |
TPoint iZoomFocus;
|
|
291 |
|
|
292 |
GestureHelper::TGestureCode iPreviousGestureCode ;
|
|
293 |
|
|
294 |
TGlxZoomAndPanMathsEngine iMathsEngine;
|
|
295 |
};
|
|
296 |
|
|
297 |
|
|
298 |
#endif /* GLXZOOMEVENTHANDLER_H_ */
|