photosgallery/viewframework/views/zoomview/inc/glxzoomcontrol.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:    Definition of CGlxZoomControl
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_GLXZOOMCONTROL_H
       
    20 #define C_GLXZOOMCONTROL_H
       
    21 
       
    22 // INCLUDES
       
    23 
       
    24 #include <w32std.h>            // For TEventCode
       
    25 
       
    26 #include <alf/alfcontrol.h>
       
    27 #include <alf/ialfwidgeteventhandler.h>
       
    28 #include <gestureobserver.h>
       
    29 #include <gesturehelper.h>
       
    30 
       
    31 #include <mglxtextureobserver.h>
       
    32 #include <mglxmedialist.h>
       
    33 #include <mglxzoomeventhandlers.h>
       
    34 #include <glxfullscreenview.hrh>
       
    35 #include <glxzoomeventhandler.h>
       
    36 #include <mglxtvobserver.h>     // for inteface MGlxTvObserver
       
    37 //Gesture Helper namespace
       
    38 namespace GestureHelper
       
    39     {
       
    40     class CGestureHelper;
       
    41     }
       
    42 
       
    43 
       
    44 namespace Alf
       
    45     {
       
    46     class IAlfViewWidget;
       
    47     class IMulSliderWidget;
       
    48     class IMulSliderModel;
       
    49     class IAlfWidgetEventHandler;
       
    50     }
       
    51 // FORWARD DECLARATIONS
       
    52 class CGlxDefaultAttributeContext;
       
    53 class CGlxUiUtility;
       
    54 class MGlxUiCommandHandler;
       
    55 class CAlfImageVisual;
       
    56 class CAlfViewportLayout;
       
    57 class TAlfImage;
       
    58 class CEikButtonGroupContainer;
       
    59 class CGlxTextureManager;
       
    60 class CGestureHelper;
       
    61 class MGestureObserver;
       
    62 
       
    63 class CGlxTv;
       
    64 using namespace Alf;
       
    65 
       
    66 // Commands sent to the view in response to zoom keys
       
    67 const TInt KGlxZoomInCommand    = 1 ;
       
    68 const TInt KGlxZoomOutCommand   = 2 ;
       
    69 const TInt KGlxVerticalImageOrientationThreshold   = 4 ;
       
    70 
       
    71 /**
       
    72  * Control for zooming in the FullScreen view.
       
    73  * @ingroup glx_view_zoomed_view
       
    74  */
       
    75 class CGlxZoomControl : public CAlfControl,
       
    76                         public IAlfWidgetEventHandler,
       
    77                         public MGlxTextureObserver,
       
    78                         public MGlxZoomEventHandlers,
       
    79                         public GestureHelper::MGestureObserver,
       
    80                         public MGlxTvObserver
       
    81     {
       
    82 public:
       
    83     // Constructors and destructor
       
    84     /**
       
    85     * Two-phased constructor.
       
    86     * @param aCommandHandler: Handler for commands.
       
    87     * @param aMediaList     : Reference to media list.
       
    88     * @param aZoomKeys      : Reference to Back Key.
       
    89     * @param aSliderWidget  : Reference to  slider widget created in fullscreen view.
       
    90     */
       
    91     IMPORT_C static CGlxZoomControl* NewL(
       
    92     MGlxUiCommandHandler& aCommandHandler,
       
    93     MGlxMediaList& aMediaList,CEikButtonGroupContainer& aZoomKeys,
       
    94     IMulSliderWidget& aSliderWidget, GestureHelper::CGestureHelper* aGestureHelper);
       
    95 
       
    96     /**
       
    97     * Destructor.
       
    98     */
       
    99     ~CGlxZoomControl();
       
   100 
       
   101     /**
       
   102     * Show the control and begin zooming in.
       
   103     * @param aIntialZoomLevel:The Initial Zoom Level shown when zoom is active from full screen view.
       
   104     * @param aTap            :if the zoom was launched by tapping or by pressing volume key.
       
   105     */
       
   106     IMPORT_C void ActivateL(TInt aIntialZoomRatio,TZoomStartMode aStartMode,TInt aFocusIndex, 
       
   107                                     TGlxMedia& aItem,  TPoint* aZoomFocus = NULL);
       
   108 
       
   109     /**
       
   110     * Hide the control and disable zooming.
       
   111     */
       
   112     IMPORT_C void Deactivate();
       
   113 
       
   114     /**
       
   115     * to check if the zoom  control is activated?
       
   116     */
       
   117     IMPORT_C TBool Activated();
       
   118 
       
   119     /**
       
   120     * Zoom Foreground event handling function
       
   121     * @param aForeground: value signify if it is in foreground or not.
       
   122     */
       
   123     IMPORT_C void HandleZoomForegroundEvent(TBool aForeground);
       
   124 
       
   125     void UpdateViewPort(
       
   126             TPoint& aViewPortTopLeft ,
       
   127             TInt aTransitionTime ,
       
   128             TSize  *apViewPortDimension = NULL,
       
   129             TInt aPrimarySliderLevel = -1);
       
   130 private:// From MGlxTvObserver
       
   131     virtual void HandleTvStatusChangedL ( TTvChangeType aChangeType );
       
   132 
       
   133 private:  // From CAlfControl
       
   134     TBool OfferEventL(const TAlfEvent &aEvent);
       
   135 
       
   136     void VisualLayoutUpdated(CAlfVisual &aVisual);
       
   137 
       
   138 private:  //From IAlfWidgetEventHandler
       
   139     AlfEventStatus offerEvent( CAlfWidgetControl& /*aControl*/, const TAlfEvent& aEvent );
       
   140 
       
   141     bool accept( CAlfWidgetControl& aControl, const TAlfEvent& aEvent ) const;
       
   142 
       
   143     void setEventHandlerData( const AlfWidgetEventHandlerInitData& aData );
       
   144 
       
   145     AlfWidgetEventHandlerInitData* eventHandlerData();
       
   146 
       
   147     void setActiveStates( unsigned int aStates );
       
   148 
       
   149     IAlfInterfaceBase* makeInterface( const IfId& aType );
       
   150 
       
   151     AlfEventHandlerType eventHandlerType() ;
       
   152 
       
   153     AlfEventHandlerExecutionPhase eventExecutionPhase() ;
       
   154 
       
   155 private: // From MGlxTextureObserver
       
   156     void TextureContentChangedL( TBool aHasContent , CAlfTexture* aNewTexture);
       
   157 
       
   158 private: // From MGlxZoomEventHandlers
       
   159     void HandleViewPortParametersChanged(TPoint& aViewPortTopLeft ,
       
   160             TInt aTransitionTime ,
       
   161             TSize  *apViewPortDimension = NULL,
       
   162             TInt aPrimarySliderLevel = -1);
       
   163 
       
   164     void HandleShowUi(TBool aShow= EFalse) ;
       
   165 
       
   166     void HandleZoomOutL(TInt aCommandId);
       
   167 private:
       
   168         /*
       
   169         * Call back function for the CPeriodic
       
   170         */
       
   171        static TInt TimeOut(TAny* aSelf);
       
   172        void ActivateFullscreen();
       
   173        void StartZoomAnimation();
       
   174 
       
   175 private:
       
   176     /**
       
   177     * C++ default constructor.
       
   178     */
       
   179     CGlxZoomControl(MGlxUiCommandHandler& aCommandHandler,
       
   180             MGlxMediaList& aMediaList,CEikButtonGroupContainer& aZoomKeys,
       
   181             IMulSliderWidget& aSliderWidget, GestureHelper::CGestureHelper* aGestureHelper);
       
   182     /**
       
   183     * Does the necessary Initialization of iUiUtility,control group and the Media list.
       
   184     */
       
   185     void ConstructL();
       
   186     /**
       
   187     * Creation of zoomvisual:creates the zoom visual and sets the Black Background behind the image
       
   188     * and also sets the ViewPort Layout.
       
   189     */
       
   190     void CreateZoomVisualL();
       
   191     /**
       
   192     * Turn the UI/Screen Furniture[Back Key/Slider] on
       
   193     */
       
   194     void ShowUi(TBool aShow);
       
   195 
       
   196     /**
       
   197     * Cleanup function resets all the memeber variable on deactivating the ZoomControl
       
   198     */
       
   199     void CleanUpVisual();
       
   200 
       
   201     /*
       
   202     * Get Orientation of the file ,
       
   203     * This code is DUPLICATE and second copy implemented in bitmapdecoder,
       
   204     * Got to plan for removing this duplicacy
       
   205     */
       
   206     TUint16 GetOrientationL(const TDesC& aFileName) ;
       
   207 
       
   208     /*
       
   209     * This Function Shows/Hides the zoom
       
   210     * by setting the level of Opacity
       
   211     */
       
   212     void ShowZoom(TBool aShow);
       
   213 
       
   214     /*
       
   215     * Retrieves the Screensize with the help of Alf utility
       
   216     */
       
   217     TSize ScreenSize();
       
   218 
       
   219     void HandleGestureL( const GestureHelper::MGestureEvent& aEvent );
       
   220 
       
   221     TBool HandlePointerEventsL(const TAlfEvent &aEvent);
       
   222     
       
   223     TInt GetIntialZoomLevel(TSize& aSize );
       
   224 
       
   225 private:    // Data
       
   226     CAlfEnv* iEnv;                                      // AlfEnv
       
   227     MGlxMediaList& iMediaList;                          // Medialist (not owned)
       
   228     GestureHelper::CGestureHelper* iGestureHelper;                     // Attribute context for image dimensions
       
   229     IMulSliderModel* iZoomSliderModel;                  // Zoom slider model
       
   230     IMulSliderWidget& iZoomSliderWidget;                // Zoom slider Widget
       
   231     CEikButtonGroupContainer* iZoomBackKey;             // Back zoom soft key(not owned)
       
   232     CGlxDefaultAttributeContext* iAttributeContext;     // Attribute context for image dimensions
       
   233 
       
   234     CAlfDisplay* iDisplay;                              // Alf Display
       
   235     CGlxUiUtility* iUiUtility;                          // UI utility
       
   236     CGlxTextureManager* iTextureMgr;                    // TextureManager
       
   237     CAlfControlGroup* iControlGroup;                    // Control group for the Zoom control
       
   238 
       
   239     CAlfViewportLayout* iViewPort;                      // Parent Layout for Zooming/Panning
       
   240     CAlfImageVisual* iImageVisual;                      // Child visual for normal image items (not owned)
       
   241     CAlfTexture* iImageTexture;                         // Texture to be zoomed
       
   242 
       
   243     TBool iIsdrag;                                      // To determine if drag occured to evaluate the single tap
       
   244     TBool iZoomActive;                                  // This variable is updated when Zoom is activated.
       
   245     TSize iOriginalDimensions;
       
   246 
       
   247     MGlxUiCommandHandler& iCommandHandler;              // For Handling ZoomOut commands
       
   248     CGlxZoomPanEventHandler* iEventHandler;             // The event handler for the Zoom Pan Engine
       
   249 
       
   250     TSize iScreenSize;
       
   251     TBool iMultiTouchGestureOngoing;
       
   252     CGlxTv*  iGlxTvOut;
       
   253     CPeriodic* iTimer;
       
   254     TBool iZoomIn;
       
   255     };
       
   256 
       
   257 #endif  // C_GLXZOOMCONTROL_H
       
   258 
       
   259 // End of File