photosgallery/slideshow/engine/effectsrc/shwzoomandpanlayout.h
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2007-2008 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:    Layout that performs zoom and fade
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef __SHWZOOMANDPANLAYOUT_H__
       
    22 #define __SHWZOOMANDPANLAYOUT_H__
       
    23 
       
    24 #include <glxlayout.h>
       
    25 //#include <alf/alfrealsize.h>
       
    26 #include <alf/alftimedvalue.h>
       
    27 #include <alf/alfcurvepath.h>
       
    28 
       
    29 #include "shwtimedvalue.h"
       
    30 
       
    31 // FORWARD DECLARATIONS
       
    32 class CHuiCurvePath;
       
    33 
       
    34 /**
       
    35  * TShwZoomAndPanLayout
       
    36  * Handles zooming and panning a visual
       
    37  * 
       
    38  * @author Kimmo Hoikka
       
    39  * @lib shwslideshowengine.lib
       
    40  * @internal reviewed 07/06/2007 by Loughlin
       
    41  * @internal reviewed 06/06/2007 by Dan Rhodes
       
    42  */
       
    43 NONSHARABLE_CLASS( TShwZoomAndPanLayout ) : public TGlxLayout
       
    44 	{
       
    45 	public:
       
    46 
       
    47 		/**
       
    48 		 * Enumeration for zoom direction.
       
    49 		 */
       
    50 		enum TZoomDirection
       
    51 			{
       
    52 			EZoomIn = 1,	// Zoom in, from minimum to maximum size
       
    53 			EZoomOut = 2	// Zoom out, from maximum to minimum size
       
    54 			};
       
    55 
       
    56 		/**
       
    57 		 * Constructor, initializes the layout.
       
    58 		 */
       
    59 		TShwZoomAndPanLayout();
       
    60 
       
    61 		/**
       
    62 		 * Destructor
       
    63 		 */
       
    64 		~TShwZoomAndPanLayout();
       
    65 
       
    66 		/**
       
    67 		 * Sets the screen and image size
       
    68 		 * @param aScreenSize the size of the screen.
       
    69 		 * @param aImageSize the size of the image.
       
    70 		 * @param aMaximumSize the maximum ever size for the image
       
    71 		 * @return the zoom factor, this enables the client to deside 
       
    72 		 *			if it makes sense to do any zoomimg
       
    73 		 */
       
    74 		TReal32 SetSizes( 
       
    75 		    TSize aScreenSize, TSize aImageSize, TSize aMaximumSize );
       
    76 
       
    77 		/**
       
    78 		 * Sets the curve for pan. The curve must be defined so that in
       
    79 		 * 100% zoom it stays inside the image (no black borders shown)
       
    80 		 * basically this means a box inside image coordinates:
       
    81 		 * xi = image.width/2;
       
    82 		 * yi = image.height/2;
       
    83 		 *
       
    84 		 *  (-xi,yi)-------------(xi,yi)
       
    85 		 *  |  (-xb,yb)-------(xb,yb)  |
       
    86 		 *  |  |                    |  |
       
    87 		 *  |  (-xb,-yb)-----(xb,-yb)  |
       
    88 		 *  (-xi,-yi)-----------(xi,-yi)
       
    89 		 *
       
    90 		 * where:
       
    91 		 *  xb = xi - screen.width/2;
       
    92 		 *  yb = yi - screen.height/2;
       
    93 		 *
       
    94 		 * During zoom the panning curve is scaled according to current
       
    95 		 * zoom factor so that no black borders show in zoom factors < 100%
       
    96 		 *
       
    97 		 * @param aCurve the curve to use for the panning.
       
    98 		 */
       
    99 		void SetPanningCurve( CAlfCurvePath* aCurve );
       
   100 
       
   101         /**
       
   102          * This method returns the maximum zoom size for the image
       
   103          * Should not be called before before SetSizes is called
       
   104          * @return the maximum size as TSize
       
   105          */
       
   106         TSize MaximumSize();
       
   107 
       
   108 		/**
       
   109 		 * This method resets the size to minimum. Usefull when you dont 
       
   110 		 * want to do zoom & pan (for example the image is too small)
       
   111 		 */
       
   112 		void ResetSizeToMinimum();
       
   113 
       
   114 		/**
       
   115 		 * This method starts the zooming. If a pannig curve is used 
       
   116 		 * it should be set before calling this method. Note, for zoom in
       
   117 		 * the layout uses the first half of the curve and for zoom out
       
   118 		 * the latter half; this enables you to use an ellipsis to have
       
   119 		 * looping zoomin
       
   120 		 *
       
   121 		 * @param aZoomDirection the desired zoom direction
       
   122 		 * @param aDuration the length of the zoom loop
       
   123 		 */
       
   124 		void StartZoom( TZoomDirection aZoomDirection, TInt aDuration );
       
   125 
       
   126 		/** 
       
   127 		 * This method inverts the zoom the opposite way
       
   128 		 */
       
   129 		TInt InvertZoom();
       
   130 
       
   131 		/**
       
   132 		 * This method pauses zoom and pan
       
   133 		 */
       
   134 		void Pause();
       
   135 
       
   136 		/**
       
   137 		 * This method resumes zoom and pan after pause.
       
   138 		 */
       
   139 		void Resume();
       
   140 
       
   141 	protected:	// From TGlxLayout
       
   142 
       
   143 		/// @ref TGlxLayout::DoSetLayoutValues
       
   144 		void DoSetLayoutValues( TGlxLayoutInfo& aInfo );
       
   145 		/// @ref TGlxLayout::DoChanged
       
   146 		TBool DoChanged() const;
       
   147 		/// @ref TGlxLayout::DoClearChanged
       
   148 		void DoClearChanged();
       
   149 
       
   150 	private:	// Data and private parts
       
   151 
       
   152 		/// Helper to calculate minimum and maximum size
       
   153 		void CalculateMinAndMaxSize( TSize aMaximumSize );
       
   154 		/// Own: Screen size
       
   155 		TAlfRealSize iScreenSize;
       
   156 		/// Own: Image size
       
   157 		TAlfRealSize iImageSize;
       
   158 		/// Own: the maximum size
       
   159 		TAlfRealSize iMaximumSize;
       
   160 		/// Own: the minimum size
       
   161 		TAlfRealSize iMinimumSize;
       
   162 		/// Own: the zoom direction
       
   163 		TZoomDirection iZoomDirection;
       
   164 		/// Own: the zoom duration
       
   165 		TInt iZoomDuration;
       
   166 		/// Own: the zoomed size
       
   167 		TShwTimedSize iZoomedSize;
       
   168 		/// Own: Pan curve position
       
   169 		TShwTimedValue iCurvePosition;
       
   170 		/// Ref: Pan curve
       
   171 		CAlfCurvePath* iPanningCurve;
       
   172 
       
   173 	};
       
   174 
       
   175 #endif // __SHWZOOMANDPANLAYOUT_H__