photosgallery/viewframework/views/zoomview/inc/glxzoomeventhandler.h
changeset 0 4e91876724a2
child 1 9ba538e329bd
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     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     /*
       
    66      * ActivateZoom from the Zoom control
       
    67      */
       
    68     void ActivateZoom(TInt initialZoomRatio, 
       
    69                         TSize imageSize, 
       
    70                         TZoomStartMode aStartMode, 
       
    71                         TInt aMinSliderRange, 
       
    72                         TInt aMaxSliderRange,
       
    73                         TSize& aOriginalDimensions, 
       
    74                         TPoint* aZoomFocus);
       
    75     
       
    76     /*
       
    77      * DeactivateZoom from the Zoom control
       
    78      */
       
    79     void DeactivateZoom();
       
    80     
       
    81     /*
       
    82      * OrientationChanged
       
    83      */
       
    84     void OrientationChanged(const TRect& aNewScreenRect) ;
       
    85     
       
    86     /*
       
    87      * ZoomIsActivated
       
    88      * This is called when the zoom is activated/deactivated from Zoom control
       
    89      */
       
    90     void SetZoomActivated(TBool aIsActivated = EFalse);
       
    91     
       
    92     /*
       
    93      * ZoomUiState 
       
    94      * This is called when the zoom state in Zoom control is changed
       
    95      */
       
    96     void SetZoomUiState(TUiState aZoomUiState);
       
    97     
       
    98     /*
       
    99      * ZoomUiState 
       
   100      * This is called when the zoom state in Zoom control is changed
       
   101      */
       
   102     TUiState ZoomUiState();
       
   103     
       
   104     /**
       
   105     * Handle the drag events for panning
       
   106     */
       
   107     void HandleDragEvent(const GestureHelper::MGestureEvent& aEvent );
       
   108     
       
   109     void HandlePinchEventL(const GestureHelper::MGestureEvent& aEvent);
       
   110     
       
   111     void HandleDoubleTap(const GestureHelper::MGestureEvent& aEvent );
       
   112     
       
   113     void HandleSingleTap(const GestureHelper::MGestureEvent& aEvent );
       
   114     
       
   115     void HandleGestureReleased(const GestureHelper::MGestureEvent& aEvent );
       
   116     
       
   117     void SetPreviousEventCode(const GestureHelper::TGestureCode code );
       
   118     
       
   119     void HandleMultiTouchReleased();
       
   120     
       
   121 private:
       
   122     /*
       
   123      * Constructor
       
   124      */
       
   125     CGlxZoomPanEventHandler(MGlxZoomEventHandlers& aZoomEventHandler);
       
   126     
       
   127     /*
       
   128      * ConstructL
       
   129      */
       
   130     void ConstructL();
       
   131 
       
   132     /**
       
   133     *  This Function handles all the KeyEvents 
       
   134     */
       
   135     TBool HandlekeyEvents(const TAlfEvent &aEvent);
       
   136     
       
   137     /**
       
   138     * Callback function for zoom 
       
   139     */     
       
   140     static TInt ZoomIntervalExpired(TAny* aPtr);
       
   141     
       
   142     /**
       
   143     * Callback function for pan
       
   144     */ 
       
   145     static TInt PanIntervalExpired(TAny* aPtr);
       
   146     
       
   147     /**
       
   148     * Start zoom in/out continously
       
   149     */     
       
   150     void DoZoom();
       
   151     
       
   152     // Zoom by the next zoom increment.
       
   153     // aZoomMode is ignored if aExpectedZoomLevel has a positive value
       
   154     void Zoom(TInt aExpectedZoomLevel, TInt aRelativeZoomFactor, TZoomMode aZoomMode = EZoomIn, TPoint* aZoomFocus = NULL);
       
   155     /**
       
   156     * Start Panning continously
       
   157     */     
       
   158     void DoPan();
       
   159     
       
   160     /**
       
   161     * Starts the timer for continous zooming
       
   162     */     
       
   163     void StartZoomTimer();
       
   164     
       
   165     /**
       
   166     * Starts the timer for continous Panning
       
   167     */ 
       
   168     void StartPanTimer();
       
   169     
       
   170     /**
       
   171     * Stops the timer for showing the UI. 
       
   172     */ 
       
   173     void CancelUITimer();
       
   174     
       
   175     /**
       
   176     * Starts the timer for showing the UI.
       
   177     */ 
       
   178     void StartUITimer(TTimeIntervalMicroSeconds32 aDelay,
       
   179             TTimeIntervalMicroSeconds32 anInterval,
       
   180             TCallBack aCallBack) ;
       
   181     
       
   182     /**
       
   183     *Call back function to Turn off UI/Screen Furniture[Back Key/Slider].
       
   184     */
       
   185     static TInt UiTimeOut(TAny* aSelf);
       
   186     
       
   187     /*
       
   188      * Timer callback for zoomout 
       
   189      */
       
   190     static TInt ZoomOutTimerL(TAny* aSelf);
       
   191     
       
   192     /**
       
   193     * Handle zoom key pressed or released.
       
   194     * @param aZoomIn    :ETrue for Zoom In key, EFalse for Zoom Out key
       
   195     * @param aEventCode :Type of key event.
       
   196     */
       
   197     void HandleZoomKey(TZoomMode aZoomMode, const TEventCode aEventCode);
       
   198     
       
   199     /**
       
   200     * Handle the key events for panning
       
   201     * @param aPanDirection: Specifies the pan direction
       
   202     * @param aEvent       : Specifies the event values.
       
   203     */
       
   204     TBool HandlePanKey(const TAlfEvent &aEvent);
       
   205     
       
   206     /**
       
   207     * Handle zoom stripe key pressed.
       
   208     * @param aZoomIn    :ETrue for Zoom In key, EFalse for Zoom Out key
       
   209     * @param aEventCode :Type of key event.
       
   210     */
       
   211     void HandleZoomStripeAction(TZoomMode aZoomMode ,TEventCode aEventCode);
       
   212     
       
   213     /**
       
   214     * Handle the drag events for panning
       
   215     */
       
   216     void HandleDragEvent(const TPoint &aTapPoint);
       
   217     
       
   218     /*
       
   219      * ShowSliderTillTimeout
       
   220      */
       
   221     void ShowSliderTillTimeout() ;
       
   222     
       
   223     /*
       
   224      * ShowScreenFurniture
       
   225      * aTimeout == 0 means no timeout.
       
   226      */
       
   227     void ShowScreenFurniture(TTimeIntervalMicroSeconds32 aTimeout);
       
   228     
       
   229     /*
       
   230      * HideScreenFurniture
       
   231      */
       
   232     void HideScreenFurniture();
       
   233     
       
   234     /*
       
   235      * SetupPanOperation
       
   236      */
       
   237     void SetupPanOperation(TPoint& aPanDirection);
       
   238 
       
   239     void CallZoomOutL();    
       
   240 
       
   241     void SetupAnimatedZoom(TZoomMode aZoomMode, TPoint * aZoomFocus = NULL);
       
   242     
       
   243     static TInt ActivationIntervalElapsed(TAny* aPtr) ;
       
   244     
       
   245     void NextStepAnimatedZoom();
       
   246         
       
   247     void SetupAnimatedPan() ; 
       
   248     
       
   249     static TInt PanInertiaFrameElapsed(TAny* aPtr);
       
   250 
       
   251     void NextStepInerticPan();
       
   252 
       
   253     void CancelAnimationTimer();
       
   254     
       
   255 
       
   256     
       
   257 private:
       
   258     MGlxZoomEventHandlers&  iZoomEventHandler; 
       
   259 
       
   260     TTime               iPanTime;                       // The Purpose of this Variable is to determine the Time,for how long the key was held
       
   261     TZoomMode           iZoomMode;                      // Says whether we are zooming in or out.  
       
   262     TPoint              iPanDirection;                  // This gives the direction of the panning that has to be done
       
   263     TInt                iMinZoomRatio;                // The minimum value that the Zoom Slider will have  
       
   264     TInt                iMaxZoomRatio;                // The maximum value that the Zoom Slider will have
       
   265 
       
   266     CPeriodic*          iUiTimer;                       // The Timer used to Hide the UI/Screen Furniture[Back Key/Slider] after 2 seconds
       
   267     CPeriodic*          iZoomPanTimer;                  // The Timer used  for Zooming/Panning the Image Exponentially
       
   268     TPoint              iStartDisplayPoint;             // The variable holds the starting pointer posistion to determine the Drag Distance
       
   269     TTime               iDoubleTap;                     // This Variable is used to determine the double tap,by using the difference of the time 
       
   270                                                         // between subsequent single Tap.
       
   271     // [todo] do we need this variable to be global
       
   272     TInt                iZoomRatio;
       
   273     TRect               iDoubleTapRect;                 // This varaible holds the rect for the Double Tap
       
   274     TBool               iDragOngoing;                   // Is a drag event ongoing
       
   275     TBool               iZoomActivated;                 // To Denote if zoom is activated
       
   276     TUiState            iZoomUiState;                   // To Denote if the Ui is On in zoom
       
   277     
       
   278     TPoint              iPreviousPointerPosition;
       
   279     TPoint              iPreviousDragStartPosition;
       
   280 
       
   281     // for the animated zoom to 50 % allowed. 
       
   282     TBool               iIsZoomingInAnimatedState;
       
   283     TAnimationMode      iAnimatedZoomMode;
       
   284     CPeriodic*          iZoomAnimationTimer;
       
   285     TInt                iZoomPerInterval;
       
   286     TInt                iTargetAnimatedZoomRatio;
       
   287     // for the animated zoom to 50 % allowed. END 
       
   288 
       
   289     // For considering Zoom Focus. 
       
   290     TPoint              iZoomFocus;            // Not used right now. WIll soon carry the coordinates of the zoom focus. 
       
   291     // For considering Zoom Focus. END 
       
   292     
       
   293     // For Pan Inertia.
       
   294     GestureHelper::TGestureCode        iPreviousGestureCode ;
       
   295     // For Pan Inertia. END
       
   296     
       
   297     
       
   298     
       
   299     TGlxZoomAndPanMathsEngine iMathsEngine;             // The new Maths engine at the core of the Zoom Component
       
   300     
       
   301     
       
   302     };
       
   303 
       
   304 
       
   305 #endif /* GLXZOOMEVENTHANDLER_H_ */