photosgallery/viewframework/views/zoomview/src/glxzoomeventhandler.cpp
branchRCL_3
changeset 9 6b87b143d312
parent 3 9a9c174934f5
child 18 bcb43dc84c44
equal deleted inserted replaced
5:f7f0874bfe7d 9:6b87b143d312
   234         TSize screensize = iMathsEngine.ScreenSize();
   234         TSize screensize = iMathsEngine.ScreenSize();
   235         iZoomFocus = TPoint(screensize.iWidth>>1,screensize.iHeight>>1) ;
   235         iZoomFocus = TPoint(screensize.iWidth>>1,screensize.iHeight>>1) ;
   236         }
   236         }
   237     }
   237     }
   238 
   238 
   239 
       
   240 //----------------------------------------------------------------------------------
       
   241 // StartZoomTimer:Starts the Zoom timer for continous zoom
       
   242 //----------------------------------------------------------------------------------
       
   243 //
       
   244 void CGlxZoomPanEventHandler::StartZoomTimer()
       
   245     {
       
   246     TRACER("CGlxZoomPanEventHandler::StartZoomTimer");
       
   247 
       
   248     if (iZoomPanTimer->IsActive())
       
   249         {
       
   250         iZoomPanTimer->Cancel();
       
   251         }
       
   252     iZoomPanTimer->Start( KTimerLengthInMicroseconds,  
       
   253             KTimerLengthInMicroseconds, 
       
   254             TCallBack( ZoomIntervalExpired,(TAny*)this) );
       
   255     }
       
   256 
       
   257 //----------------------------------------------------------------------------------
   239 //----------------------------------------------------------------------------------
   258 // StartPanTimer:Starts the Pan timer for continous Panning
   240 // StartPanTimer:Starts the Pan timer for continous Panning
   259 //----------------------------------------------------------------------------------
   241 //----------------------------------------------------------------------------------
   260 //
   242 //
   261 void CGlxZoomPanEventHandler::StartPanTimer()
   243 void CGlxZoomPanEventHandler::StartPanTimer()
   403             case EStdKeyApplicationD :
   385             case EStdKeyApplicationD :
   404                 {
   386                 {
   405                 HandleZoomStripeAction(EZoomOut,aEvent.Code());
   387                 HandleZoomStripeAction(EZoomOut,aEvent.Code());
   406                 consumed = ETrue;
   388                 consumed = ETrue;
   407                 break ;
   389                 break ;
   408                 }
   390                 }                
   409             case EStdKeyIncVolume :
       
   410             case EKeyZoomIn :
       
   411             case EStdKeyNkpAsterisk :
       
   412                 {
       
   413                 GLX_LOG_INFO1("CGlxZoomControl::HandlekeyEvents VLUP=%d", aEvent.KeyEvent().iScanCode );
       
   414                 if (iZoomActivated)
       
   415                     {
       
   416                     HandleZoomKey(EZoomIn, aEvent.Code());
       
   417                     }
       
   418                 consumed = ETrue;
       
   419                 break;
       
   420                 }
       
   421             case EStdKeyDecVolume :
       
   422             case EKeyZoomOut :
       
   423             case EStdKeyHash :
       
   424                 {
       
   425                 GLX_LOG_INFO1("CGlxZoomControl::HandlekeyEvents VLUP_D=%d", aEvent.KeyEvent().iScanCode );    
       
   426                 HandleZoomKey(EZoomOut, aEvent.Code());
       
   427                 consumed = ETrue;
       
   428                 break;
       
   429                 }    
       
   430             default:
   391             default:
   431                 break;
   392                 break;
   432             }
   393             }
   433         }
   394         }
   434 
   395 
   435     return consumed;
   396     return consumed;
   436     }
       
   437 
       
   438 // -----------------------------------------------------------------------------
       
   439 // HandleZoomKey:Starts the Timer for contionous zoom
       
   440 // -----------------------------------------------------------------------------
       
   441 //
       
   442 void CGlxZoomPanEventHandler::HandleZoomKey(TZoomMode aZoomMode ,const TEventCode aEventCode )
       
   443     {
       
   444     TRACER("CGlxZoomControl::HandleZoomKey ");
       
   445     
       
   446     if ( EEventKeyDown == aEventCode )
       
   447         {
       
   448         CancelUITimer();
       
   449         iZoomEventHandler.HandleShowUi(ETrue);
       
   450         iZoomMode = aZoomMode ;
       
   451         StartZoomTimer();
       
   452         }
       
   453     else if ( EEventKeyUp == aEventCode )
       
   454         {
       
   455         CancelZoomPanTimer();
       
   456         StartUITimer(KGlxScreenTimeout,KGlxScreenTimeout,TCallBack( 
       
   457                 UiTimeOut,this )) ;
       
   458         }
       
   459     }
   397     }
   460 
   398 
   461 // -----------------------------------------------------------------------------
   399 // -----------------------------------------------------------------------------
   462 // HandleZoomStripeAction:Zooms the image on zoom stripe action.
   400 // HandleZoomStripeAction:Zooms the image on zoom stripe action.
   463 // -----------------------------------------------------------------------------
   401 // -----------------------------------------------------------------------------
   845     TRACER("CGlxZoomPanEventHandler::CallZoomOutL()");
   783     TRACER("CGlxZoomPanEventHandler::CallZoomOutL()");
   846     iZoomEventHandler.HandleZoomOutL(KGlxZoomOutCommand);
   784     iZoomEventHandler.HandleZoomOutL(KGlxZoomOutCommand);
   847     }
   785     }
   848 
   786 
   849 //----------------------------------------------------------------------------------
   787 //----------------------------------------------------------------------------------
   850 // ZoomTimerCallback:Callback function for the Zoom timer
       
   851 //----------------------------------------------------------------------------------
       
   852 //
       
   853 TInt CGlxZoomPanEventHandler::ZoomIntervalExpired(TAny* aPtr)
       
   854     {
       
   855     TRACER("CGlxZoomControl::ZoomIntervalExpired ");
       
   856     CGlxZoomPanEventHandler* self = static_cast<CGlxZoomPanEventHandler*>(aPtr);
       
   857     self->DoZoom();
       
   858     return 0; // Timer has finished
       
   859     }
       
   860 
       
   861 //----------------------------------------------------------------------------------
       
   862 // PanIntervalExpired:Callback function for the pan timer
   788 // PanIntervalExpired:Callback function for the pan timer
   863 //----------------------------------------------------------------------------------
   789 //----------------------------------------------------------------------------------
   864 //
   790 //
   865 TInt CGlxZoomPanEventHandler::PanIntervalExpired(TAny* aPtr)
   791 TInt CGlxZoomPanEventHandler::PanIntervalExpired(TAny* aPtr)
   866     {
   792     {
   869     CGlxZoomPanEventHandler* self = static_cast<CGlxZoomPanEventHandler*>(aPtr);
   795     CGlxZoomPanEventHandler* self = static_cast<CGlxZoomPanEventHandler*>(aPtr);
   870     self->DoPan();
   796     self->DoPan();
   871     return 0; // Timer has finished
   797     return 0; // Timer has finished
   872     }
   798     }
   873 
   799 
   874 //----------------------------------------------------------------------------------
       
   875 // DoZoom:calls zooming function and updates the slider value 
       
   876 //----------------------------------------------------------------------------------
       
   877 //    
       
   878 void CGlxZoomPanEventHandler::DoZoom()
       
   879     {
       
   880     TRACER("CGlxZoomPanEventHandler::DoZoom ");
       
   881     Zoom(0, 0, iZoomMode);
       
   882     }
       
   883 
       
   884 
   800 
   885 //----------------------------------------------------------------------------------
   801 //----------------------------------------------------------------------------------
   886 // DoPan:calls Panning function.
   802 // DoPan:calls Panning function.
   887 //----------------------------------------------------------------------------------
   803 //----------------------------------------------------------------------------------
   888 //    
   804 //    
   911 //    
   827 //    
   912 void CGlxZoomPanEventHandler::OrientationChanged(const TRect& aNewScreenRect)
   828 void CGlxZoomPanEventHandler::OrientationChanged(const TRect& aNewScreenRect)
   913     {
   829     {
   914     TRACER("CGlxZoomPanEventHandler::OrientationChanged ");
   830     TRACER("CGlxZoomPanEventHandler::OrientationChanged ");
   915     
   831     
       
   832     iMathsEngine.OrientationChanged(aNewScreenRect); // Needs to be called before Call to Zoom() inorder to Update the iScreenSize.
       
   833     
   916     Zoom(0, 0, iZoomMode) ;
   834     Zoom(0, 0, iZoomMode) ;
   917 
       
   918     iMathsEngine.OrientationChanged(aNewScreenRect);
       
   919     }
   835     }
   920 
   836 
   921 // -----------------------------------------------------------------------------
   837 // -----------------------------------------------------------------------------
   922 // ShowSlider
   838 // ShowSlider
   923 // -----------------------------------------------------------------------------
   839 // -----------------------------------------------------------------------------
   950 
   866 
   951 // -----------------------------------------------------------------------------
   867 // -----------------------------------------------------------------------------
   952 // ActivateZoom
   868 // ActivateZoom
   953 // -----------------------------------------------------------------------------
   869 // -----------------------------------------------------------------------------
   954 //
   870 //
   955 void CGlxZoomPanEventHandler::ActivateZoom(TInt /*aInitialZoomRatio*/, 
   871 void CGlxZoomPanEventHandler::ActivateZoom(TInt aInitialZoomRatio, 
   956         TSize aImageSize, 
   872         TSize aImageSize, 
   957         TZoomStartMode aStartMode, 
   873         TZoomStartMode aStartMode, 
   958         TInt aMinSliderRange, 
   874         TInt aMinSliderRange, 
   959         TInt aMaxSliderRange,
   875         TInt aMaxSliderRange,
   960         TSize& aOriginalDimensions, 
   876         TSize& aOriginalDimensions, 
   973               );
   889               );
   974     
   890     
   975     // Minimum and Maximum Zoom Ratio     
   891     // Minimum and Maximum Zoom Ratio     
   976     iMinZoomRatio = iZoomRatio = aMinSliderRange;
   892     iMinZoomRatio = iZoomRatio = aMinSliderRange;
   977     iMaxZoomRatio = aMaxSliderRange   ;
   893     iMaxZoomRatio = aMaxSliderRange   ;
       
   894     
       
   895     iInitialZoomRatio = aInitialZoomRatio;
   978 
   896 
   979     iMathsEngine.Initialize(center,
   897     iMathsEngine.Initialize(center,
   980             screenSize,
   898             screenSize,
   981             imageSize,
   899             imageSize,
   982             aOriginalDimensions,
   900             aOriginalDimensions,
   990 
   908 
   991     switch(aStartMode)
   909     switch(aStartMode)
   992         {
   910         {
   993         case EZoomStartKey :
   911         case EZoomStartKey :
   994             {
   912             {
   995             StartZoomTimer();            
   913             // Fix for issue EPKA-7ZX8FR: Vasco_wk03: Zoom In Key (Volume Up Key),
       
   914             // gradually Zooms the image to full extent on a single click.
       
   915             
       
   916             // We are not getting keyup event which cancle the timer so not
       
   917             // starting timer to do zoom
       
   918             Zoom(0, 0, iZoomMode);          
   996             }
   919             }
   997             break;
   920             break;
   998         case EZoomStartDoubleTap :
   921         case EZoomStartDoubleTap :
   999             {
   922             {
  1000             if (!iIsZoomingInAnimatedState)
   923             if (!iIsZoomingInAnimatedState)
  1046 // -----------------------------------------------------------------------------
   969 // -----------------------------------------------------------------------------
  1047 //
   970 //
  1048 // Todo: Combine both these HandleEvents
   971 // Todo: Combine both these HandleEvents
  1049 TBool CGlxZoomPanEventHandler::HandleEvent( const TAlfEvent& aEvent )
   972 TBool CGlxZoomPanEventHandler::HandleEvent( const TAlfEvent& aEvent )
  1050     {
   973     {
  1051     TRACER("CGlxZoomControl::HandleEvent()");
   974     TRACER("CGlxZoomPanEventHandler::HandleEvent()");
  1052     
   975     
  1053     TBool eventHandledState = EFalse;
   976     TBool eventHandledState = EFalse;
  1054     
   977     
  1055     if (iZoomActivated)
   978     if (iZoomActivated)
  1056         {
   979         {
  1121 // HandleEvent
  1044 // HandleEvent
  1122 // -----------------------------------------------------------------------------
  1045 // -----------------------------------------------------------------------------
  1123 //
  1046 //
  1124 TBool CGlxZoomPanEventHandler::HandleEventL(const TAlfEvent &aEvent)
  1047 TBool CGlxZoomPanEventHandler::HandleEventL(const TAlfEvent &aEvent)
  1125     {
  1048     {
  1126     TRACER("CGlxZoomControl::HandleEventL()");
  1049     TRACER("CGlxZoomPanEventHandler::HandleEventL()");
  1127     
  1050     
  1128     TBool consumed = EFalse;
  1051     TBool consumed = EFalse;
  1129 
  1052 
  1130     if (iZoomActivated)
  1053     if (iZoomActivated)
  1131         {
  1054         {
  1143     return consumed;
  1066     return consumed;
  1144     }
  1067     }
  1145 
  1068 
  1146 
  1069 
  1147 // -----------------------------------------------------------------------------
  1070 // -----------------------------------------------------------------------------
       
  1071 // ZoomToMinimum
       
  1072 // -----------------------------------------------------------------------------
       
  1073 //
       
  1074 void CGlxZoomPanEventHandler::ZoomToMinimumL()
       
  1075     {
       
  1076     TRACER("CGlxZoomPanEventHandler::ZoomToMinimumL( )");
       
  1077     
       
  1078     Zoom(iInitialZoomRatio, 0, EZoomOut);
       
  1079     CallZoomOutL();
       
  1080     }
       
  1081 
       
  1082 
       
  1083 // -----------------------------------------------------------------------------
  1148 // Zoom
  1084 // Zoom
  1149 // -----------------------------------------------------------------------------
  1085 // -----------------------------------------------------------------------------
  1150 //
  1086 //
  1151 
       
  1152 
       
  1153 void CGlxZoomPanEventHandler::Zoom(TInt aExpectedZoomLevel, TInt aRelativeZoomFactor, TZoomMode aZoomMode, TPoint* aZoomFocus)
  1087 void CGlxZoomPanEventHandler::Zoom(TInt aExpectedZoomLevel, TInt aRelativeZoomFactor, TZoomMode aZoomMode, TPoint* aZoomFocus)
  1154     {
  1088     {
  1155     TRACER("CGlxZoomControl::ZoomL( )");
  1089     TRACER("CGlxZoomPanEventHandler::ZoomL( )");
  1156     
  1090     
  1157     TPoint          viewPortTopLeft(0,0);
  1091     TPoint          viewPortTopLeft(0,0);
  1158     TSize           viewPortDimension(0,0);
  1092     TSize           viewPortDimension(0,0);
  1159     TBool           atZoomThreshold = EFalse;
  1093     TBool           atZoomThreshold = EFalse;
  1160     
  1094