camerauis/cameraapp/generic/inc/CamZoomPane.h
branchRCL_3
changeset 24 bac7acad7cb3
child 25 2c87b2808fd7
equal deleted inserted replaced
23:61bc0f252b2b 24:bac7acad7cb3
       
     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:  Class for Camera Zoom Pane*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 #ifndef CAMZOOMPANE_H
       
    20 #define CAMZOOMPANE_H
       
    21 
       
    22 //  INCLUDES
       
    23 #include <coecntrl.h>
       
    24 #include <eiklabel.h>
       
    25 #include <AknUtils.h>               // for TAknLayout
       
    26 #include "CamPSI.h"                 // For Product Specific Information
       
    27 #include "CamAppController.h"   // For controller definition
       
    28 #include "CamSettings.hrh"          // For TCamPhotoSizeId
       
    29 #include "CamSettingsInternal.hrh"
       
    30 #include "CamResourceLoader.h"
       
    31 #include "CamZoomModel.h"
       
    32 #include "CamBmpRotatorAo.h"
       
    33 
       
    34 // CONSTANTS
       
    35 
       
    36 // MACROS
       
    37 
       
    38 // DATA TYPES
       
    39 
       
    40 // FUNCTION PROTOTYPES
       
    41 
       
    42 // FORWARD DECLARATIONS
       
    43 class CCamRemConObserver;
       
    44 class MTouchFeedback;
       
    45 
       
    46 // CLASS DECLARATION
       
    47 
       
    48 /**
       
    49 *  Class for showing the current zoom level in a side pane.
       
    50 *
       
    51 *  @since 2.8
       
    52 */
       
    53 class CCamZoomPane : public CBase, 
       
    54                      public MCamControllerObserver,
       
    55                      public MCamResourceLoader
       
    56     {
       
    57     // Private data type used internally by the zoom pane 
       
    58     // to store the orientation it should be drawn    
       
    59     enum TZPOrientation
       
    60         {
       
    61         EZPOrientationVertical = 0,
       
    62         EZPOrientationHorizontal = 1
       
    63         };
       
    64     
       
    65     public:  // Constructors and destructor
       
    66         
       
    67         /**
       
    68         * Two-phased constructor.
       
    69         * @param aController handle to camera application controller
       
    70         * @param aOverlayViewFinder whether zoom pane is drawn over view finder
       
    71         */
       
    72         static CCamZoomPane* NewL( CCamAppController& aController,
       
    73                                    TBool aOverlayViewFinder );
       
    74         
       
    75         /**
       
    76         * Destructor.
       
    77         */
       
    78         virtual ~CCamZoomPane();
       
    79 
       
    80     public: // From MCamResourceLoader    
       
    81         /**
       
    82         * From MCamResourceLoader
       
    83         * @since 3.0
       
    84         */
       
    85         void LoadResourceDataL();
       
    86 
       
    87         /**
       
    88         * From MCamResourceLoader
       
    89         * @since 3.0
       
    90         */
       
    91         void UnloadResourceData();
       
    92 
       
    93         /**
       
    94         * From MCamResourceLoader
       
    95         * @since 3.0
       
    96         */
       
    97         void ReloadResourceDataL();
       
    98         
       
    99     public: // New functions
       
   100         /**
       
   101         * Sets the range of values to be represented on the Zoom Pane "shaft".
       
   102         * These values should be retrieved from the CCaeEngine
       
   103         * @since 2.8
       
   104         * @param aMin The minimum supported value (typically zero)
       
   105         * @param aMax The maximum supported value (one or more)
       
   106         * @return KErrNone if parameters are valid, else KErrArgument
       
   107         */
       
   108         TInt SetZoomRange( TInt aMin, TInt aMax );
       
   109 
       
   110         /**
       
   111         * Sets the current zoom level.  Must be within (inclusive) range passed
       
   112         * to the SetZoomRange function.
       
   113         * @since 2.8
       
   114         * @param aZoom New zoom value to use.
       
   115         * @return KErrNone if parameter valid, else KErrArgument
       
   116         */    
       
   117         TInt SetZoomValue( TInt aZoom );
       
   118 
       
   119         /**
       
   120         * Sets the keys to be intepreted as zoom keys
       
   121         * @since 3.0
       
   122         * @param aZoomIn Zoom in key scancode
       
   123         * @param aZoomOut Zoom out key scancode
       
   124         */
       
   125         void SetZoomKeys( const RArray<TInt>& aZoomIn,
       
   126                           const RArray<TInt>& aZoomOut );
       
   127 
       
   128         /**
       
   129         * Gets the current zoom step
       
   130         * @since 2.8
       
   131         * @returns The current zoom step
       
   132         */
       
   133         TInt ZoomValue() const;
       
   134 
       
   135         /**
       
   136         * Returns whether or not the Zoom Pane can currently be shown.
       
   137         * @since 2.8
       
   138         * @return ETrue if the Zoom Pane is allowed to be shown, else EFalse
       
   139         */    
       
   140         TBool OkToShowPane() const;
       
   141 
       
   142         /**
       
   143         * Is the zoom pane is visible
       
   144         * @since 2.8
       
   145         * @return ETrue if the zoom pane is visible
       
   146         */   
       
   147         TBool IsVisible() const;
       
   148 
       
   149         /**
       
   150         * Tells the zoom pane whether it is on display
       
   151         * @since 2.8
       
   152         * @param aVisible ETrue to make the zoom pane invisible
       
   153         * @param aRedraw Whether to force a redraw event
       
   154         */   
       
   155         void MakeVisible( TBool aVisible, TBool aRedraw );
       
   156 
       
   157         /**
       
   158         * Draws the zoom pane
       
   159         * @since 2.8
       
   160         * @param aGc The graphics context to use for drawing
       
   161         */
       
   162         void Draw( CBitmapContext& aGc ) const;
       
   163 
       
   164         /**
       
   165         * Set draw rect
       
   166         * @since 2.8
       
   167         * @param aRect Rect zoom pane draws into
       
   168         */
       
   169         void SetRect( TRect aRect );
       
   170 
       
   171         /**
       
   172         * Handles zoom-key operation, passed in from the container.
       
   173         * @since 2.8
       
   174         * @param aKeyEvent The key event
       
   175         * @param aType the key type
       
   176         * @return Whether this key event was consumed or not
       
   177         */
       
   178         TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
   179 
       
   180         /**
       
   181         * Returns the zoom pane rect
       
   182         * @since 3.0
       
   183         * @return the zoom pane rect
       
   184         */
       
   185         TRect Rect() const;
       
   186         
       
   187         /**
       
   188         * Called when the parent gains or loses foreground
       
   189         * @param aForeground ETrue if gained foreground, else EFalse
       
   190         * @since 3.0
       
   191         */
       
   192         void HandleForegroundEvent( TBool aForeground );
       
   193 
       
   194         /**
       
   195         * Sets the number of zoom steps for each type of zoom to be
       
   196         * reflected in the zoom pane shaft
       
   197         * @param aOptSteps The number of optical zoom steps
       
   198         * @param aStdSteps The number of digital zoom steps
       
   199         * @param aExtSteps The number of extended digital zoom steps
       
   200         * @since 3.0
       
   201         */
       
   202         void SetZoomSteps( TInt aOptSteps, TInt aStdSteps, TInt aExtSteps );
       
   203         
       
   204         /**
       
   205         * Returns whether there is currently an ongoing zoom operation.
       
   206         * @since 3.0
       
   207         * @return ETrue if zooming, else EFalse
       
   208         */
       
   209         TBool IsCurrentlyZooming() const;
       
   210         
       
   211         /**
       
   212         * Indicates that the zoom level should be reset to default
       
   213         * when the engine is next prepared
       
   214         * @since 2.8
       
   215         * @param aReset ETrue if the zoom pane should be reset, else EFalse
       
   216         */
       
   217         void ResetToDefaultAfterPrepare( TBool aReset );
       
   218         
       
   219         /**
       
   220         * Indicates whether or not the zoom level is waiting to be reset to default
       
   221         * @since 3.0
       
   222         * @return TBool ETrue if a reset is pending, othewise EFalse
       
   223         */       
       
   224         TBool IsResetPending() const;
       
   225         
       
   226         /**
       
   227         * Sets a point position to be based on another point plus an optional offset.
       
   228         * Used for moving along the slider.  Whether the X or Y part of the point 
       
   229         * changes is dependent on the current orientation
       
   230         * @since 3.0
       
   231         * @param aPoint This point will be overwritten with the new X/Y values
       
   232         * @param aOffset This is the basis for the new value for 'aPoint'
       
   233         * @param aAddditional This is an additional modification to 'aOffset' value
       
   234         */       
       
   235         void SetPoint( TPoint& aPoint, const TPoint& aOffset, TInt aAdditional = 0) const; 
       
   236 
       
   237         /**
       
   238         * Returns whether the current zoom value is the minimum zoom
       
   239         * @since 3.1
       
   240         * @return Whether the current zoom value is the minimum zoom
       
   241         */
       
   242         TBool IsZoomAtMinimum() const;
       
   243 
       
   244         /**
       
   245         * Returns whether the current zoom value is the maximum zoom
       
   246         * @since 5.1
       
   247         * @return Whether the current zoom value is the maximum zoom
       
   248         */
       
   249         TBool IsZoomAtMaximum() const;
       
   250 
       
   251         /**
       
   252         * Zooms to max zoom value
       
   253         * @since 5.1
       
   254         */                        
       
   255         void ZoomToMaximum();
       
   256 
       
   257         /**
       
   258         * Zooms to min zoom value
       
   259         * @since 5.1
       
   260         */                        
       
   261         void ZoomToMinimum();
       
   262 
       
   263         /**
       
   264         * Stops all zooming activity
       
   265         */
       
   266         void StopZoom();
       
   267         
       
   268         /***
       
   269         * Resets the zoom (digital, and, if available, optical) to 1x
       
   270         * @since 3.0
       
   271         */                        
       
   272         void ResetZoomTo1x();
       
   273 
       
   274         /***
       
   275         * Handle pointer events
       
   276         * @since S60 v5.0
       
   277         * @param TPointerEvent, pointer event
       
   278         * @return TBool, ETrue if the pointer event was used
       
   279         */  
       
   280         TBool HandlePointerEventL( const TPointerEvent& aPointerEvent ); 
       
   281         
       
   282         /***
       
   283         * Handle pointer events
       
   284         * @since S60 v5.0
       
   285         * @param TInt, Pointer's Y-position
       
   286         * @return TBool, ETrue if the pointer event was used
       
   287         */  
       
   288         TBool StartTouchZoomL( TInt aPointer ); 
       
   289         
       
   290         
       
   291 
       
   292     public: // Functions from base classes        
       
   293     protected:  // New functions        
       
   294     protected:  // Functions from CCoeControl        
       
   295 
       
   296         /**
       
   297         * Handles events from the controller
       
   298         * @since 2.8
       
   299         * @param aEvent The controller event that has occurred
       
   300         * @param aError An associated error code
       
   301         */
       
   302         void HandleControllerEventL( TCamControllerEvent aEvent, TInt aError );
       
   303 
       
   304     protected:  // Functions from base classes
       
   305     private:
       
   306 
       
   307         /**
       
   308         * C++ default constructor.
       
   309         * since 2.8
       
   310         * @param aRect parent rect
       
   311         * @param aController handle to camera application controller
       
   312         * @param aOverlayViewFinder whether zoom pane is drawn over view finder
       
   313         */
       
   314         CCamZoomPane( CCamAppController& aController, 
       
   315                       TBool aOverlayViewFinder );
       
   316 
       
   317         /**
       
   318         * By default Symbian 2nd phase constructor is private.
       
   319         */
       
   320         void ConstructL();        
       
   321 
       
   322         /**
       
   323         * Reads layout information from a resource
       
   324         * @since 2.8
       
   325         */
       
   326         void ReadLayoutL();
       
   327 
       
   328         /**
       
   329         * Updates Layout and size of control
       
   330         * @since S60 5.0
       
   331         */
       
   332         void SizeChanged(); 
       
   333 
       
   334         /**
       
   335         * Draws the thumb on the zoom pane
       
   336         * @since 3.0
       
   337         * @param aGc The graphics context to draw to
       
   338         */
       
   339         void DrawThumb( CBitmapContext& aGc ) const;
       
   340 
       
   341         /**
       
   342         * Draws the shaft of the zoom pane
       
   343         * @since 3.0
       
   344         * @param aGc The graphics context to draw to
       
   345         */
       
   346         void DrawShaft( CBitmapContext& aGc ) const;
       
   347         
       
   348         /**
       
   349         * Draws the plus/minus icons for the zoom pane
       
   350         * @since 3.0
       
   351         * @param aGc The graphics context to draw to
       
   352         */
       
   353         void DrawPlusMinus( CBitmapContext& aGc ) const;
       
   354         
       
   355         /**
       
   356         * Returns the current Zoom Pane orientation based on stored
       
   357         * settings and whether the current camera supports horizontal zoom bar
       
   358         * @since 3.0
       
   359         * @return The orientation (veritcal or horizontal)
       
   360         */
       
   361         TZPOrientation PaneOrientation() const;
       
   362 
       
   363         /**
       
   364         * Read nontouch layout
       
   365         */
       
   366         void TouchLayout();
       
   367 
       
   368         /**
       
   369         * Read touch layout
       
   370         */
       
   371         void NonTouchLayout(); 
       
   372 
       
   373         /*
       
   374         * Reads zoom keys from the appropriate array
       
   375         */
       
   376         void ReadZoomKeys( const RArray<TInt>& aSource,
       
   377                            RArray<TInt>& aTarget );
       
   378         /*
       
   379         * Checks for the zoom key with the mapped key's scan code
       
   380         */
       
   381         TBool CheckForZoomKey( const TKeyEvent& aKeyEvent,
       
   382                                const RArray<TInt>& aKeys );
       
   383 
       
   384         /**
       
   385         * Touchfeedback
       
   386         * @since S60 v5.0
       
   387         */
       
   388         void Touchfeedback(); 
       
   389 
       
   390     public:     // Data
       
   391     
       
   392     protected:  // Data
       
   393 
       
   394     private:    // Data
       
   395 
       
   396         // The bitmaps for the graphical components.
       
   397         CFbsBitmap* iIconZoomTop[2];  
       
   398         CFbsBitmap* iIconZoomMiddle[2];
       
   399         CFbsBitmap* iIconZoomBottom[2];
       
   400         CFbsBitmap* iIconZoomMarker[2];
       
   401         CFbsBitmap* iIconZoomMarkerGray[2]; 
       
   402         CFbsBitmap* iIconZoomMin[2];
       
   403         CFbsBitmap* iIconZoomMax[2];
       
   404         CFbsBitmap* iIconZoomMarkerCurrent;
       
   405 
       
   406         TRect iZoomPaneRect;
       
   407         TRect iSliderParentRect;
       
   408         TPoint iPlusPoint;
       
   409         TPoint iMinusPoint;
       
   410         TPoint iTopPoint;
       
   411         TPoint iMiddlePoint;
       
   412         TPoint iBottomPoint;
       
   413 
       
   414         //Holds the maximum 'travel' of the thumb along the slider 
       
   415         TInt iMaxOffset; 
       
   416         
       
   417         // Minimum supported zoom level
       
   418         TInt iMinZoom;    
       
   419 
       
   420         // Maximum supported zoom level
       
   421         TInt iMaxZoom;
       
   422 
       
   423         // Actual zoom level
       
   424         TInt iCurZoom;
       
   425         
       
   426         // Targeted zoom level to be indicated by the thumb
       
   427         TInt iTrgZoom;
       
   428 
       
   429         // Previous pointer Y-position
       
   430         TInt iPointerPrevi; 
       
   431 
       
   432         // Whether we are currently recording video or not.
       
   433         TBool iRecordingVideo;
       
   434 
       
   435         // Reference to the Controller
       
   436         CCamAppController& iController;
       
   437 
       
   438         // Represents a bitmask of TCamVideoZoom for video zoom features
       
   439         TInt iZoomSupport;
       
   440 
       
   441         // Determine from PSI if zoom pane are overlaid on VF
       
   442         TBool iOverlayViewFinder;
       
   443 
       
   444         // is the zoom pane visible
       
   445         TBool iVisible;
       
   446         
       
   447         // Determine whether or not touch is active
       
   448         TBool iTouchActive;
       
   449 
       
   450         // The current engine state, updated if it changes
       
   451         TCamCameraState iCameraState;
       
   452 
       
   453         // The zoom model, owned by this control
       
   454         CCamZoomModel* iModel;
       
   455 
       
   456         // The number of key repeats received in a row.
       
   457         TInt iRepeatCounter;
       
   458 
       
   459         // The optical, digital and extended zoom steps to be shown on the zoom bar
       
   460         TInt iOptSteps;
       
   461         TInt iStdSteps;
       
   462         TInt iExtSteps;
       
   463         
       
   464         // Stores the look and feel info of the zoom bar
       
   465         TCamZoomLAF iZoomLAF;
       
   466          
       
   467         // Stores the orientation of the zoom pane (vertical or horizontal)
       
   468         // as read from the Central Repository
       
   469         TZPOrientation iOrientation;
       
   470 
       
   471         // Whether or not product uses volume keys for zoom
       
   472         TBool iZoomUsingVolumeKeys;
       
   473 
       
   474         // Whether or not product uses navi-key left and right for zoom
       
   475         TBool iZoomUsingNaviKeys;
       
   476 
       
   477         // Performs zoom frame/thumb bitmap rotation when needed
       
   478         CCamBmpRotatorAo* iRotatorAo;
       
   479 
       
   480 		// Timer used to remove zoom pane after a short delay
       
   481 		CCamTimer* iZoomTimer;
       
   482         MTouchFeedback* iFeedback; // Not own
       
   483 
       
   484         // observer to receive volume key presses
       
   485 		CCamRemConObserver* iVolumeKeyObserver;
       
   486         
       
   487         RArray<TInt> iZoomInKeys;
       
   488         RArray<TInt> iZoomOutKeys;
       
   489     };
       
   490 
       
   491 #endif      // CAMZOOMPANE_H
       
   492             
       
   493 // End of File