|
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: Implementation of Zoom Event Handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // Avkon |
|
20 #include <eikon.hrh> |
|
21 |
|
22 // Antariksh |
|
23 #include <alf/alfutil.h> // AlfUtil |
|
24 #include <mul/mulevent.h> // For Slider events |
|
25 |
|
26 //Photos Headers |
|
27 #include <glxtracer.h> // For Tracer |
|
28 #include <glxlog.h> // For Log |
|
29 |
|
30 #include <mglxuicommandhandler.h> // For MGlxUiCommandHandler |
|
31 #include <glxzoomeventhandler.h> |
|
32 #include <glxzoommathsengine.h> |
|
33 #include <glxzoomcontrol.h> |
|
34 #include <glxzoomeventhandler.h> |
|
35 |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 const TInt KTimerLengthInMicroseconds = 100000 ; |
|
39 const TInt KGlxScreenTimeout = 2000000 ; // 2 seconds timer for UI On/Off |
|
40 |
|
41 const TInt KGlxAnimationTimeDrag = 30 ; |
|
42 const TInt KGlxAnimationTimekeyPan = 50 ; |
|
43 |
|
44 const TInt KGlxZoomPanInc = 5 ; // Min number of pixels panned in one keypress. This value is incremented exponentially by multiples of iPanFactor |
|
45 |
|
46 // Anime Speed changes in inverse proportion to KGlxAnimeFrameInmS. |
|
47 // Steps increase with KGlxAnimeFrameCount. |
|
48 // Total time taken = (KGlxAnimeFrameInmS * KGlxAnimeFrameCount)microseconds. |
|
49 const TInt KGlxAnimeFrameInmS = 10000 ; |
|
50 const TInt KGlxAnimeFrameCount = 10 ; |
|
51 |
|
52 const TInt KGlxPanInertiaFrameInmS = 20000 ; |
|
53 |
|
54 // The (neutral) zoom factor above which all zooms caused are zoom-ins and below , zoom-outs. |
|
55 const TInt KGlxNeutralZoomFactor = 100; |
|
56 |
|
57 using namespace GestureHelper; |
|
58 |
|
59 // ============================ CGlxZoomPanEventHandler=============================== |
|
60 // ============================ MEMBER FUNCTIONS =============================== |
|
61 |
|
62 //---------------------------------------------------------------------------------- |
|
63 // NewL |
|
64 //---------------------------------------------------------------------------------- |
|
65 // |
|
66 CGlxZoomPanEventHandler* CGlxZoomPanEventHandler::NewL( |
|
67 MGlxZoomEventHandlers& aZoomEventHandler) |
|
68 { |
|
69 TRACER("CGlxZoomPanEventHandler::NewL"); |
|
70 CGlxZoomPanEventHandler* self = new (ELeave) CGlxZoomPanEventHandler( |
|
71 aZoomEventHandler); |
|
72 CleanupStack::PushL(self); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop(self); |
|
75 return self; |
|
76 } |
|
77 |
|
78 //---------------------------------------------------------------------------------- |
|
79 // CGlxZoomPanEventHandler constructor |
|
80 //---------------------------------------------------------------------------------- |
|
81 // |
|
82 CGlxZoomPanEventHandler::CGlxZoomPanEventHandler( |
|
83 MGlxZoomEventHandlers& aZoomEventHandler) : |
|
84 iZoomEventHandler(aZoomEventHandler), iPrevPinchPercentage( |
|
85 KGlxNeutralZoomFactor) |
|
86 { |
|
87 TRACER("CGlxZoomPanEventHandler::CGlxZoomPanEventHandler()"); |
|
88 // No Implementation |
|
89 } |
|
90 |
|
91 //---------------------------------------------------------------------------------- |
|
92 // CGlxZoomPanEventHandlerDestructor |
|
93 //---------------------------------------------------------------------------------- |
|
94 // |
|
95 CGlxZoomPanEventHandler::~CGlxZoomPanEventHandler() |
|
96 { |
|
97 TRACER("CGlxZoomPanEventHandler::~CGlxZoomPanEventHandler()"); |
|
98 if(iZoomPanTimer) |
|
99 { |
|
100 CancelZoomPanTimer(); |
|
101 delete iZoomPanTimer; |
|
102 iZoomPanTimer = NULL; |
|
103 } |
|
104 if (iUiTimer) |
|
105 { |
|
106 CancelUITimer(); |
|
107 delete iUiTimer; |
|
108 iUiTimer = NULL; |
|
109 } |
|
110 if(iZoomAnimationTimer) |
|
111 { |
|
112 CancelAnimationTimer(); |
|
113 delete iZoomAnimationTimer; |
|
114 iZoomAnimationTimer = NULL; |
|
115 } |
|
116 } |
|
117 |
|
118 //---------------------------------------------------------------------------------- |
|
119 // CGlxZoomPanEventHandler Constructl |
|
120 //---------------------------------------------------------------------------------- |
|
121 // |
|
122 void CGlxZoomPanEventHandler::ConstructL() |
|
123 { |
|
124 TRACER("CGlxZoomPanEventHandler::ConstructL()"); |
|
125 if(!iUiTimer) |
|
126 { |
|
127 iUiTimer = CPeriodic::NewL(EPriorityNormal); |
|
128 } |
|
129 if(!iZoomPanTimer) |
|
130 { |
|
131 iZoomPanTimer = CPeriodic::NewL(EPriorityNormal); |
|
132 } |
|
133 if(!iZoomAnimationTimer) |
|
134 { |
|
135 iZoomAnimationTimer = CPeriodic::NewL(EPriorityNormal); |
|
136 } |
|
137 } |
|
138 |
|
139 //---------------------------------------------------------------------------------- |
|
140 // CGlxZoomPanEventHandler SetupAnimatedZoom |
|
141 //---------------------------------------------------------------------------------- |
|
142 // |
|
143 // Todo: Combine logics of setting up animated zoom and pan. |
|
144 void CGlxZoomPanEventHandler::SetupAnimatedZoom(TZoomMode aZoomMode, |
|
145 TPoint* /*aZoomFocus*/) |
|
146 { |
|
147 TRACER("CGlxZoomPanEventHandler::SetupAnimatedZoom"); |
|
148 |
|
149 iTargetAnimatedZoomRatio = (iMaxZoomRatio + iMinZoomRatio) / 2; |
|
150 |
|
151 CancelAnimationTimer(); |
|
152 CancelUITimer(); |
|
153 |
|
154 //ToDo: Verify this with images slightly smaller or slightly larger than fullscreen size. |
|
155 if (EZoomIn == aZoomMode) |
|
156 { |
|
157 // the '1+' is to take care of the situation when there the rest of the equation returns something betn 0 and 1 |
|
158 iZoomPerInterval = 1 + (iTargetAnimatedZoomRatio - iZoomRatio) |
|
159 / KGlxAnimeFrameCount; |
|
160 } |
|
161 else |
|
162 { |
|
163 iZoomPerInterval = 1 + (iZoomRatio - iMinZoomRatio) |
|
164 / KGlxAnimeFrameCount; |
|
165 } |
|
166 |
|
167 if (1 < iZoomPerInterval) |
|
168 { |
|
169 iIsZoomingInAnimatedState = ETrue; |
|
170 |
|
171 switch (aZoomMode) |
|
172 { |
|
173 case EZoomIn: |
|
174 iAnimatedZoomMode = EAnimationModeZoomIn; |
|
175 break; |
|
176 case EZoomOut: |
|
177 iAnimatedZoomMode = EAnimationModeZoomOut; |
|
178 break; |
|
179 } |
|
180 |
|
181 iZoomAnimationTimer->Start(0, KGlxAnimeFrameInmS, TCallBack( |
|
182 ActivationIntervalElapsed, (TAny*) this)); |
|
183 } |
|
184 else |
|
185 // Cant zoom in/out at less than 1 percent. so directly jump to the target zoom ratio. |
|
186 // This happens in cases where there is not much difference between the source and target zoom levels |
|
187 { |
|
188 TInt targetZoomRatio = 0; |
|
189 if (EZoomIn == aZoomMode) |
|
190 { |
|
191 targetZoomRatio = iTargetAnimatedZoomRatio; |
|
192 } |
|
193 else |
|
194 { |
|
195 targetZoomRatio = iMinZoomRatio; |
|
196 } |
|
197 Zoom(targetZoomRatio, 0); |
|
198 } |
|
199 } |
|
200 |
|
201 //---------------------------------------------------------------------------------- |
|
202 // CGlxZoomPanEventHandler ActivationIntervalElapsed |
|
203 //---------------------------------------------------------------------------------- |
|
204 // |
|
205 TInt CGlxZoomPanEventHandler::ActivationIntervalElapsed(TAny* aPtr) |
|
206 { |
|
207 TRACER("CGlxZoomPanEventHandler::ActivationIntervalElapsed"); |
|
208 |
|
209 CGlxZoomPanEventHandler* self = static_cast<CGlxZoomPanEventHandler*>(aPtr); |
|
210 |
|
211 self->NextStepAnimatedZoom(); |
|
212 return 0; |
|
213 } |
|
214 |
|
215 //---------------------------------------------------------------------------------- |
|
216 // CGlxZoomPanEventHandler NextStepAmimatedZoom |
|
217 //---------------------------------------------------------------------------------- |
|
218 // |
|
219 void CGlxZoomPanEventHandler::NextStepAnimatedZoom() |
|
220 { |
|
221 TRACER("CGlxZoomPanEventHandler::NextStepAmimatedZoom"); |
|
222 |
|
223 TInt targetZoomLevel = 0 ; |
|
224 |
|
225 if (EAnimationModeZoomIn == iAnimatedZoomMode) |
|
226 { |
|
227 targetZoomLevel = iZoomRatio + iZoomPerInterval; |
|
228 } |
|
229 else |
|
230 { |
|
231 targetZoomLevel = iZoomRatio - iZoomPerInterval; |
|
232 } |
|
233 |
|
234 Zoom(targetZoomLevel, 0, EZoomIn, &iZoomFocus ); |
|
235 |
|
236 // The boundary conditions. |
|
237 if (((targetZoomLevel >= iTargetAnimatedZoomRatio) |
|
238 && (EAnimationModeZoomIn == iAnimatedZoomMode)) |
|
239 || ((targetZoomLevel <= iMinZoomRatio) |
|
240 && (EAnimationModeZoomOut == iAnimatedZoomMode))) |
|
241 { |
|
242 iIsZoomingInAnimatedState = EFalse; |
|
243 CancelAnimationTimer(); |
|
244 TSize screensize = iMathsEngine.ScreenSize(); |
|
245 iZoomFocus = TPoint(screensize.iWidth>>1,screensize.iHeight>>1) ; |
|
246 |
|
247 //start the timer here after the animation is complete |
|
248 if(EUiOn == iZoomUiState && iZoomActivated) |
|
249 { |
|
250 ShowScreenFurniture(KGlxScreenTimeout); |
|
251 } |
|
252 } |
|
253 } |
|
254 |
|
255 //---------------------------------------------------------------------------------- |
|
256 // StartPanTimer:Starts the Pan timer for continous Panning |
|
257 //---------------------------------------------------------------------------------- |
|
258 // |
|
259 void CGlxZoomPanEventHandler::StartPanTimer() |
|
260 { |
|
261 TRACER("CGlxZoomPanEventHandler::StartPanTimer "); |
|
262 |
|
263 //After Panning in one direction for a long time by holding the key and |
|
264 //then if panning is started in another direction,the panning will be done in more pixels. |
|
265 |
|
266 GLX_LOG_INFO("CGlxZoomPanEventHandler::StartPanTimer: Cancelling timers "); |
|
267 |
|
268 if (iZoomPanTimer->IsActive()) |
|
269 { |
|
270 iZoomPanTimer->Cancel(); |
|
271 } |
|
272 iZoomPanTimer->Start( 0, |
|
273 KTimerLengthInMicroseconds, |
|
274 TCallBack( PanIntervalExpired,(TAny*)this) ); |
|
275 |
|
276 } |
|
277 |
|
278 //---------------------------------------------------------------------------------- |
|
279 // CancelZoomPanTimer: Cancels the Zoom timer for continous zoom |
|
280 //---------------------------------------------------------------------------------- |
|
281 // |
|
282 void CGlxZoomPanEventHandler::CancelZoomPanTimer() |
|
283 { |
|
284 TRACER("CGlxZoomPanEventHandler::CancelZoomPanTimer "); |
|
285 |
|
286 if (iZoomPanTimer->IsActive()) |
|
287 { |
|
288 iZoomPanTimer->Cancel(); |
|
289 } |
|
290 } |
|
291 |
|
292 //---------------------------------------------------------------------------------- |
|
293 // CancelUITimer |
|
294 //---------------------------------------------------------------------------------- |
|
295 // |
|
296 void CGlxZoomPanEventHandler::CancelUITimer() |
|
297 { |
|
298 TRACER("CGlxZoomPanEventHandler::CancelUITimer "); |
|
299 |
|
300 if (iUiTimer->IsActive()) |
|
301 { |
|
302 iUiTimer->Cancel(); |
|
303 } |
|
304 } |
|
305 |
|
306 //---------------------------------------------------------------------------------- |
|
307 // CancelUITimer |
|
308 //---------------------------------------------------------------------------------- |
|
309 // |
|
310 void CGlxZoomPanEventHandler::CancelAnimationTimer() |
|
311 { |
|
312 TRACER("CGlxZoomPanEventHandler::CancelAnimationTimer "); |
|
313 |
|
314 // This will set the timer to false if it is being used for zoom. For Pan |
|
315 // this flag is immaterial |
|
316 iIsZoomingInAnimatedState = EFalse; |
|
317 if (iZoomAnimationTimer->IsActive()) |
|
318 { |
|
319 iZoomAnimationTimer->Cancel(); |
|
320 } |
|
321 } |
|
322 |
|
323 //---------------------------------------------------------------------------------- |
|
324 // StartUITimer |
|
325 //---------------------------------------------------------------------------------- |
|
326 // |
|
327 void CGlxZoomPanEventHandler::StartUITimer(TTimeIntervalMicroSeconds32 aDelay, |
|
328 TTimeIntervalMicroSeconds32 anInterval, |
|
329 TCallBack aCallBack) |
|
330 { |
|
331 TRACER("CGlxZoomPanEventHandler::StartUITimer "); |
|
332 |
|
333 if (iUiTimer->IsActive()) |
|
334 { |
|
335 iUiTimer->Cancel(); |
|
336 } |
|
337 iUiTimer->Start(aDelay,anInterval,aCallBack); |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // HandlekeyEvents:This function handles the key Events. |
|
342 // ----------------------------------------------------------------------------- |
|
343 // |
|
344 TBool CGlxZoomPanEventHandler::HandlekeyEvents(const TAlfEvent &aEvent) |
|
345 { |
|
346 TRACER("CGlxZoomPanEventHandler::HandlekeyEvents()"); |
|
347 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandlekeyEvents.Scancode = %d", |
|
348 aEvent.KeyEvent().iScanCode); |
|
349 |
|
350 TBool consumed = EFalse; |
|
351 |
|
352 if (!iIsZoomingInAnimatedState) |
|
353 { |
|
354 switch (aEvent.KeyEvent().iScanCode) |
|
355 { |
|
356 case EStdKeyDevice10: //Listen to EStdKeyDevice10 as EKeyLeftUpArrow key is mapped to TKeyCode::EKeyDevice10 for which TStdScancode is EStdKeyDevice10 |
|
357 case EKeyLeftUpArrow : |
|
358 case EStdKeyDevice13: //Listen to EStdKeyDevice13 as EKeyLeftDownArrow key is mapped to TKeyCode::EKeyDevice13 for which TStdScancode is EStdKeyDevice13 |
|
359 case EKeyLeftDownArrow : |
|
360 case EStdKeyDevice11://Listen to EStdKeyDevice11 as EKeyRightUpArrow key is mapped to TKeyCode::EKeyDevice11 for which TStdScancode is EStdKeyDevice11 |
|
361 case EKeyRightUpArrow : |
|
362 case EStdKeyDevice12: //Listen to EStdKeyDevice12 as EKeyRightDownArrow key is mapped to TKeyCode::EKeyDevice12 for which TStdScancode is EStdKeyDevice12 |
|
363 case EKeyRightDownArrow : |
|
364 case EStdKeyLeftArrow : |
|
365 case EStdKeyRightArrow : |
|
366 case EStdKeyUpArrow : |
|
367 case EStdKeyDownArrow : |
|
368 { |
|
369 HandlePanKey(aEvent); |
|
370 consumed = ETrue; |
|
371 } |
|
372 break; |
|
373 case EStdKeyDevice0: |
|
374 case EStdKeyDevice1: |
|
375 case EStdKeyDevice3: |
|
376 { |
|
377 //Center button/MSK changes the UI State |
|
378 if (aEvent.Code() == EEventKeyDown) |
|
379 { |
|
380 if (EUiOff == iZoomUiState ) |
|
381 { |
|
382 ShowScreenFurniture(KGlxScreenTimeout); |
|
383 } |
|
384 else |
|
385 { |
|
386 HideScreenFurniture(); |
|
387 } |
|
388 } |
|
389 consumed = ETrue; |
|
390 } |
|
391 break; |
|
392 |
|
393 //Listen EStdKeyApplicationC as EKeyZoomIn key is mapped to TKeyCode:: EKeyApplicationC for which TStdScancode is EStdKeyApplicatoinC |
|
394 case EStdKeyApplicationC : |
|
395 { |
|
396 HandleZoomKey(EZoomIn ,aEvent.Code()) ; |
|
397 consumed = ETrue; |
|
398 break ; |
|
399 } |
|
400 //Listen EStdKeyApplicationD as EKeyZoomOut key is mapped to TKeyCode:: EKeyApplicationD for which TStdScancode is EStdKeyApplicatoinD |
|
401 case EStdKeyApplicationD : |
|
402 { |
|
403 HandleZoomKey(EZoomOut,aEvent.Code()); |
|
404 consumed = ETrue; |
|
405 break ; |
|
406 } |
|
407 default: |
|
408 break; |
|
409 } |
|
410 } |
|
411 |
|
412 return consumed; |
|
413 } |
|
414 |
|
415 // ----------------------------------------------------------------------------- |
|
416 // HandleZoomKey:Zooms the image on zoom stripe action. |
|
417 // ----------------------------------------------------------------------------- |
|
418 // |
|
419 void CGlxZoomPanEventHandler::HandleZoomKey(TZoomMode aZoomMode, |
|
420 TEventCode aEventCode) |
|
421 { |
|
422 TRACER("CGlxZoomPanEventHandler::HandleZoomKey "); |
|
423 if ( iZoomActivated ) |
|
424 { |
|
425 switch(aEventCode) |
|
426 { |
|
427 case EEventKey : |
|
428 { |
|
429 iZoomMode = aZoomMode ; |
|
430 Zoom(0, 0, aZoomMode) ; |
|
431 |
|
432 ShowScreenFurniture(KGlxScreenTimeout); |
|
433 break ; |
|
434 } |
|
435 default : |
|
436 break ; |
|
437 } |
|
438 } |
|
439 } |
|
440 |
|
441 // ----------------------------------------------------------------------------- |
|
442 // SetupPanOperation: start the pan operation for Key based pan. |
|
443 // ----------------------------------------------------------------------------- |
|
444 // |
|
445 void CGlxZoomPanEventHandler::SetupPanOperation(TPoint& aPanDirection) |
|
446 { |
|
447 TRACER("CGlxZoomPanEventHandler::SetupPanOperation "); |
|
448 |
|
449 iPanDirection = TPoint(aPanDirection); |
|
450 if(EUiOn == iZoomUiState ) |
|
451 { |
|
452 HideScreenFurniture(); |
|
453 } |
|
454 |
|
455 StartPanTimer(); |
|
456 |
|
457 iMathsEngine.SetupPanOperation(); |
|
458 } |
|
459 |
|
460 // ----------------------------------------------------------------------------- |
|
461 // HandlePanKey :handles the keys related to pan and starts the pan Timer |
|
462 // ----------------------------------------------------------------------------- |
|
463 // |
|
464 TBool CGlxZoomPanEventHandler::HandlePanKey( const TAlfEvent &aEvent ) |
|
465 { |
|
466 TRACER("CGlxZoomPanEventHandler::HandlePanKey "); |
|
467 |
|
468 TSize imageVirtualSize = iMathsEngine.ImageVirtualSize(); |
|
469 TSize screenSize = iMathsEngine.ScreenSize(); |
|
470 TBool safeToPan = EFalse ; |
|
471 TPoint panDirection(0,0); |
|
472 TBool handled = EFalse; |
|
473 |
|
474 if ( aEvent.Code() == EEventKeyDown ) |
|
475 { |
|
476 //if height and/or width of the zoomed image is greater than the screen height and screen width , |
|
477 //then this paning should be posssible |
|
478 switch(aEvent.KeyEvent().iScanCode ) |
|
479 { |
|
480 case EStdKeyDevice10: |
|
481 case EKeyLeftUpArrow: |
|
482 { |
|
483 if ((imageVirtualSize.iHeight>screenSize.iHeight) |
|
484 &&(imageVirtualSize.iWidth > screenSize.iWidth)) |
|
485 { |
|
486 safeToPan = ETrue; |
|
487 panDirection = TPoint(-KGlxZoomPanInc, -KGlxZoomPanInc); |
|
488 } |
|
489 } |
|
490 break; |
|
491 case EStdKeyDevice11: |
|
492 case EKeyRightUpArrow: |
|
493 { |
|
494 if ((imageVirtualSize.iHeight>screenSize.iHeight) |
|
495 &&(imageVirtualSize.iWidth > screenSize.iWidth)) |
|
496 { |
|
497 safeToPan = ETrue; |
|
498 panDirection = TPoint(KGlxZoomPanInc, -KGlxZoomPanInc); |
|
499 } |
|
500 } |
|
501 break; |
|
502 case EStdKeyDevice12: |
|
503 case EKeyLeftDownArrow: |
|
504 { |
|
505 if ((imageVirtualSize.iHeight>screenSize.iHeight) |
|
506 &&(imageVirtualSize.iWidth > screenSize.iWidth)) |
|
507 { |
|
508 safeToPan = ETrue; |
|
509 panDirection = TPoint(-KGlxZoomPanInc, KGlxZoomPanInc); |
|
510 } |
|
511 } |
|
512 break; |
|
513 case EStdKeyDevice13: |
|
514 case EKeyRightDownArrow: |
|
515 { |
|
516 if ((imageVirtualSize.iHeight>screenSize.iHeight) |
|
517 &&(imageVirtualSize.iWidth > screenSize.iWidth)) |
|
518 { |
|
519 safeToPan = ETrue; |
|
520 panDirection = TPoint(KGlxZoomPanInc, KGlxZoomPanInc); |
|
521 } |
|
522 } |
|
523 break; |
|
524 case EStdKeyUpArrow: |
|
525 { |
|
526 if( (imageVirtualSize.iHeight ) > screenSize.iHeight ) |
|
527 { |
|
528 safeToPan = ETrue; |
|
529 panDirection = TPoint(0, -KGlxZoomPanInc); |
|
530 } |
|
531 } |
|
532 break; |
|
533 case EStdKeyDownArrow: |
|
534 { |
|
535 if( (imageVirtualSize.iHeight ) > screenSize.iHeight ) |
|
536 { |
|
537 safeToPan = ETrue; |
|
538 panDirection = TPoint(0, KGlxZoomPanInc); |
|
539 } |
|
540 } |
|
541 break; |
|
542 case EStdKeyLeftArrow: |
|
543 { |
|
544 if( (imageVirtualSize.iWidth ) > screenSize.iWidth ) |
|
545 { |
|
546 safeToPan = ETrue; |
|
547 panDirection = TPoint(-KGlxZoomPanInc, 0); |
|
548 } |
|
549 } |
|
550 break; |
|
551 case EStdKeyRightArrow: |
|
552 { |
|
553 if ((imageVirtualSize.iWidth ) > screenSize.iWidth ) |
|
554 { |
|
555 safeToPan = ETrue; |
|
556 panDirection = TPoint(KGlxZoomPanInc, 0); |
|
557 } |
|
558 } |
|
559 break; |
|
560 default: |
|
561 break; |
|
562 } |
|
563 if (safeToPan) |
|
564 { |
|
565 SetupPanOperation(panDirection); |
|
566 handled = ETrue; |
|
567 } |
|
568 } |
|
569 else if ( aEvent.Code() == EEventKeyUp) |
|
570 { |
|
571 // destroy the Pan infrastructure |
|
572 // Reset the PanDirection and cancel the pan timers. |
|
573 CancelZoomPanTimer(); |
|
574 iPanDirection = TPoint(0, 0); |
|
575 handled = ETrue; |
|
576 } |
|
577 return handled; |
|
578 } |
|
579 |
|
580 |
|
581 // ----------------------------------------------------------------------------- |
|
582 // HandleDragEvent |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 void CGlxZoomPanEventHandler::HandleDragEvent( |
|
586 const GestureHelper::MGestureEvent& aEvent) |
|
587 { |
|
588 TRACER("CGlxZoomPanEventHandler::HandleDragEvent(GestureHelper::MGestureEvent&)"); |
|
589 |
|
590 // Ignore events when we are animating in Zoom |
|
591 if (iIsZoomingInAnimatedState) |
|
592 { |
|
593 return; |
|
594 } |
|
595 |
|
596 TPoint startPos = aEvent.StartPos(); |
|
597 TPoint currPos = aEvent.CurrentPos(); |
|
598 |
|
599 |
|
600 // This means a new gesture has just started. |
|
601 if (startPos != iPreviousDragStartPosition) |
|
602 { |
|
603 iPreviousPointerPosition = startPos; |
|
604 } |
|
605 |
|
606 TPoint offset((iPreviousPointerPosition.iX - currPos.iX), |
|
607 (iPreviousPointerPosition.iY - currPos.iY)); |
|
608 |
|
609 HideScreenFurniture(); |
|
610 |
|
611 TPoint topLeftCorner(0,0); |
|
612 iMathsEngine.Pan(offset, topLeftCorner, EGlxPanIncrementUniform); |
|
613 |
|
614 iZoomEventHandler.HandleViewPortParametersChanged(topLeftCorner, |
|
615 KGlxAnimationTimeDrag); |
|
616 |
|
617 iPreviousPointerPosition = currPos ; |
|
618 iPreviousDragStartPosition = startPos; |
|
619 } |
|
620 |
|
621 // ----------------------------------------------------------------------------- |
|
622 // HandleGestureReleased |
|
623 // ----------------------------------------------------------------------------- |
|
624 // |
|
625 void CGlxZoomPanEventHandler::HandleGestureReleased( |
|
626 const GestureHelper::MGestureEvent& /*aEvent*/) |
|
627 { |
|
628 TRACER("CGlxZoomPanEventHandler::HandleGestureReleasedEvent(const GestureHelper::MGestureEvent& )"); |
|
629 |
|
630 if ( (EGestureSwipeLeft == iPreviousGestureCode) |
|
631 ||(EGestureSwipeRight == iPreviousGestureCode) |
|
632 ||(EGestureSwipeUp == iPreviousGestureCode) |
|
633 ||(EGestureSwipeDown == iPreviousGestureCode) |
|
634 ) |
|
635 { |
|
636 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandleGestureReleased: Previous Gesture Code [%d]" , iPreviousGestureCode); |
|
637 SetupAnimatedPan(); |
|
638 } |
|
639 } |
|
640 |
|
641 void CGlxZoomPanEventHandler::SetupAnimatedPan() |
|
642 { |
|
643 TRACER("CGlxZoomPanEventHandler::SetupAnimatedPan"); |
|
644 |
|
645 CancelAnimationTimer(); |
|
646 |
|
647 iZoomAnimationTimer->Start( KGlxPanInertiaFrameInmS, |
|
648 KGlxPanInertiaFrameInmS, |
|
649 TCallBack( PanInertiaFrameElapsed,(TAny*)this) ); |
|
650 |
|
651 } |
|
652 |
|
653 |
|
654 TInt CGlxZoomPanEventHandler::PanInertiaFrameElapsed(TAny* aPtr) |
|
655 { |
|
656 TRACER("CGlxZoomPanEventHandler::PanInertiaFrameElapsed"); |
|
657 |
|
658 CGlxZoomPanEventHandler* self = static_cast<CGlxZoomPanEventHandler*>(aPtr); |
|
659 |
|
660 self->NextStepInerticPan(); |
|
661 return 0; |
|
662 |
|
663 } |
|
664 |
|
665 |
|
666 void CGlxZoomPanEventHandler::NextStepInerticPan() |
|
667 { |
|
668 TRACER("CGlxZoomPanEventHandler::NextStepInerticPan"); |
|
669 |
|
670 TPoint inertiaOffset = iMathsEngine.LastPanOffset(); |
|
671 |
|
672 if ( (10 >= Abs(inertiaOffset.iX )) && (10 >= Abs(inertiaOffset.iY) )) |
|
673 { |
|
674 CancelAnimationTimer(); |
|
675 } |
|
676 else |
|
677 { |
|
678 TPoint topLeftCorner(0, 0); |
|
679 TBool thresholdReached = EFalse; |
|
680 iMathsEngine.Pan(inertiaOffset, topLeftCorner, |
|
681 EGlxPanIncrementInertic, &thresholdReached); |
|
682 |
|
683 iZoomEventHandler.HandleViewPortParametersChanged(topLeftCorner, |
|
684 KGlxAnimationTimeDrag); |
|
685 |
|
686 // we dont want to continue animated PAN if we have reached one end of the image. |
|
687 if (thresholdReached) |
|
688 { |
|
689 CancelAnimationTimer(); |
|
690 } |
|
691 } |
|
692 } |
|
693 |
|
694 void CGlxZoomPanEventHandler::SetPreviousEventCode(const TGestureCode aCode ) |
|
695 { |
|
696 TRACER("CGlxZoomPanEventHandler::SetPreviousEventCode(const TGestureCode aCode )"); |
|
697 |
|
698 iPreviousGestureCode = aCode; |
|
699 } |
|
700 |
|
701 // ----------------------------------------------------------------------------- |
|
702 // HandlePinchEvent |
|
703 // ----------------------------------------------------------------------------- |
|
704 // |
|
705 void CGlxZoomPanEventHandler::HandlePinchEventL( |
|
706 const GestureHelper::MGestureEvent& aEvent) |
|
707 { |
|
708 TRACER("CGlxZoomPanEventHandler::HandlePinchEvent(GestureHelper::MGestureEvent&)"); |
|
709 |
|
710 // Ignore events when we are animating in Zoom |
|
711 if (iIsZoomingInAnimatedState) |
|
712 { |
|
713 return; |
|
714 } |
|
715 |
|
716 TPoint pinchFocus = aEvent.PinchCentrePoint(); |
|
717 // Wrong convention in variable nomenclature but better than |
|
718 // ratioInPercentOfChangeInPinchDistance which is incidentally correct |
|
719 TInt pinchPercentage = aEvent.PinchPercent(); |
|
720 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandlePinchEventL: Percentage [%d]" , pinchPercentage); |
|
721 GLX_LOG_INFO2("CGlxZoomPanEventHandler::HandlePinchEventL: Pinch Focus [%d, %d]" , pinchFocus.iX, pinchFocus.iY); |
|
722 |
|
723 if (( iPrevPinchPercentage >= KGlxNeutralZoomFactor ) && |
|
724 ( pinchPercentage < KGlxNeutralZoomFactor )) |
|
725 { |
|
726 iPrevPinchPercentage = pinchPercentage ; |
|
727 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandlePinchEventL: Pinch Ignored. Previous pinch factor = %d", iPrevPinchPercentage ); |
|
728 //This will result in we ignoring this event |
|
729 pinchPercentage = KGlxNeutralZoomFactor; |
|
730 } |
|
731 else |
|
732 { |
|
733 iPrevPinchPercentage = pinchPercentage ; |
|
734 } |
|
735 |
|
736 // pinchPercentage == 100 => No change in finger distance => No Zoom. |
|
737 // A negative Pinch percentage signifies an error in calculations. |
|
738 // So NOT handling these |
|
739 if ( (pinchPercentage != KGlxNeutralZoomFactor) |
|
740 && (pinchPercentage > 0) ) |
|
741 { |
|
742 Zoom(0, pinchPercentage, EZoomIn, &pinchFocus); |
|
743 } |
|
744 |
|
745 HideScreenFurniture(); |
|
746 } |
|
747 |
|
748 // ----------------------------------------------------------------------------- |
|
749 // HandleDoubleTap |
|
750 // ----------------------------------------------------------------------------- |
|
751 // |
|
752 void CGlxZoomPanEventHandler::HandleDoubleTap(const GestureHelper::MGestureEvent& /*aEvent*/ ) |
|
753 { |
|
754 TRACER("CGlxZoomPanEventHandler::HandleDoubleTap(GestureHelper::MGestureEvent&)"); |
|
755 |
|
756 // Ignore events when we are animating in Zoom |
|
757 if (iIsZoomingInAnimatedState) |
|
758 { |
|
759 return; |
|
760 } |
|
761 |
|
762 SetupAnimatedZoom(EZoomOut); |
|
763 } |
|
764 |
|
765 // ----------------------------------------------------------------------------- |
|
766 // HandleSingleTap |
|
767 // ----------------------------------------------------------------------------- |
|
768 // |
|
769 void CGlxZoomPanEventHandler::HandleSingleTap(const GestureHelper::MGestureEvent& /*aEvent*/ ) |
|
770 { |
|
771 TRACER("CGlxZoomControl::HandleSingleTap(GestureHelper::MGestureEvent&)"); |
|
772 |
|
773 // Ignore events when we are animating in Zoom |
|
774 if (iIsZoomingInAnimatedState) |
|
775 { |
|
776 return; |
|
777 } |
|
778 |
|
779 if (EUiOff == iZoomUiState) |
|
780 { |
|
781 ShowScreenFurniture(KGlxScreenTimeout); |
|
782 } |
|
783 else{ |
|
784 HideScreenFurniture(); |
|
785 } |
|
786 } |
|
787 |
|
788 // --------------------------------------------------------------------------- |
|
789 // UiTimeOut: Hides the screen furniture once the Timeout happens |
|
790 // --------------------------------------------------------------------------- |
|
791 // |
|
792 TInt CGlxZoomPanEventHandler::UiTimeOut(TAny* aSelf) |
|
793 { |
|
794 TRACER("CGlxZoomPanEventHandler::UiTimeOut"); |
|
795 if(aSelf) |
|
796 { |
|
797 CGlxZoomPanEventHandler* self = static_cast <CGlxZoomPanEventHandler*> (aSelf); |
|
798 //retreive the UI state. |
|
799 if(EUiOn == self->iZoomUiState) |
|
800 { |
|
801 self->HideScreenFurniture(); |
|
802 } |
|
803 } |
|
804 return KErrNone; |
|
805 } |
|
806 |
|
807 // --------------------------------------------------------------------------- |
|
808 // ZoomOutTimerL |
|
809 // --------------------------------------------------------------------------- |
|
810 // |
|
811 TInt CGlxZoomPanEventHandler::ZoomOutTimerL(TAny* aSelf) |
|
812 { |
|
813 TRACER("CGlxZoomPanEventHandler::ZoomOutTimerL"); |
|
814 if(aSelf) |
|
815 { |
|
816 CGlxZoomPanEventHandler* self = static_cast <CGlxZoomPanEventHandler*> (aSelf); |
|
817 self->CallZoomOutL(); |
|
818 } |
|
819 return KErrNone; |
|
820 } |
|
821 |
|
822 // --------------------------------------------------------------------------- |
|
823 // CallZoomOutL |
|
824 // --------------------------------------------------------------------------- |
|
825 // |
|
826 void CGlxZoomPanEventHandler::CallZoomOutL() |
|
827 { |
|
828 TRACER("CGlxZoomPanEventHandler::CallZoomOutL()"); |
|
829 iZoomEventHandler.HandleZoomOutL(KGlxZoomOutCommand); |
|
830 } |
|
831 |
|
832 //---------------------------------------------------------------------------------- |
|
833 // PanIntervalExpired:Callback function for the pan timer |
|
834 //---------------------------------------------------------------------------------- |
|
835 // |
|
836 TInt CGlxZoomPanEventHandler::PanIntervalExpired(TAny* aPtr) |
|
837 { |
|
838 TRACER("CGlxZoomPanEventHandler::PanIntervalExpired "); |
|
839 GLX_LOG_INFO("PanIntervalExpired "); |
|
840 CGlxZoomPanEventHandler* self = static_cast<CGlxZoomPanEventHandler*>(aPtr); |
|
841 self->DoPan(); |
|
842 return 0; // Timer has finished |
|
843 } |
|
844 |
|
845 |
|
846 //---------------------------------------------------------------------------------- |
|
847 // DoPan:calls Panning function. |
|
848 //---------------------------------------------------------------------------------- |
|
849 // |
|
850 void CGlxZoomPanEventHandler::DoPan() |
|
851 { |
|
852 TRACER("CGlxZoomPanEventHandler::DoPan "); |
|
853 |
|
854 TBool atPanThreshold = EFalse; |
|
855 TPoint topLeftCorner; |
|
856 iMathsEngine.Pan(iPanDirection, topLeftCorner, |
|
857 EGlxPanIncrementExponential, &atPanThreshold); |
|
858 |
|
859 iZoomEventHandler.HandleViewPortParametersChanged(topLeftCorner, |
|
860 KGlxAnimationTimekeyPan); |
|
861 |
|
862 if ( atPanThreshold ) |
|
863 { |
|
864 CancelZoomPanTimer(); |
|
865 } |
|
866 |
|
867 iMathsEngine.UpdatePanFactor(); |
|
868 } |
|
869 |
|
870 |
|
871 //---------------------------------------------------------------------------------- |
|
872 // OrientationChanged |
|
873 //---------------------------------------------------------------------------------- |
|
874 // |
|
875 void CGlxZoomPanEventHandler::OrientationChanged(const TRect& aNewScreenRect) |
|
876 { |
|
877 TRACER("CGlxZoomPanEventHandler::OrientationChanged "); |
|
878 |
|
879 iMathsEngine.OrientationChanged(aNewScreenRect); |
|
880 iMinZoomRatio = iMathsEngine.MinimumZoomRatio(); |
|
881 //Keep the relative Zoom Ratio same while changing orientation |
|
882 Zoom(0, KGlxNeutralZoomFactor, iZoomMode) ; |
|
883 } |
|
884 |
|
885 // ----------------------------------------------------------------------------- |
|
886 // ShowSlider |
|
887 // ----------------------------------------------------------------------------- |
|
888 // |
|
889 void CGlxZoomPanEventHandler::ShowScreenFurniture(TTimeIntervalMicroSeconds32 aTimeout) |
|
890 { |
|
891 TRACER("CGlxZoomPanEventHandler::ShowScreenFurniture()"); |
|
892 |
|
893 if (EUiOff == iZoomUiState ) |
|
894 { |
|
895 // make visible if not already visible. |
|
896 // the timer will ofcourse get restarted. |
|
897 iZoomEventHandler.HandleShowUi(ETrue); |
|
898 } |
|
899 |
|
900 if (aTimeout.Int()) |
|
901 { |
|
902 StartUITimer(aTimeout,aTimeout,TCallBack( UiTimeOut,this )); |
|
903 } |
|
904 } |
|
905 |
|
906 |
|
907 // ----------------------------------------------------------------------------- |
|
908 // HideScreenFurniture |
|
909 // ----------------------------------------------------------------------------- |
|
910 // |
|
911 void CGlxZoomPanEventHandler::HideScreenFurniture() |
|
912 { |
|
913 TRACER("CGlxZoomPanEventHandler::HideScreenFurniture()"); |
|
914 if (EUiOn == iZoomUiState ) |
|
915 { |
|
916 iZoomEventHandler.HandleShowUi(EFalse); |
|
917 CancelUITimer(); |
|
918 } |
|
919 } |
|
920 |
|
921 |
|
922 // ----------------------------------------------------------------------------- |
|
923 // ActivateZoom |
|
924 // ----------------------------------------------------------------------------- |
|
925 // |
|
926 void CGlxZoomPanEventHandler::ActivateZoom( TInt aInitialZoomRatio, |
|
927 TSize aImageSize, |
|
928 TZoomStartMode aStartMode, |
|
929 TInt aMinZoomRatio, |
|
930 TInt aMaxZoomRatio, |
|
931 TPoint* aZoomFocus) |
|
932 { |
|
933 TRACER("CGlxZoomPanEventHandler::ActivateZoom"); |
|
934 |
|
935 TPoint center(aImageSize.iWidth/2 ,aImageSize.iHeight/2 ); |
|
936 TSize imageSize(aImageSize.iWidth, aImageSize.iHeight); |
|
937 |
|
938 TSize screenSize = TSize(AlfUtil::ScreenSize()); |
|
939 |
|
940 GLX_LOG_INFO2("ActivateZoom : Center = [%d,%d], ", |
|
941 TInt(center.iX), |
|
942 TInt(center.iY) |
|
943 ); |
|
944 |
|
945 // Minimum and Maximum Zoom Ratio |
|
946 iZoomRatio = aInitialZoomRatio; |
|
947 iMinZoomRatio = aMinZoomRatio ; |
|
948 iMaxZoomRatio = aMaxZoomRatio ; |
|
949 |
|
950 iMathsEngine.Initialize(center, |
|
951 screenSize, |
|
952 imageSize, |
|
953 iZoomRatio, |
|
954 aMinZoomRatio |
|
955 ); |
|
956 |
|
957 //initially show the slider,so set the state to slider visible |
|
958 TPoint viewPortTopLeft(0,0); |
|
959 TSize viewPortDimension(0,0); |
|
960 iZoomMode = EZoomIn; |
|
961 |
|
962 switch(aStartMode) |
|
963 { |
|
964 case EZoomStartKey : |
|
965 { |
|
966 // Fix for issue EPKA-7ZX8FR: Vasco_wk03: Zoom In Key (Volume Up Key), |
|
967 // gradually Zooms the image to full extent on a single click. |
|
968 |
|
969 // We are not getting keyup event which cancle the timer so not |
|
970 // starting timer to do zoom |
|
971 Zoom(0, 0, iZoomMode); |
|
972 } |
|
973 break; |
|
974 case EZoomStartDoubleTap : |
|
975 { |
|
976 if (!iIsZoomingInAnimatedState) |
|
977 { |
|
978 if (aZoomFocus) |
|
979 { |
|
980 iZoomFocus.iX = aZoomFocus->iX ; |
|
981 iZoomFocus.iY = aZoomFocus->iY ; |
|
982 } |
|
983 SetupAnimatedZoom(EZoomIn, &iZoomFocus); |
|
984 } |
|
985 } |
|
986 break; |
|
987 case EZoomStartPinch: |
|
988 { |
|
989 iZoomRatio = iMathsEngine.Zoom(EZoomIn, aMinZoomRatio, |
|
990 viewPortTopLeft, viewPortDimension); |
|
991 |
|
992 iZoomEventHandler.HandleViewPortParametersChanged(viewPortTopLeft , 0, |
|
993 &viewPortDimension, iZoomRatio); |
|
994 iZoomEventHandler.HandleShowUi(EFalse); |
|
995 } |
|
996 break; |
|
997 case EZoomStartSlider: |
|
998 { |
|
999 Zoom(aInitialZoomRatio, 0, iZoomMode); |
|
1000 } |
|
1001 break; |
|
1002 default: |
|
1003 break; |
|
1004 } |
|
1005 |
|
1006 } |
|
1007 |
|
1008 // ----------------------------------------------------------------------------- |
|
1009 // DeactivateZoom |
|
1010 // ----------------------------------------------------------------------------- |
|
1011 // |
|
1012 void CGlxZoomPanEventHandler::DeactivateZoom() |
|
1013 { |
|
1014 TRACER("CGlxZoomPanEventHandler::DeactivateZoom()"); |
|
1015 |
|
1016 iZoomMode = EZoomOut; |
|
1017 iIsZoomingInAnimatedState = EFalse ; |
|
1018 CancelZoomPanTimer(); |
|
1019 CancelUITimer(); |
|
1020 CancelAnimationTimer(); |
|
1021 } |
|
1022 |
|
1023 // ----------------------------------------------------------------------------- |
|
1024 // HandleEvent |
|
1025 // ----------------------------------------------------------------------------- |
|
1026 // |
|
1027 // Todo: Combine both these HandleEvents |
|
1028 TBool CGlxZoomPanEventHandler::HandleEvent( const TAlfEvent& aEvent ) |
|
1029 { |
|
1030 TRACER("CGlxZoomPanEventHandler::HandleEvent()"); |
|
1031 |
|
1032 TBool eventHandledState = EFalse; |
|
1033 |
|
1034 if (iZoomActivated) |
|
1035 { |
|
1036 if(!aEvent.IsCustomEvent()) |
|
1037 { |
|
1038 eventHandledState = EFalse; |
|
1039 } |
|
1040 else |
|
1041 { |
|
1042 GLX_LOG_INFO("CGlxZoomPanEventHandler::HandleEvent: Custom Event."); |
|
1043 TInt EventID = aEvent.CustomParameter(); |
|
1044 |
|
1045 switch(EventID) |
|
1046 { |
|
1047 case ETypePrimaryValueChange: |
|
1048 { |
|
1049 GLX_LOG_INFO("CGlxZoomPanEventHandler::HandleEvent:ETypePrimaryValueChange"); |
|
1050 |
|
1051 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandleEvent:ETypePrimaryValueChange, iMinZoomRatio = [%d]", iMinZoomRatio); |
|
1052 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandleEvent:ETypePrimaryValueChange, iMaxZoomRatio = [%d]", iMaxZoomRatio); |
|
1053 |
|
1054 MulSliderPos* dataPtr = (MulSliderPos*)(aEvent.CustomEventData()); |
|
1055 TInt currentSliderValue = dataPtr->mCurrentValue; |
|
1056 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandleEvent:ETypePrimaryValueChange, currentSliderValue = [%d]", currentSliderValue ); |
|
1057 |
|
1058 // Is current value within acceptable range? |
|
1059 // If yes, then zoom in or zoom out as needed. |
|
1060 if ( currentSliderValue > iMinZoomRatio |
|
1061 && currentSliderValue <= iMaxZoomRatio ) |
|
1062 { |
|
1063 Zoom(currentSliderValue, 0, EZoomIn); |
|
1064 } |
|
1065 else if (currentSliderValue <= iMinZoomRatio) |
|
1066 { |
|
1067 CallZoomOutL(); |
|
1068 } |
|
1069 eventHandledState = ETrue; |
|
1070 } |
|
1071 break; |
|
1072 |
|
1073 case ECustomEventIconClick : |
|
1074 { |
|
1075 //The Slider is held by user,so cancel the UI Timer |
|
1076 //When the slider is held ,the screen furniture shouldn't disappear |
|
1077 GLX_LOG_INFO("CGlxZoomPanEventHandler::HandleEvent, ECustomEventIconClick"); |
|
1078 CancelUITimer(); |
|
1079 eventHandledState = ETrue; |
|
1080 } |
|
1081 break; |
|
1082 |
|
1083 case ECustomEventIconRelease: |
|
1084 { |
|
1085 //The slider is not held, by the user,start the ui timer to hide the screen furniture |
|
1086 GLX_LOG_INFO( " CGlxZoomPanEventHandler::offerEvent,ECustomEventIconRelease"); |
|
1087 StartUITimer(KGlxScreenTimeout, KGlxScreenTimeout, |
|
1088 TCallBack(UiTimeOut, this)); |
|
1089 eventHandledState = ETrue; |
|
1090 } |
|
1091 break; |
|
1092 |
|
1093 default: |
|
1094 { |
|
1095 GLX_LOG_INFO(" CGlxZoomPanEventHandler::HandleEvent default"); |
|
1096 eventHandledState = EFalse; |
|
1097 break; |
|
1098 } |
|
1099 } |
|
1100 } |
|
1101 } |
|
1102 return eventHandledState ; |
|
1103 } |
|
1104 |
|
1105 // ----------------------------------------------------------------------------- |
|
1106 // HandleEvent |
|
1107 // ----------------------------------------------------------------------------- |
|
1108 // |
|
1109 TBool CGlxZoomPanEventHandler::HandleEventL(const TAlfEvent &aEvent) |
|
1110 { |
|
1111 TRACER("CGlxZoomPanEventHandler::HandleEventL()"); |
|
1112 |
|
1113 TBool consumed = EFalse; |
|
1114 |
|
1115 if (iZoomActivated) |
|
1116 { |
|
1117 if (aEvent.IsKeyEvent() ) |
|
1118 { |
|
1119 GLX_LOG_INFO(" CGlxZoomPanEventHandler::HandleEvent KeyEvent"); |
|
1120 consumed = HandlekeyEvents(aEvent); |
|
1121 } |
|
1122 else if(aEvent.IsPointerEvent() ) |
|
1123 { |
|
1124 GLX_LOG_INFO(" CGlxZoomPanEventHandler::HandleEvent PointerEvent "); |
|
1125 consumed = iZoomEventHandler.HandlePointerEventsL(aEvent); |
|
1126 } |
|
1127 } |
|
1128 return consumed; |
|
1129 } |
|
1130 |
|
1131 |
|
1132 // ----------------------------------------------------------------------------- |
|
1133 // ZoomToMinimum |
|
1134 // ----------------------------------------------------------------------------- |
|
1135 // |
|
1136 void CGlxZoomPanEventHandler::ZoomToMinimumL() |
|
1137 { |
|
1138 TRACER("CGlxZoomPanEventHandler::ZoomToMinimumL( )"); |
|
1139 |
|
1140 Zoom(iMinZoomRatio, 0, EZoomOut); |
|
1141 CallZoomOutL(); |
|
1142 } |
|
1143 |
|
1144 |
|
1145 // ----------------------------------------------------------------------------- |
|
1146 // Zoom |
|
1147 // ----------------------------------------------------------------------------- |
|
1148 // |
|
1149 void CGlxZoomPanEventHandler::Zoom(TInt aExpectedZoomLevel, |
|
1150 TInt aRelativeZoomFactor, TZoomMode aZoomMode, TPoint* aZoomFocus) |
|
1151 { |
|
1152 TRACER("CGlxZoomPanEventHandler::Zoom()"); |
|
1153 |
|
1154 TPoint viewPortTopLeft(0,0); |
|
1155 TSize viewPortDimension(0,0); |
|
1156 TBool atZoomThreshold = EFalse; |
|
1157 |
|
1158 iZoomRatio = iMathsEngine.Zoom(aZoomMode, |
|
1159 aExpectedZoomLevel, |
|
1160 viewPortTopLeft, |
|
1161 viewPortDimension, |
|
1162 &atZoomThreshold, |
|
1163 aZoomFocus, |
|
1164 aRelativeZoomFactor); |
|
1165 |
|
1166 if( atZoomThreshold ) |
|
1167 { |
|
1168 GLX_LOG_INFO("CGlxZoomPanEventHandler::Zoom Threshold Reached"); |
|
1169 CancelZoomPanTimer(); |
|
1170 if (iZoomRatio <= iMinZoomRatio) |
|
1171 { |
|
1172 CallZoomOutL(); |
|
1173 return; |
|
1174 } |
|
1175 } |
|
1176 iZoomEventHandler.HandleViewPortParametersChanged(viewPortTopLeft, 0, |
|
1177 &viewPortDimension, iZoomRatio); |
|
1178 } |
|
1179 |
|
1180 // ----------------------------------------------------------------------------- |
|
1181 // ZoomIsActivated |
|
1182 // ----------------------------------------------------------------------------- |
|
1183 // |
|
1184 void CGlxZoomPanEventHandler::SetZoomActivated(TBool aIsActivated) |
|
1185 { |
|
1186 TRACER("CGlxZoomPanEventHandler::ZoomIsActivated"); |
|
1187 iZoomActivated = aIsActivated; |
|
1188 } |
|
1189 |
|
1190 // ----------------------------------------------------------------------------- |
|
1191 // SetZoomUiState |
|
1192 // ----------------------------------------------------------------------------- |
|
1193 // |
|
1194 void CGlxZoomPanEventHandler::SetZoomUiState(TUiState aZoomUiState) |
|
1195 { |
|
1196 TRACER("CGlxZoomPanEventHandler::ZoomIsActivated"); |
|
1197 iZoomUiState = aZoomUiState; |
|
1198 GLX_LOG_INFO1("CGlxZoomPanEventHandler::SetZoomUiState :=%d",iZoomUiState); |
|
1199 } |
|
1200 |
|
1201 // ----------------------------------------------------------------------------- |
|
1202 // ZoomUiState |
|
1203 // ----------------------------------------------------------------------------- |
|
1204 // |
|
1205 TUiState CGlxZoomPanEventHandler::ZoomUiState() |
|
1206 { |
|
1207 TRACER("CGlxZoomPanEventHandler::ZoomUiState"); |
|
1208 GLX_LOG_INFO1("CGlxZoomPanEventHandler::ZoomUiState :=%d",iZoomUiState); |
|
1209 return iZoomUiState ; |
|
1210 } |
|
1211 |
|
1212 // ----------------------------------------------------------------------------- |
|
1213 // HandleMultiTouchReleased |
|
1214 // ----------------------------------------------------------------------------- |
|
1215 // |
|
1216 void CGlxZoomPanEventHandler::HandleMultiTouchReleased() |
|
1217 { |
|
1218 TRACER("CGlxZoomPanEventHandler::HandleMultiTouchReleased"); |
|
1219 //Do nothing |
|
1220 } |