camerauis/cameraapp/generic/src/CamZoomPane.cpp
changeset 0 1ddebce53859
child 1 f5ec9446e5bf
equal deleted inserted replaced
-1:000000000000 0:1ddebce53859
       
     1 /*
       
     2 * Copyright (c) 2007-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:  Camera Zoom Pane; shows the zoom level graphically*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <e32base.h>
       
    21 #include <e32std.h>
       
    22 #include <coemain.h>
       
    23 #include <eikenv.h>
       
    24 #include <cameraapp.mbg>
       
    25 #include <eikappui.h>    // For CCoeAppUiBase
       
    26 #include <eikapp.h>      // For CEikApplication
       
    27 #include <barsread.h>    // resource reader
       
    28 #include <AknIconUtils.h>
       
    29 #include <centralrepository.h>
       
    30 #include <layoutmetadata.cdl.h>         
       
    31 #include <aknlayoutscalable_apps.cdl.h> 
       
    32 #include <touchfeedback.h> 
       
    33 #include <cameraapp.rsg>
       
    34 #include <vgacamsettings.rsg>
       
    35 #include "CameraUiConfigManager.h"
       
    36 #include "CamPanic.h"    // Panic codes
       
    37 #include "CamUtility.h"
       
    38 #include "CamZoomPane.h"
       
    39 #include "CamZoomModel.h"
       
    40 #include "CamAppUi.h"
       
    41 #include "CamBmpRotatorAo.h"
       
    42 #include "CameraappPrivateCRKeys.h"
       
    43 #include "CamTimer.h"
       
    44 
       
    45 
       
    46 // CONSTANTS
       
    47 const TInt KDivisorFactor = 10000;    // integer scaling factor to avoid the 
       
    48                                      // use of floating point arithmetic
       
    49 const TInt KTouchAreaExpansion = 35; // Pixels to grow touchable area                                    
       
    50 
       
    51 // ============================ MEMBER FUNCTIONS ===============================
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CCamZoomPane::CCamZoomPane
       
    55 // C++ default constructor can NOT contain any code, that
       
    56 // might leave.
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 CCamZoomPane::CCamZoomPane( CCamAppController& aController, TBool aOverlayViewFinder )
       
    60     : iController( aController ),
       
    61       iOverlayViewFinder( aOverlayViewFinder )
       
    62     {
       
    63     }
       
    64 
       
    65 // -----------------------------------------------------------------------------
       
    66 // CCamZoomPane::ConstructL
       
    67 // Symbian 2nd phase constructor can leave.
       
    68 // -----------------------------------------------------------------------------
       
    69 //
       
    70 void CCamZoomPane::ConstructL()
       
    71     {
       
    72     PRINT( _L( "Camera => CCamZoomPane::ConstructL " ) );
       
    73     // Load the zoom pane orientation value from the Central Repository
       
    74  	CRepository* repository = CRepository::NewL( KCRUidCameraappSettings );        
       
    75  	TInt val = 0;
       
    76     TInt err = repository->Get( KCamCrZoomPaneOrientation, val );
       
    77 
       
    78     // If there is an error then assume standard (vertical) orientation
       
    79     if ( err != KErrNone )
       
    80         {
       
    81         iOrientation = EZPOrientationVertical;
       
    82         }
       
    83     else 
       
    84         {
       
    85         iOrientation = static_cast<TZPOrientation>( val );
       
    86         }
       
    87 #if !( defined(__WINS__) || defined(__WINSCW__) )
       
    88     // Get Central Repository key indicating if product uses volume keys for zoom
       
    89     err = repository->Get( KCamCrZoomUsingVolumeKeys, val );
       
    90 
       
    91     // If there is an error then assume volume keys not used
       
    92     if ( err != KErrNone )
       
    93         {
       
    94         iZoomUsingVolumeKeys = EFalse;
       
    95         }
       
    96     else 
       
    97         {
       
    98         iZoomUsingVolumeKeys = val;
       
    99         }
       
   100     
       
   101         iZoomUsingVolumeKeys = EFalse;
       
   102     
       
   103     // Get Central Repository key indicating if product uses navi-keys for zoom
       
   104     err = repository->Get( KCamCrZoomUsingNaviKeys, val );
       
   105 
       
   106     // If there is an error then assume navi-keys not used
       
   107     if ( err != KErrNone )
       
   108         {
       
   109         iZoomUsingNaviKeys = EFalse;
       
   110         }
       
   111     else 
       
   112         {
       
   113         iZoomUsingNaviKeys = val;
       
   114         }
       
   115 #else
       
   116     iZoomUsingVolumeKeys = EFalse;   
       
   117     iZoomUsingNaviKeys = ETrue;  
       
   118 #endif // !( defined(__WINS__) || defined(__WINSCW__) )       
       
   119         
       
   120     delete repository;
       
   121     repository = NULL;
       
   122         
       
   123     // Find the name and path of the MBM file for zoom pane bitmaps
       
   124     TFileName resFileName;
       
   125     CamUtility::ResourceFileName( resFileName );
       
   126     TPtrC resname = resFileName;
       
   127            
       
   128     // Create component bitmaps 
       
   129     AknIconUtils::CreateIconL( iIconZoomTop[0], 
       
   130                                iIconZoomTop[1], 
       
   131                                resname, 
       
   132                                EMbmCameraappQgn_indi_cam4_zoom_top, 
       
   133                                EMbmCameraappQgn_indi_cam4_zoom_top_mask );
       
   134 
       
   135     AknIconUtils::CreateIconL( iIconZoomMiddle[0], 
       
   136                                iIconZoomMiddle[1], 
       
   137                                resname, 
       
   138                                EMbmCameraappQgn_indi_cam4_zoom_middle, 
       
   139                                EMbmCameraappQgn_indi_cam4_zoom_middle_mask );
       
   140                             
       
   141     AknIconUtils::CreateIconL( iIconZoomBottom[0], 
       
   142                                iIconZoomBottom[1], 
       
   143                                resname, 
       
   144                                EMbmCameraappQgn_indi_cam4_zoom_bottom, 
       
   145                                EMbmCameraappQgn_indi_cam4_zoom_bottom_mask );   
       
   146         
       
   147     AknIconUtils::CreateIconL( iIconZoomMarker[0], 
       
   148                                iIconZoomMarker[1], 
       
   149                                resname, 
       
   150                                EMbmCameraappQgn_indi_cam4_zoom_marker, 
       
   151                                EMbmCameraappQgn_indi_cam4_zoom_marker_mask );
       
   152 
       
   153     AknIconUtils::CreateIconL( iIconZoomMarkerGray[0], 
       
   154                                iIconZoomMarkerGray[1], 
       
   155                                resname, 
       
   156                                EMbmCameraappQgn_indi_cam4_zoom_marker_selected, 
       
   157                                EMbmCameraappQgn_indi_cam4_zoom_marker_selected_mask );
       
   158 
       
   159     AknIconUtils::CreateIconL( iIconZoomMin[0], 
       
   160                                iIconZoomMin[1], 
       
   161                                resname, 
       
   162                                EMbmCameraappQgn_indi_cam4_zoom_min, 
       
   163                                EMbmCameraappQgn_indi_cam4_zoom_min_mask );
       
   164                                
       
   165     AknIconUtils::CreateIconL( iIconZoomMax[0], 
       
   166                                iIconZoomMax[1], 
       
   167                                resname, 
       
   168                                EMbmCameraappQgn_indi_cam4_zoom_max, 
       
   169                                EMbmCameraappQgn_indi_cam4_zoom_max_mask );   
       
   170 
       
   171     SizeChanged(); // Initialize layouts and set sizes   
       
   172     CamUtility::SetAlphaL( iIconZoomTop[0], iIconZoomTop[1] ); 
       
   173     CamUtility::SetAlphaL( iIconZoomMiddle[0], iIconZoomMiddle[1] ); 
       
   174     CamUtility::SetAlphaL( iIconZoomBottom[0], iIconZoomBottom[1] );  
       
   175     CamUtility::SetAlphaL( iIconZoomMarker[0], iIconZoomMarker[1] );  
       
   176     CamUtility::SetAlphaL( iIconZoomMarkerGray[0], iIconZoomMarkerGray[1] ); 
       
   177     CamUtility::SetAlphaL( iIconZoomMin[0], iIconZoomMin[1] ); 
       
   178     CamUtility::SetAlphaL( iIconZoomMax[0], iIconZoomMax[1] );  
       
   179     iIconZoomMarkerCurrent = iIconZoomMarker[0]; 
       
   180 
       
   181     // Retrieve product-specific information about zoom support
       
   182     CamUtility::GetPsiInt( ECamPsiVideoZoomSupport, iZoomSupport );
       
   183 
       
   184     // Retrieve the timing and step values for each of the zoom bar 
       
   185     // segments/modes eg Optical/Digital/Extended    
       
   186     TPckgBuf <TCamZoomLAF> pckg;
       
   187     CamUtility::GetPsiAnyL( ECamPsiZoomBarLAF, &pckg);
       
   188     iZoomLAF = pckg();
       
   189         
       
   190     // Register for notification of controller events
       
   191     iController.AddControllerObserverL( this );    
       
   192     
       
   193     iModel = CCamZoomModel::NewL( iController, this );
       
   194     iFeedback = MTouchFeedback::Instance();   
       
   195 
       
   196     PRINT( _L( "Camera <= CCamZoomPane::ConstructL " ) );
       
   197     }
       
   198 
       
   199 // -----------------------------------------------------------------------------
       
   200 // CCamZoomPane::LoadResourceDataL()
       
   201 // Reads in all information needed from resources
       
   202 // -----------------------------------------------------------------------------
       
   203 //
       
   204 void CCamZoomPane::LoadResourceDataL()
       
   205     {
       
   206     PRINT( _L( "Camera => CCamZoomPane::LoadResourceDataL " ) );
       
   207     ReadLayoutL();
       
   208     PRINT( _L( "Camera <= CCamZoomPane::LoadResourceDataL " ) );
       
   209     }
       
   210 
       
   211 // -----------------------------------------------------------------------------
       
   212 // CCamZoomPane::UnloadResourceData()
       
   213 // Frees all dynamic resources allocated in LoadResourceDataL
       
   214 // -----------------------------------------------------------------------------
       
   215 //
       
   216 void CCamZoomPane::UnloadResourceData()
       
   217     {
       
   218     PRINT( _L( "Camera => CCamZoomPane::UnloadResourceData " ) );
       
   219     PRINT( _L( "Camera <= CCamZoomPane::UnloadResourceData " ) );
       
   220     }
       
   221     
       
   222 // -----------------------------------------------------------------------------
       
   223 // CCamZoomPane::ReloadResourceDataL()
       
   224 // Refreshes all resource-based information stored in the class
       
   225 // -----------------------------------------------------------------------------
       
   226 //
       
   227 void CCamZoomPane::ReloadResourceDataL()
       
   228     {
       
   229     PRINT( _L( "Camera => CCamZoomPane::ReloadResourceDataL " ) );
       
   230     UnloadResourceData();
       
   231     LoadResourceDataL();
       
   232     PRINT( _L( "Camera <= CCamZoomPane::ReloadResourceDataL " ) );
       
   233     }
       
   234 
       
   235 // -----------------------------------------------------------------------------
       
   236 // CCamZoomPane::NewL
       
   237 // Two-phased constructor.
       
   238 // -----------------------------------------------------------------------------
       
   239 //
       
   240 CCamZoomPane* CCamZoomPane::NewL( CCamAppController& aController,
       
   241                                   TBool aOverlayViewFinder )
       
   242     {
       
   243     PRINT( _L( "Camera => CCamZoomPane::NewL " ) );
       
   244     CCamZoomPane* self = new( ELeave ) CCamZoomPane ( aController, aOverlayViewFinder );
       
   245     CleanupStack::PushL( self );
       
   246     self->ConstructL();
       
   247     CleanupStack::Pop( self );
       
   248     PRINT( _L( "Camera <= CCamZoomPane::NewL " ) );
       
   249     return self;
       
   250     }
       
   251     
       
   252 // -----------------------------------------------------------------------------
       
   253 // CCamZoomPane::~CCamZoomPane
       
   254 // Destructor.
       
   255 // -----------------------------------------------------------------------------
       
   256 //
       
   257 CCamZoomPane::~CCamZoomPane()
       
   258     {
       
   259     PRINT( _L("Camera => ~CCamZoomPane" ))  
       
   260     iController.RemoveControllerObserver( this );
       
   261 
       
   262     delete iIconZoomTop[0];  
       
   263     delete iIconZoomMiddle[0];
       
   264     delete iIconZoomBottom[0];
       
   265     delete iIconZoomMarker[0];
       
   266     delete iIconZoomMarkerGray[0]; 
       
   267     delete iIconZoomMin[0];
       
   268     delete iIconZoomMax[0];
       
   269     delete iIconZoomTop[1];  
       
   270     delete iIconZoomMiddle[1];
       
   271     delete iIconZoomBottom[1];
       
   272     delete iIconZoomMarker[1];
       
   273     delete iIconZoomMarkerGray[1]; 
       
   274     delete iIconZoomMin[1];
       
   275     delete iIconZoomMax[1];
       
   276  
       
   277     delete iModel;
       
   278   
       
   279     if ( iRotatorAo &&
       
   280          iRotatorAo->IsActive() )
       
   281         {
       
   282         iRotatorAo->Cancel();
       
   283         }
       
   284     delete iRotatorAo;
       
   285 
       
   286 
       
   287     iZoomInKeys.Close();
       
   288     iZoomOutKeys.Close();
       
   289 
       
   290     PRINT( _L("Camera <= ~CCamZoomPane" ))  
       
   291     }
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CCamZoomPane::Draw
       
   295 // Draws the zoom pane
       
   296 // -----------------------------------------------------------------------------
       
   297 //
       
   298 void CCamZoomPane::Draw( CBitmapContext& aGc ) const
       
   299     {
       
   300     PRINT( _L( "Camera => CCamZoomPane::Draw " ) );
       
   301     if ( !iMaxZoom )
       
   302         {        
       
   303         PRINT( _L( "Camera <= CCamZoomPane::Draw not set up yet" ) );
       
   304         return; // Not set up yet
       
   305         }
       
   306         
       
   307     if ( !iOverlayViewFinder )
       
   308         {
       
   309         aGc.Clear( iZoomPaneRect );
       
   310         }
       
   311     
       
   312     DrawPlusMinus( aGc );
       
   313     DrawShaft( aGc );
       
   314     DrawThumb( aGc );    
       
   315     PRINT( _L( "Camera <= CCamZoomPane::Draw " ) );
       
   316     }
       
   317     
       
   318 // -----------------------------------------------------------------------------
       
   319 // CCamZoomPane::DrawPlusMinus
       
   320 // Draws the plus and minus icons
       
   321 // -----------------------------------------------------------------------------
       
   322 //    
       
   323 void CCamZoomPane::DrawPlusMinus( CBitmapContext& aGc ) const
       
   324     {    
       
   325     PRINT( _L( "Camera => CCamZoomPane::DrawPlusMinus " ) );
       
   326     aGc.BitBlt( iPlusPoint,  iIconZoomMax[0] );    
       
   327     aGc.BitBlt( iMinusPoint, iIconZoomMin[0] );   
       
   328     PRINT( _L( "Camera <= CCamZoomPane::DrawPlusMinus " ) );                 
       
   329     }
       
   330     
       
   331 // -----------------------------------------------------------------------------
       
   332 // CCamZoomPane::DrawShaft
       
   333 // Draws the shaft of the zoom pane
       
   334 // -----------------------------------------------------------------------------
       
   335 //    
       
   336 void CCamZoomPane::DrawShaft( CBitmapContext& aGc ) const  
       
   337     {
       
   338     PRINT( _L( "Camera => CCamZoomPane::DrawShaft " ) );
       
   339     aGc.BitBlt( iTopPoint,    iIconZoomTop[0] );
       
   340     aGc.BitBlt( iMiddlePoint, iIconZoomMiddle[0] );
       
   341     aGc.BitBlt( iBottomPoint, iIconZoomBottom[0] );
       
   342     PRINT( _L( "Camera <= CCamZoomPane::DrawShaft " ) );
       
   343     }
       
   344    
       
   345 // -----------------------------------------------------------------------------
       
   346 // CCamZoomPane::SetPoint
       
   347 // Sets the value of a point based on another point and an (optional) modifier value.
       
   348 // This was added to simplify the bar drawing code, so the changes based on orientation 
       
   349 // are (as much as possible) contained in this function
       
   350 // -----------------------------------------------------------------------------
       
   351 //    
       
   352 void 
       
   353 CCamZoomPane::SetPoint(       TPoint& aPoint, 
       
   354                         const TPoint& aOffset, 
       
   355                               TInt    aAdditional ) const
       
   356     {
       
   357     PRINT( _L( "Camera => CCamZoomPane::SetPoint " ) );
       
   358     if ( PaneOrientation() == EZPOrientationVertical )
       
   359         {
       
   360         aPoint.iY = aOffset.iY + aAdditional;
       
   361         }
       
   362     else
       
   363         {
       
   364         aPoint.iX = aOffset.iX - aAdditional;
       
   365         }
       
   366     PRINT( _L( "Camera <= CCamZoomPane::SetPoint " ) );
       
   367     }
       
   368     
       
   369 // -----------------------------------------------------------------------------
       
   370 // CCamZoomPane::PaneOrientation
       
   371 // Returns the current zoom pane orientation (taking into account whether this
       
   372 // should be forced or not if on secondary camera)
       
   373 // -----------------------------------------------------------------------------
       
   374 //        
       
   375 CCamZoomPane::TZPOrientation CCamZoomPane::PaneOrientation() const
       
   376     {
       
   377     PRINT( _L( "Camera => CCamZoomPane::PaneOrientation " ) );
       
   378     if ( iController.ActiveCamera() == ECamActiveCameraSecondary )
       
   379         {
       
   380         PRINT( _L( "Camera <= CCamZoomPane::PaneOrientation EZPOrientationVertical" ) );
       
   381         return EZPOrientationVertical;
       
   382         }
       
   383     else 
       
   384         {
       
   385         PRINT( _L( "Camera <= CCamZoomPane::PaneOrientation iOrientation" ) );
       
   386         return iOrientation;
       
   387         }
       
   388     }
       
   389     
       
   390 // -----------------------------------------------------------------------------
       
   391 // CCamZoomPane::DrawThumb
       
   392 // Draws the thumb of the zoom pane
       
   393 // -----------------------------------------------------------------------------
       
   394 //       
       
   395 void CCamZoomPane::DrawThumb( CBitmapContext& aGc ) const
       
   396     {   
       
   397     PRINT( _L( "Camera => CCamZoomPane::DrawThumb " ) );
       
   398     TPoint newThumbPos;                            
       
   399     // Knob bitmap has an empty area on the edge, thus it starts upper than top
       
   400     // of zoom slider 
       
   401     // topPointY is iTl.iY of knob bitmap when maximum zoom is used. 
       
   402     newThumbPos.iX = iZoomPaneRect.iTl.iX;        
       
   403         
       
   404     TInt pixelsPerStep = ( iMaxOffset * KDivisorFactor ) / (iMaxZoom+1);
       
   405     TInt pixelsFromBase;
       
   406     pixelsFromBase = ( iTrgZoom * pixelsPerStep );
       
   407     newThumbPos.iY = iTopPoint.iY + iMaxOffset -
       
   408              (pixelsFromBase + pixelsPerStep/2 +
       
   409               iIconZoomMarker[0]->SizeInPixels().iHeight * 
       
   410               KDivisorFactor / 2) / KDivisorFactor;                                                        
       
   411         
       
   412     aGc.BitBlt( newThumbPos, iIconZoomMarkerCurrent ); 
       
   413     PRINT( _L( "Camera <= CCamZoomPane::DrawThumb " ) );                   
       
   414     }
       
   415 
       
   416 // -----------------------------------------------------------------------------
       
   417 // CCamZoomPane::SetRect
       
   418 // Sets the rect that zoom pane is drawn into
       
   419 // -----------------------------------------------------------------------------
       
   420 //
       
   421 void CCamZoomPane::SetRect( TRect aRect )
       
   422     {
       
   423     PRINT( _L( "Camera => CCamZoomPane::SetRect " ) );
       
   424     iZoomPaneRect = aRect;
       
   425     PRINT( _L( "Camera <= CCamZoomPane::SetRect " ) );
       
   426     }
       
   427 
       
   428 // -----------------------------------------------------------------------------
       
   429 // CCamZoomPane::SetZoomRange
       
   430 // Specifies the range of values zoom supports
       
   431 // aMax should always be more than aMin. 
       
   432 // -----------------------------------------------------------------------------
       
   433 //
       
   434 TInt CCamZoomPane::SetZoomRange( TInt aMin, TInt aMax )
       
   435     {        
       
   436     PRINT( _L( "Camera => CCamZoomPane::SetZoomRange " ) );
       
   437     // The minimum value should always be less than the max.
       
   438     if ( aMin >= aMax ||
       
   439          aMin < 0 )
       
   440         {    
       
   441         PRINT( _L( "Camera <= CCamZoomPane::SetZoomRange KErrArgument" ) );
       
   442         return KErrArgument;
       
   443         }
       
   444 
       
   445     iMinZoom = aMin;
       
   446     iMaxZoom = aMax;
       
   447     PRINT( _L( "Camera <= CCamZoomPane::SetZoomRange " ) );
       
   448     return KErrNone;
       
   449     } 
       
   450 
       
   451 // -----------------------------------------------------------------------------
       
   452 // CCamZoomPane::SetZoomSteps
       
   453 // Sets the number of steps allowed in each category
       
   454 // -----------------------------------------------------------------------------
       
   455 //
       
   456 void CCamZoomPane::SetZoomSteps( TInt aOptSteps, TInt aStdSteps, TInt aExtSteps )
       
   457     {  
       
   458     PRINT( _L( "Camera => CCamZoomPane::SetZoomSteps " ) );      
       
   459     ASSERT( aOptSteps >= 0 && aStdSteps >= 0 && aExtSteps >= 0 );
       
   460     
       
   461     iOptSteps = aOptSteps;
       
   462     iStdSteps = aStdSteps;    
       
   463     iExtSteps = aExtSteps;
       
   464     PRINT( _L( "Camera <= CCamZoomPane::SetZoomSteps " ) );        
       
   465     }
       
   466     
       
   467 // -----------------------------------------------------------------------------
       
   468 // CCamZoomPane::SetZoomValue
       
   469 // Specifies the current level of Zoom.
       
   470 // -----------------------------------------------------------------------------
       
   471 //
       
   472 TInt CCamZoomPane::SetZoomValue( TInt aZoom )
       
   473     { 
       
   474     PRINT1( _L( "Camera => CCamZoomPane::SetZoomValue aZoom=%d" ), aZoom );
       
   475     if ( iController.UiConfigManagerPtr()->IsExtendedDigitalZoomSupported() )
       
   476         {
       
   477         // this may happen if in the extended zoom range
       
   478         // and we switch the extended range off - the
       
   479         // zoom value in the engine will be greater than
       
   480         // the max value allowed
       
   481         if ( aZoom > iMaxZoom )
       
   482             {
       
   483             aZoom = iMaxZoom;
       
   484             }        
       
   485         }
       
   486 
       
   487     // Check supplied value is within valid range
       
   488     if ( aZoom < iMinZoom || aZoom > iMaxZoom )
       
   489         {
       
   490         PRINT( _L( "Camera <= CCamZoomPane::SetZoomValue KErrArgument" ) );
       
   491         return KErrArgument;
       
   492         }
       
   493 
       
   494     iCurZoom = aZoom;
       
   495     iTrgZoom = aZoom;
       
   496 
       
   497     if ( iVisible )
       
   498         {
       
   499         // force redraw of zoom pane
       
   500         MakeVisible( ETrue, ETrue );
       
   501         }
       
   502 
       
   503     PRINT( _L( "Camera <= CCamZoomPane::SetZoomValue " ) );
       
   504     return KErrNone;
       
   505     }
       
   506 
       
   507 // -----------------------------------------------------------------------------
       
   508 // CCamZoomPane::ZoomValue
       
   509 // Returns the current zoom value (as the ZoomPane knows it)
       
   510 // -----------------------------------------------------------------------------
       
   511 //
       
   512 TInt CCamZoomPane::ZoomValue() const
       
   513     {   
       
   514     PRINT( _L( "Camera => CCamZoomPane::ZoomValue " ) );
       
   515     PRINT1( _L( "Camera <= CCamZoomPane::ZoomValue iCurZoom=%d" ), iCurZoom );
       
   516     return iCurZoom;
       
   517     }
       
   518 
       
   519 // -----------------------------------------------------------------------------
       
   520 // CCamZoomPane::IsZoomAtMinimum
       
   521 // Returns whether the current zoom value is the minimum zoom
       
   522 // -----------------------------------------------------------------------------
       
   523 //
       
   524 TBool CCamZoomPane::IsZoomAtMinimum() const
       
   525     {
       
   526     PRINT2(_L("Camera =><= CCamZoomPane::IsZoomAtMinimum iCurZoom = %d, iMinZoom = %d"), iCurZoom, iMinZoom);
       
   527     return iCurZoom == iMinZoom;
       
   528     }
       
   529     
       
   530 // -----------------------------------------------------------------------------
       
   531 // CCamZoomPane::OkToShowPane
       
   532 // Returns whether or not the Zoom Pane can currently be shown.
       
   533 // -----------------------------------------------------------------------------
       
   534 //
       
   535 TBool CCamZoomPane::OkToShowPane() const
       
   536     {    
       
   537     PRINT( _L( "Camera => CCamZoomPane::OkToShowPane " ) );
       
   538     // Are we currently recording video?
       
   539     if ( iRecordingVideo )
       
   540         {   
       
   541         // Are we allowed to zoom when recording video?
       
   542         if ( ( iZoomSupport & ECamZoomWhenRecord ) )
       
   543             {
       
   544             PRINT( _L( "Camera <= CCamZoomPane::OkToShowPane ETrue" ) );
       
   545             return ETrue;
       
   546             }
       
   547         else // If not allowed, return false
       
   548             {
       
   549             PRINT( _L( "Camera <= CCamZoomPane::OkToShowPane EFalse" ) );
       
   550             return EFalse;
       
   551             }
       
   552         }
       
   553 
       
   554     // If a sequence capture is in progress
       
   555     if ( iController.SequenceCaptureInProgress() )
       
   556         {
       
   557         PRINT( _L( "Camera <= CCamZoomPane::OkToShowPane EFalse" ) );
       
   558         return EFalse;
       
   559         }
       
   560         
       
   561     PRINT( _L( "Camera <= CCamZoomPane::OkToShowPane ETrue" ) );
       
   562     return ETrue;
       
   563     }
       
   564 
       
   565 // -----------------------------------------------------------------------------
       
   566 // CCamZoomPane::HandleControllerEventL
       
   567 // Handle controller events, specifically to find out if video is currently
       
   568 // being recorded.  Only called if Zooming while recording is NOT allowed
       
   569 // -----------------------------------------------------------------------------
       
   570 //
       
   571 void CCamZoomPane::HandleControllerEventL( TCamControllerEvent aEvent, 
       
   572                                            TInt                /*aError*/ )
       
   573     {
       
   574     PRINT( _L( "Camera => CCamZoomPane::HandleControllerEventL " ) );
       
   575     switch ( aEvent )
       
   576         {
       
   577         case ECamEventOperationStateChanged:
       
   578             {
       
   579             iRecordingVideo = ECamControllerVideo == iController.CurrentMode()
       
   580                            && ECamCapturing == iController.CurrentOperation();
       
   581             break;
       
   582             }
       
   583         case ECamEventCameraChanged:
       
   584             {
       
   585             ReadLayoutL();
       
   586             break;
       
   587             }
       
   588         case ECamEventCaptureComplete:
       
   589             {
       
   590             // Release knob if image is captured with HW button while zooming.
       
   591             iIconZoomMarkerCurrent = iIconZoomMarker[0];
       
   592             break;
       
   593             }
       
   594         default:
       
   595             break;
       
   596         }
       
   597     PRINT( _L( "Camera <= CCamZoomPane::HandleControllerEventL " ) );
       
   598     }
       
   599 
       
   600 // -----------------------------------------------------------------------------
       
   601 // CCamZoomPane::Rect
       
   602 // Returns the zoom pane rect
       
   603 // -----------------------------------------------------------------------------
       
   604 //
       
   605 TRect CCamZoomPane::Rect() const
       
   606     {
       
   607     PRINT( _L( "Camera =><= CCamZoomPane::Rect " ) );
       
   608     return iZoomPaneRect;
       
   609     }
       
   610 
       
   611 // ---------------------------------------------------------
       
   612 // CCamZoomPane::ReadLayoutL
       
   613 // ---------------------------------------------------------
       
   614 //
       
   615 void CCamZoomPane::ReadLayoutL()
       
   616     {   
       
   617     PRINT( _L( "Camera =><= CCamZoomPane::ReadLayoutL " ) );
       
   618     
       
   619     if ( CamUtility::IsNhdDevice() ) 
       
   620         {
       
   621         TouchLayout();
       
   622         }
       
   623     else
       
   624         {
       
   625         NonTouchLayout();
       
   626         }
       
   627     }
       
   628 
       
   629 // -----------------------------------------------------------------------------
       
   630 // CCamZoomPane::IsVisible
       
   631 // Is the zoom pane invisible
       
   632 // -----------------------------------------------------------------------------
       
   633 //
       
   634 TBool CCamZoomPane::IsVisible() const
       
   635     {
       
   636     PRINT( _L( "Camera =><= CCamZoomPane::IsVisible " ) );
       
   637     return iVisible;
       
   638     }
       
   639 
       
   640 // -----------------------------------------------------------------------------
       
   641 // CCamZoomPane::MakeVisible
       
   642 // Makes the zoom pane visible
       
   643 // -----------------------------------------------------------------------------
       
   644 //
       
   645 void CCamZoomPane::MakeVisible( TBool aVisible, TBool aRedraw )
       
   646     {
       
   647     PRINT2( _L( "Camera => CCamZoomPane::MakeVisible aVisible=%d aRedraw=%d" ), aVisible, aRedraw );    
       
   648     iVisible = aVisible;
       
   649 
       
   650     CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );    
       
   651     
       
   652     // No zoom in secondary camera view
       
   653     if ( appUi && iController.ActiveCamera() == ECamActiveCameraPrimary )
       
   654         {
       
   655         if ( aVisible ) 
       
   656             {
       
   657             appUi->ShowZoomPane(aRedraw);
       
   658             }
       
   659         else
       
   660             {
       
   661             appUi->HideZoomPane(aRedraw);
       
   662             iVisible = EFalse;  
       
   663             }
       
   664         }
       
   665     PRINT( _L( "Camera <= CCamZoomPane::MakeVisible " ) );    
       
   666     }
       
   667 
       
   668 void CCamZoomPane::SetZoomKeys( const RArray<TInt>& aZoomIn,
       
   669                                 const RArray<TInt>& aZoomOut )
       
   670     {
       
   671     PRINT( _L( "Camera => CCamZoomPane::SetZoomKeys CAMERAAPP_MULTIPLE_ZOOM_KEYS" ) );    
       
   672     iZoomInKeys.Reset();
       
   673     ReadZoomKeys( aZoomIn, iZoomInKeys );
       
   674     iZoomOutKeys.Reset();
       
   675     ReadZoomKeys( aZoomOut, iZoomOutKeys );
       
   676     PRINT( _L( "Camera <= CCamZoomPane::SetZoomKeys " ) );    
       
   677     }
       
   678 
       
   679 // -----------------------------------------------------------------------------
       
   680 // CCamZoomPane::ReadZoomKeys
       
   681 // -----------------------------------------------------------------------------
       
   682 //
       
   683 void CCamZoomPane::ReadZoomKeys( const RArray<TInt>& aSource,
       
   684                                  RArray<TInt>& aTarget )
       
   685     {
       
   686     PRINT( _L( "Camera => CCamZoomPane::ReadZoomKeys " ) );
       
   687     for ( TInt i = 0; i < aSource.Count(); i++ )
       
   688         {
       
   689         // here we ignore the error 
       
   690         aTarget.Append( aSource[i] );
       
   691         }
       
   692     PRINT( _L( "Camera <= CCamZoomPane::ReadZoomKeys " ) );
       
   693     }
       
   694 
       
   695 // -----------------------------------------------------------------------------
       
   696 // CCamZoomPane::CheckForZoomKey
       
   697 // -----------------------------------------------------------------------------
       
   698 //
       
   699 TBool CCamZoomPane::CheckForZoomKey( const TKeyEvent& aKeyEvent,
       
   700                                      const RArray<TInt>& aKeys )
       
   701     {
       
   702     PRINT( _L( "Camera =><= CCamZoomPane::CheckForZoomKey " ) );
       
   703     return (KErrNotFound != aKeys.Find( aKeyEvent.iScanCode ));
       
   704     }
       
   705 
       
   706 
       
   707 // -----------------------------------------------------------------------------
       
   708 // CCamZoomPane::OfferKeyEventL
       
   709 // Handles key events for the zoom pane.
       
   710 // -----------------------------------------------------------------------------
       
   711 //
       
   712 TKeyResponse CCamZoomPane::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   713     {    
       
   714     PRINT2( _L("Camera => CCamZoomPane::OfferKeyEventL (%d) (%d)"),aKeyEvent.iScanCode, aType )
       
   715     TBool vertical = PaneOrientation() == EZPOrientationVertical;
       
   716 
       
   717  
       
   718     TBool foundZoomInKey =  CheckForZoomKey( aKeyEvent, iZoomInKeys  );
       
   719     TBool foundZoomOutKey = CheckForZoomKey( aKeyEvent, iZoomOutKeys );
       
   720 
       
   721     if ( foundZoomInKey && vertical ||
       
   722          foundZoomOutKey && !vertical )
       
   723         {
       
   724         // Block key events if touch is active
       
   725         if ( iTouchActive )
       
   726             {
       
   727             return EKeyWasConsumed;
       
   728             }
       
   729         // Handle a zoom-in key as a valid event, and start zoom
       
   730         else if ( aType == EEventKeyDown )
       
   731             {
       
   732             iModel->ZoomIn();      
       
   733             PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyDown, zoom in"))
       
   734             return EKeyWasConsumed;      
       
   735             }
       
   736         // Handle an up zoom-in key as a valid event, only if currently
       
   737         // zooming.  Can get stray up events if user woke from standby
       
   738         // with zoom key.  This should filter these out.
       
   739         else if ( aType == EEventKeyUp &&
       
   740                   IsCurrentlyZooming() )
       
   741             {
       
   742             PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyUp, stop zoom 1"))
       
   743             iModel->StopZoom();
       
   744             return EKeyWasConsumed;
       
   745             }
       
   746         // Handle special zoom-in once request
       
   747         else if ( aType == EEventUser &&
       
   748                   !IsCurrentlyZooming() )
       
   749             {
       
   750             PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyUp, zoom in once"))
       
   751             iModel->ZoomIn( ETrue );
       
   752             return EKeyWasConsumed;
       
   753             }
       
   754         // Repeat "key" events are consumed (to keep the bar visible) but
       
   755         // no need to do anything with it as zooming is timer (not key event) based
       
   756         else if ( aType == EEventKey &&
       
   757                   aKeyEvent.iRepeats > 0 )
       
   758             {            
       
   759             PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKey repeated 1"))
       
   760             // Do nothing with it, but consume it
       
   761             return EKeyWasConsumed;
       
   762             }
       
   763         else
       
   764             {
       
   765             // empty statement to remove Lint error.
       
   766             }
       
   767         
       
   768         }
       
   769     // If the orientation of the zoom pane changes, the keys to zoom in/out 
       
   770     // need to switch to move in the correct direction on the zoom pane.
       
   771     else if ( foundZoomOutKey && vertical ||
       
   772               foundZoomInKey && !vertical )
       
   773         {   
       
   774         // Handle a zoom-out key as a valid event, and start zoom
       
   775         if ( aType == EEventKeyDown )
       
   776             {
       
   777             iModel->ZoomOut();
       
   778             PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyDown, zoom out"))
       
   779             return EKeyWasConsumed;
       
   780             }
       
   781         // Handle an up zoom-out key as a valid event, only if currently
       
   782         // zooming.  Can get stray up events if user woke from standby
       
   783         // with zoom key.  This should filter these out.            
       
   784         else if ( aType == EEventKeyUp &&
       
   785                   IsCurrentlyZooming() )
       
   786             {
       
   787             PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyUp, calling StopZoom"))
       
   788             iModel->StopZoom();
       
   789             PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyUp, stop zoom 2"))
       
   790             return EKeyWasConsumed;
       
   791             }
       
   792         // Handle special zoom-out once request
       
   793         else if ( aType == EEventUser &&
       
   794                   !IsCurrentlyZooming() )
       
   795             {
       
   796             PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyUp, zoom out once"))
       
   797             iModel->ZoomOut( ETrue );
       
   798             return EKeyWasConsumed;
       
   799             }
       
   800         // Repeat "key" events are consumed (to keep the bar visible) but
       
   801         // no need to do anything with it as zooming is timer (not key event) based
       
   802         else if ( aType == EEventKey &&
       
   803                   aKeyEvent.iRepeats > 0 )
       
   804             {        
       
   805             PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKey repeated 2"))
       
   806             // Do nothing with it, but consume it
       
   807             return EKeyWasConsumed;
       
   808             }
       
   809         else
       
   810             {    
       
   811             // empty statement to remove Lint error.   
       
   812             PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKey empty statement!"))
       
   813             }
       
   814         
       
   815         }
       
   816     // otherwise, do nothing
       
   817     else
       
   818         {
       
   819         // empty statement to remove Lint error.
       
   820         PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKey empty statement!!"))
       
   821         }
       
   822 	PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL not consumed"))
       
   823     return EKeyWasNotConsumed;
       
   824     }
       
   825 
       
   826 // -----------------------------------------------------------------------------
       
   827 // CCamZoomPane::HandleForegroundEvent
       
   828 // Performs required actions on gaining/losing foreground
       
   829 // -----------------------------------------------------------------------------
       
   830 //
       
   831 void CCamZoomPane::HandleForegroundEvent( TBool aForeground )
       
   832     {
       
   833     PRINT( _L( "Camera => CCamZoomPane::HandleForegroundEvent " ) );
       
   834     if ( !aForeground )
       
   835         {
       
   836         // Ensure any ongoing zoom is stopped
       
   837         PRINT( _L( "Camera <> CCamZoomPane::HandleForegroundEvent calling StopZoom" ) );
       
   838         iModel->StopZoom();            
       
   839         }
       
   840     PRINT( _L( "Camera <= CCamZoomPane::HandleForegroundEvent " ) );
       
   841     }
       
   842 
       
   843 // -----------------------------------------------------------------------------
       
   844 // CCamZoomPane::IsCurrentlyZooming
       
   845 // Returns ETrue if the zoom model is currently zooming in/out,
       
   846 // else returns EFalse
       
   847 // -----------------------------------------------------------------------------
       
   848 //
       
   849 TBool CCamZoomPane::IsCurrentlyZooming() const
       
   850     {
       
   851     PRINT( _L( "Camera =><= CCamZoomPane::IsCurrentlyZooming " ) );
       
   852     return iModel->IsCurrentlyZooming();
       
   853     }
       
   854 
       
   855 // -----------------------------------------------------------------------------
       
   856 // CCamZoomPane::ResetToDefaultAfterPrepare
       
   857 // Sets the zoompane to reset the zoom level to default values
       
   858 // next time the engine is prepared
       
   859 // -----------------------------------------------------------------------------
       
   860 //
       
   861 void CCamZoomPane::ResetToDefaultAfterPrepare( TBool aReset )
       
   862     {
       
   863     PRINT( _L( "Camera =><= CCamZoomPane::ResetToDefaultAfterPrepare " ) );
       
   864     iModel->ResetToDefaultAfterPrepare( aReset );
       
   865     }
       
   866     
       
   867 // -----------------------------------------------------------------------------
       
   868 // CCamZoomPane::IsResetPending
       
   869 // Whether or not the zoom level is waiting to be reset to default
       
   870 // -----------------------------------------------------------------------------
       
   871 //
       
   872 TBool CCamZoomPane::IsResetPending() const
       
   873     {
       
   874     PRINT( _L( "Camera =><= CCamZoomPane::IsResetPending " ) );
       
   875     return iModel->IsResetPending();
       
   876     }    
       
   877 
       
   878 // -----------------------------------------------------------------------------    
       
   879 // CCamZoomPane::StopZoom
       
   880 // Stops zoom actions
       
   881 // -----------------------------------------------------------------------------
       
   882 //
       
   883 void CCamZoomPane::StopZoom()
       
   884     {
       
   885     PRINT( _L( "Camera => CCamZoomPane::StopZoom " ) );
       
   886     iModel->StopZoom();
       
   887     PRINT( _L( "Camera <= CCamZoomPane::StopZoom " ) );
       
   888     }
       
   889 
       
   890 // -----------------------------------------------------------------------------
       
   891 // CCamZoomPane::ResetZoomTo1x
       
   892 // Resets the zoom level to 1x.
       
   893 // -----------------------------------------------------------------------------
       
   894 //
       
   895 void CCamZoomPane::ResetZoomTo1x()
       
   896     {
       
   897     PRINT( _L( "Camera => CCamZoomPane::ResetZoomTo1x " ) );
       
   898     iModel->ResetZoomTo1x();
       
   899     PRINT( _L( "Camera <= CCamZoomPane::ResetZoomTo1x " ) );
       
   900     }
       
   901 
       
   902 // -----------------------------------------------------------------------------
       
   903 // CCamZoomPane::StartTouchZoomL
       
   904 // -----------------------------------------------------------------------------
       
   905 //
       
   906 TBool CCamZoomPane::StartTouchZoomL( TInt aPointer )  
       
   907     {     
       
   908     PRINT( _L( "Camera => CCamZoomPane::StartTouchZoomL" ) );
       
   909     
       
   910     // Block key events
       
   911     iTouchActive = ETrue;
       
   912     if ( !iMaxZoom ) // Avoid division by zero 
       
   913         {
       
   914         return EFalse;
       
   915         }
       
   916     TInt pixelsPerStep = ( iMaxOffset * KDivisorFactor ) / (iMaxZoom+1);
       
   917 
       
   918     PRINT1( _L( "Camera <> CCamZoomPane::StartTouchZoomL (iMaxZoom) %d" ), iMaxZoom );
       
   919     PRINT1( _L( "Camera <> CCamZoomPane::StartTouchZoomL (iMinZoom) %d" ), iMinZoom );
       
   920     PRINT1( _L( "Camera <> CCamZoomPane::StartTouchZoomL (pixelsPerStep) %d" ), pixelsPerStep );
       
   921 
       
   922     // New zoom according to touched point                        
       
   923     TInt base = iSliderParentRect.iBr.iY - aPointer;
       
   924     PRINT1( _L( "Camera <> CCamZoomPane::StartTouchZoomL (base) %d" ), base );
       
   925 
       
   926     // Target zoom level 
       
   927     iTrgZoom = base * KDivisorFactor / pixelsPerStep;
       
   928     iTrgZoom = ( iTrgZoom < iMinZoom )? iMinZoom:iTrgZoom;
       
   929     iTrgZoom = ( iTrgZoom > iMaxZoom )? iMaxZoom:iTrgZoom;
       
   930     PRINT1( _L( "Camera <> CCamZoomPane::StartTouchZoomL (iTrgZoom) %d" ), iTrgZoom );
       
   931    
       
   932     // Only update zoom when necessary
       
   933     if ( Abs( aPointer - iPointerPrevi ) >= pixelsPerStep / KDivisorFactor &&
       
   934          iTrgZoom != iCurZoom )
       
   935         {
       
   936         PRINT( _L( "Camera <> CCamZoomPane::StartTouchZoomL ZoomTo" ) );
       
   937         iModel->ZoomTo( iTrgZoom );
       
   938         iPointerPrevi = aPointer;
       
   939         PRINT( _L( "Camera <= CCamZoomPane::StartTouchZoomL ETrue" ) );
       
   940         return ETrue;
       
   941         }       
       
   942         
       
   943     // Pointer didn't move, so we don't need to update anything
       
   944     PRINT( _L( "Camera <= CCamZoomPane::StartTouchZoomL EFalse" ) );
       
   945     return EFalse;
       
   946     }
       
   947     
       
   948 // -----------------------------------------------------------------------------
       
   949 // CCamZoomPane::HandlePointerEventL
       
   950 // -----------------------------------------------------------------------------
       
   951 //
       
   952 TBool CCamZoomPane::HandlePointerEventL( const TPointerEvent& aPointerEvent )
       
   953     {
       
   954     PRINT( _L( "Camera => CCamZoomPane::HandlePointerEventL" ) );
       
   955 
       
   956     if ( PaneOrientation() != EZPOrientationVertical )
       
   957         {
       
   958         PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (orientation)" ) );
       
   959         return EFalse; // EZPOrientationHorizontal not supported               
       
   960         }
       
   961     
       
   962     TRect tchZoomArea = iSliderParentRect;
       
   963     tchZoomArea.Grow( KTouchAreaExpansion, KTouchAreaExpansion );
       
   964     TPointerEvent::TType type = aPointerEvent.iType;
       
   965     
       
   966     // Only make the pane appear on first touch
       
   967     if( !IsVisible() &&
       
   968         type == TPointerEvent::EButton1Down )
       
   969         {
       
   970         Touchfeedback(); 
       
   971         StopZoom();
       
   972         MakeVisible( ETrue, ETrue );
       
   973         PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (first touch)" ) );
       
   974         return ETrue;
       
   975         }
       
   976 
       
   977     // At this point, the zoom pane should have already been visible
       
   978     // so we activate touch zoom if the pointer is on the zoom pane
       
   979     if ( IsVisible() &&
       
   980          tchZoomArea.Contains( aPointerEvent.iPosition ) &&
       
   981          type == TPointerEvent::EButton1Down )
       
   982         {
       
   983         Touchfeedback(); 
       
   984         // Change zoom thumb to non-dimmed
       
   985         iIconZoomMarkerCurrent = iIconZoomMarkerGray[0]; // Dimmed knob
       
   986         // Force redraw of zoom pane, so knob will be dimmed
       
   987         TBool ret = ETrue;
       
   988         // Update zoom position, if necessary
       
   989         StartTouchZoomL( aPointerEvent.iPosition.iY );
       
   990         PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (touch active)" ) );
       
   991         return ret;
       
   992         }
       
   993         
       
   994     // If the zoom panel is visible, but the touch event is not in the
       
   995     // zoom area, then make the zoom pane disappear.
       
   996     if ( IsVisible() &&
       
   997          !tchZoomArea.Contains( aPointerEvent.iPosition ) &&
       
   998          type == TPointerEvent::EButton1Down )
       
   999         {
       
  1000         Touchfeedback();
       
  1001         // Cancel zoom if user is pushing the volume key
       
  1002         StopZoom(); 
       
  1003         // Hide zoom pane
       
  1004         MakeVisible( EFalse, ETrue );
       
  1005         PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (make disappear)" ) );
       
  1006         // return EFalse so the calling component doesn't reactivate the zoom pane
       
  1007         return EFalse;
       
  1008         }
       
  1009         
       
  1010     // Only allow drag if the zoom is already active
       
  1011     if ( type == TPointerEvent::EDrag &&
       
  1012          iTouchActive )
       
  1013         { 
       
  1014         TBool ret = StartTouchZoomL( aPointerEvent.iPosition.iY );
       
  1015         PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (dragging)" ) );
       
  1016         return ret;
       
  1017         }  
       
  1018     
       
  1019     // Clean up when the touch events are stopped
       
  1020     if ( type == TPointerEvent::EButton1Up )
       
  1021         {
       
  1022         // don't do anything for stray touches
       
  1023         if ( iTouchActive )
       
  1024             {
       
  1025             // Key events are no longer blocked
       
  1026             iTouchActive = EFalse;
       
  1027             // Change zoom thumb to non-dimmed
       
  1028             iIconZoomMarkerCurrent = iIconZoomMarker[0]; 
       
  1029             // force redraw of zoom pane, so knob is not dimmed anymore
       
  1030             MakeVisible( ETrue, ETrue );
       
  1031             PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (touch stopped)" ) );
       
  1032             return ETrue;
       
  1033             }
       
  1034 
       
  1035         PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (touch not active)" ) );
       
  1036         return EFalse;
       
  1037         }
       
  1038          
       
  1039     PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (not handled)" ) );
       
  1040     return EFalse;
       
  1041     }
       
  1042 
       
  1043 // ---------------------------------------------------------
       
  1044 // CCamZoomPane::SizeChanged
       
  1045 // Called when the view size is changed
       
  1046 // ---------------------------------------------------------
       
  1047 //
       
  1048 void CCamZoomPane::SizeChanged() 
       
  1049     {
       
  1050     PRINT( _L( "Camera => CCamZoomPane::SizeChanged" ) );
       
  1051     if ( CamUtility::IsNhdDevice() ) 
       
  1052         {
       
  1053         TouchLayout();
       
  1054         }
       
  1055     else
       
  1056         {
       
  1057         NonTouchLayout();
       
  1058         }
       
  1059                               
       
  1060     PRINT( _L( "Camera <= CCamZoomPane::SizeChanged" ) );                       
       
  1061     }
       
  1062     
       
  1063 // ---------------------------------------------------------
       
  1064 // CCamZoomPane::TouchLayout
       
  1065 // ---------------------------------------------------------
       
  1066 void CCamZoomPane::TouchLayout() 
       
  1067     {
       
  1068     PRINT( _L( "Camera => CCamZoomPane::TouchLayout()" ) );
       
  1069     TRect mainPaneRect;   
       
  1070     iMaxOffset = 0;
       
  1071     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow,
       
  1072                                        mainPaneRect );  
       
  1073     mainPaneRect.Move( -mainPaneRect.iTl ); 
       
  1074     
       
  1075     TInt variant = Layout_Meta_Data::IsLandscapeOrientation();                                     
       
  1076     TAknWindowComponentLayout l = AknLayoutScalable_Apps::cam4_zoom_pane(variant); 
       
  1077 
       
  1078     TAknLayoutRect area;
       
  1079     area.LayoutRect( mainPaneRect, l.LayoutLine() ); 
       
  1080     iZoomPaneRect = area.Rect();
       
  1081 
       
  1082     l = AknLayoutScalable_Apps::cam4_zoom_cont_pane(variant); 
       
  1083     area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
       
  1084     iSliderParentRect = area.Rect();
       
  1085     
       
  1086     l = AknLayoutScalable_Apps::cam4_zoom_pane_g1(variant); // +
       
  1087     area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
       
  1088     AknIconUtils::SetSize( iIconZoomMax[0], area.Rect().Size(), 
       
  1089                            EAspectRatioNotPreserved );
       
  1090     iPlusPoint = area.Rect().iTl;                       
       
  1091     
       
  1092     l = AknLayoutScalable_Apps::cam4_zoom_pane_g2(variant); // -
       
  1093     area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
       
  1094     AknIconUtils::SetSize( iIconZoomMin[0], area.Rect().Size(), 
       
  1095                            EAspectRatioNotPreserved );
       
  1096     iMinusPoint = area.Rect().iTl;                             
       
  1097     
       
  1098     l = AknLayoutScalable_Apps::cam4_zoom_cont_pane_g1(variant); // Top
       
  1099     area.LayoutRect( iSliderParentRect, l.LayoutLine() );
       
  1100     AknIconUtils::SetSize( iIconZoomTop[0], area.Rect().Size(), 
       
  1101                            EAspectRatioNotPreserved );
       
  1102     iTopPoint = area.Rect().iTl;                           
       
  1103     iMaxOffset += area.Rect().Height();
       
  1104     
       
  1105     l = AknLayoutScalable_Apps::cam4_zoom_cont_pane_g3(variant); // Middle
       
  1106     area.LayoutRect( iSliderParentRect, l.LayoutLine() );
       
  1107     iIconZoomMiddle[0]->Resize( area.Rect().Size());
       
  1108     AknIconUtils::SetSize( iIconZoomMiddle[0], area.Rect().Size(), 
       
  1109                            EAspectRatioNotPreserved );
       
  1110     iMiddlePoint = area.Rect().iTl;                        
       
  1111     iMaxOffset += area.Rect().Height();
       
  1112 
       
  1113     l = AknLayoutScalable_Apps::cam4_zoom_cont_pane_g2(variant); // Bottom
       
  1114     area.LayoutRect( iSliderParentRect, l.LayoutLine() );
       
  1115     AknIconUtils::SetSize( iIconZoomBottom[0], area.Rect().Size(), 
       
  1116                            EAspectRatioNotPreserved );
       
  1117     iBottomPoint = area.Rect().iTl;                        
       
  1118     TRect bottomRect = area.Rect();
       
  1119     iMaxOffset += area.Rect().Height();
       
  1120     
       
  1121     l = AknLayoutScalable_Apps::cam4_zoom_pane_g3(variant); // Knob
       
  1122     area.LayoutRect(iSliderParentRect, l.LayoutLine() );
       
  1123     TRect adj = iZoomPaneRect;
       
  1124 	adj.SetHeight( area.Rect().Height() );
       
  1125 	adj.Move( bottomRect.Center() - adj.Center() );
       
  1126     AknIconUtils::SetSize( iIconZoomMarker[0], adj.Size() );  
       
  1127     AknIconUtils::SetSize( iIconZoomMarkerGray[0], adj.Size() );
       
  1128    
       
  1129     }
       
  1130 
       
  1131 // ---------------------------------------------------------
       
  1132 // CCamZoomPane::NonTouchLayout
       
  1133 // ---------------------------------------------------------
       
  1134 void CCamZoomPane::NonTouchLayout() 
       
  1135     {
       
  1136     TRect mainPaneRect; 
       
  1137     iMaxOffset = 0;
       
  1138     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow,
       
  1139                                        mainPaneRect );  
       
  1140     mainPaneRect.Move( -mainPaneRect.iTl ); 
       
  1141     
       
  1142     TInt variant = Layout_Meta_Data::IsLandscapeOrientation(); 
       
  1143 
       
  1144     TAknWindowComponentLayout l = AknLayoutScalable_Apps::cam6_zoom_pane(variant); 
       
  1145 
       
  1146     TAknLayoutRect area;
       
  1147     area.LayoutRect( mainPaneRect, l.LayoutLine() ); 
       
  1148     iZoomPaneRect = area.Rect();
       
  1149 
       
  1150     l = AknLayoutScalable_Apps::cam6_zoom_cont_pane(variant); 
       
  1151     area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
       
  1152     iSliderParentRect = area.Rect();
       
  1153     
       
  1154     l = AknLayoutScalable_Apps::cam6_zoom_pane_g1(variant); // +
       
  1155     area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
       
  1156     AknIconUtils::SetSize( iIconZoomMax[0], area.Rect().Size(), 
       
  1157                            EAspectRatioNotPreserved );
       
  1158     iPlusPoint = area.Rect().iTl;                       
       
  1159     
       
  1160     l = AknLayoutScalable_Apps::cam6_zoom_pane_g2(variant); // -
       
  1161     area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
       
  1162     AknIconUtils::SetSize( iIconZoomMin[0], area.Rect().Size(), 
       
  1163                            EAspectRatioNotPreserved );
       
  1164     iMinusPoint = area.Rect().iTl;                             
       
  1165     
       
  1166     l = AknLayoutScalable_Apps::cam6_zoom_cont_pane_g1(variant); // Top
       
  1167     area.LayoutRect( iSliderParentRect, l.LayoutLine() );
       
  1168     AknIconUtils::SetSize( iIconZoomTop[0], area.Rect().Size(), 
       
  1169                            EAspectRatioNotPreserved );
       
  1170     iTopPoint = area.Rect().iTl; 
       
  1171     iMaxOffset += area.Rect().Height();
       
  1172     
       
  1173     l = AknLayoutScalable_Apps::cam6_zoom_cont_pane_g3(variant); // Middle
       
  1174     area.LayoutRect( iSliderParentRect, l.LayoutLine() );
       
  1175     iIconZoomMiddle[0]->Resize( area.Rect().Size());
       
  1176     AknIconUtils::SetSize( iIconZoomMiddle[0], area.Rect().Size(), 
       
  1177                            EAspectRatioNotPreserved );
       
  1178     iMiddlePoint = area.Rect().iTl;                        
       
  1179     iMaxOffset += area.Rect().Height();
       
  1180 
       
  1181     l = AknLayoutScalable_Apps::cam6_zoom_cont_pane_g2(variant); // Bottom
       
  1182     area.LayoutRect( iSliderParentRect, l.LayoutLine() );
       
  1183     AknIconUtils::SetSize( iIconZoomBottom[0], area.Rect().Size(), 
       
  1184                            EAspectRatioNotPreserved );
       
  1185     iBottomPoint = area.Rect().iTl;                        
       
  1186     TRect bottomRect = area.Rect();
       
  1187     iMaxOffset += area.Rect().Height();
       
  1188     
       
  1189     l = AknLayoutScalable_Apps::cam6_zoom_pane_g3(variant); // Knob
       
  1190     area.LayoutRect(iSliderParentRect, l.LayoutLine() );
       
  1191     iZoomPaneRect.iTl.iX += area.Rect().Width()/2;
       
  1192     AknIconUtils::SetSize( iIconZoomMarker[0], area.Rect().Size() );  
       
  1193     AknIconUtils::SetSize( iIconZoomMarkerGray[0], area.Rect().Size() );    
       
  1194     }
       
  1195     
       
  1196 // ---------------------------------------------------------
       
  1197 // CCamZoomPane::Touchfeedback
       
  1198 // ---------------------------------------------------------
       
  1199 //
       
  1200 void CCamZoomPane::Touchfeedback() 
       
  1201     {
       
  1202     PRINT( _L( "Camera => CCamZoomPane::Touchfeedback" ) );
       
  1203     if ( iFeedback )
       
  1204         {
       
  1205         iFeedback->InstantFeedback( iRecordingVideo?
       
  1206                                     ETouchFeedbackNone : ETouchFeedbackBasic );        
       
  1207         }
       
  1208     PRINT( _L( "Camera <= CCamZoomPane::Touchfeedback" ) );
       
  1209     }
       
  1210 
       
  1211 //  End of File