camerauis/cameraapp/generic/src/CamCaptureSetupSlider.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:  Class for showing the EV slider*
       
    15 */
       
    16 
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "CamCaptureSetupSlider.h"
       
    21 #include "CamPanic.h"    // Panic codes
       
    22 #include "CamUtility.h"
       
    23 #include "CamAppUi.h"
       
    24 #include "CamPSI.h"
       
    25 #include "camconfiguration.h"
       
    26 #include "CameraUiConfigManager.h"
       
    27 
       
    28 #include <e32base.h>
       
    29 #include <e32std.h>
       
    30 #include <coemain.h>
       
    31 #include <eikenv.h>
       
    32 #include <cameraapp.mbg>
       
    33 #include <eikappui.h>    // For CCoeAppUiBase
       
    34 #include <eikapp.h>      // For CEikApplication
       
    35 #include <barsread.h>    // resource reader
       
    36 #include <AknIconUtils.h>
       
    37 #include <AknsDrawUtils.h>
       
    38 #include <touchfeedback.h> 
       
    39 
       
    40 #include <cameraapp.rsg>
       
    41 #include <vgacamsettings.rsg>
       
    42 #include <aknlayoutscalable_apps.cdl.h>
       
    43 
       
    44 // EXTERNAL DATA STRUCTURES
       
    45 
       
    46 // EXTERNAL FUNCTION PROTOTYPES  
       
    47 
       
    48 // CONSTANTS
       
    49 const TInt KDivisorFactor = 1024; // Avoids using TReal maths, use factor of 2
       
    50 
       
    51 // Contrast slider value indexes
       
    52 const TInt KContrastPlusInd = 0;
       
    53 const TInt KContrastMinusInd = 1;
       
    54 const TInt KContrastIconInd = 2;
       
    55 
       
    56 // EV slider value indexes
       
    57 const TInt KEVPlus20Ind = 0;
       
    58 const TInt KEVPlus15Ind = 1;
       
    59 const TInt KEVPlus10Ind = 2;
       
    60 const TInt KEVPlus05Ind = 3;
       
    61 const TInt KEV0Ind = 4;
       
    62 const TInt KEVMinus05Ind = 5;
       
    63 const TInt KEVMinus10Ind = 6;
       
    64 const TInt KEVMinus15Ind = 7;
       
    65 const TInt KEVMinus20Ind = 8;
       
    66 
       
    67 
       
    68 
       
    69 
       
    70 // ============================ MEMBER FUNCTIONS ===============================
       
    71 
       
    72 // ---------------------------------------------------------
       
    73 // CCamSliderLegend::~CCamSliderLegend
       
    74 // destructor 
       
    75 // ---------------------------------------------------------
       
    76 //
       
    77 CCamSliderLegend::~CCamSliderLegend()
       
    78   {
       
    79   PRINT( _L("Camera => ~CCamSliderLegend") );
       
    80   delete iText;
       
    81   delete iBitmap;
       
    82   delete iMask;
       
    83   PRINT( _L("Camera <= ~CCamSliderLegend") );
       
    84   }
       
    85 
       
    86 // ---------------------------------------------------------
       
    87 // CCamSliderLegend::Draw
       
    88 // Draws the legend 
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 void CCamSliderLegend::Draw( CWindowGc& aGc ) const
       
    92     {
       
    93     if ( iItem == ECamSliderLegendItemText )
       
    94         {
       
    95         TRgb color;
       
    96         MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
    97         AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors,
       
    98                                                 EAknsCIQsnTextColorsCG6 );
       
    99 
       
   100         iPosition.DrawText( aGc, iText->Des(), ETrue, color );
       
   101         }
       
   102     else
       
   103         {
       
   104         iIconRect.DrawImage( aGc, iBitmap, iMask );
       
   105         }
       
   106     }
       
   107 
       
   108 // ---------------------------------------------------------
       
   109 // CCamSliderLegend::Rect
       
   110 // Returns the legend rect 
       
   111 // ---------------------------------------------------------
       
   112 //
       
   113 TRect CCamSliderLegend::Rect() const
       
   114     {
       
   115     if ( iItem == ECamSliderLegendItemText )
       
   116         {
       
   117         return iPosition.TextRect();
       
   118         }
       
   119     else
       
   120         {
       
   121         return iIconRect.Rect();
       
   122         }
       
   123     }
       
   124 
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CCamSliderLegend::ConstructTextL
       
   128 // Constructs a text element from resources with given layout
       
   129 // ---------------------------------------------------------
       
   130 //
       
   131 void CCamSliderLegend::ConstructTextL(
       
   132         TResourceReader& aReader,
       
   133         const TRect& aRect,
       
   134         const TAknTextComponentLayout& aLayout )
       
   135     {      
       
   136 	iItem = static_cast<TCamSliderLegendItem>( aReader.ReadInt16() );
       
   137 	if ( iItem == ECamSliderLegendItemText )
       
   138 		{ // must be a text	
       
   139 		iPosition.LayoutText( aRect, aLayout );
       
   140 		iText = aReader.ReadHBufC16L();
       
   141         aReader.ReadInt32(); // bitmap
       
   142         aReader.ReadInt32(); // mask
       
   143 		}
       
   144     }
       
   145  
       
   146 // ---------------------------------------------------------
       
   147 // CCamSliderLegend::ConstructIconL
       
   148 // Constructs an icon from resources with given layout
       
   149 // ---------------------------------------------------------
       
   150 //
       
   151 void CCamSliderLegend::ConstructIconL(
       
   152         TResourceReader& aReader,
       
   153         const TRect& aRect,
       
   154         const TAknWindowComponentLayout& aLayout )
       
   155     {      
       
   156 	iItem = static_cast<TCamSliderLegendItem>( aReader.ReadInt16() );
       
   157 	if ( iItem == ECamSliderLegendItemIcon )
       
   158 	    { // must be an icon	
       
   159 		iIconRect.LayoutRect( aRect, aLayout );
       
   160 		iText = aReader.ReadHBufC16L();
       
   161 		TInt bitmap = aReader.ReadInt32();
       
   162 		TInt mask = aReader.ReadInt32();
       
   163 		
       
   164 		// Create component bitmaps 
       
   165         TFileName resFileName;
       
   166         CamUtility::ResourceFileName( resFileName );
       
   167         TPtrC resname = resFileName;
       
   168 		AknIconUtils::CreateIconL( iBitmap, iMask, resname, bitmap, mask );
       
   169         AknIconUtils::SetSize( iBitmap, iIconRect.Rect().Size() );
       
   170 		}
       
   171     }
       
   172 
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CCamCaptureSetupSlider::CCamCaptureSetupSlider
       
   176 // C++ default constructor can NOT contain any code, that
       
   177 // might leave.
       
   178 // -----------------------------------------------------------------------------
       
   179 //
       
   180 CCamCaptureSetupSlider::CCamCaptureSetupSlider( MCamSettingValueObserver* aObserver,
       
   181                                                 TCamSettingItemIds aSettingType,
       
   182                                                 TInt aSteps ) 
       
   183 : iSettingObserver( aObserver ), iSettingType( aSettingType ), iSteps( aSteps )
       
   184     {
       
   185     }
       
   186 
       
   187 
       
   188 /*
       
   189  * CCamCaptureSetupSlider::InitializeSliderValuesL
       
   190  */
       
   191 
       
   192 void CCamCaptureSetupSlider::InitializeSliderValuesL()
       
   193     {
       
   194     CCameraUiConfigManager* configManager = static_cast<CCamAppUi*>
       
   195                            ( iCoeEnv->AppUi() )->AppController().UiConfigManagerPtr();
       
   196     TBool configureRunTime = EFalse;
       
   197     RArray<TInt> range;
       
   198     CleanupClosePushL( range );
       
   199     
       
   200     switch ( iSettingType )
       
   201         {
       
   202         case ECamSettingItemDynamicPhotoBrightness:
       
   203         case ECamSettingItemDynamicVideoBrightness:
       
   204         case ECamSettingItemUserSceneBrightness:
       
   205             {
       
   206             if ( configManager && configManager->IsBrightnessSupported() )
       
   207                 {
       
   208                 configManager->SupportedBrightnessRangeL( range );
       
   209                 configureRunTime = ETrue;
       
   210                 }
       
   211             break;
       
   212             }
       
   213         case ECamSettingItemDynamicPhotoContrast:
       
   214         case ECamSettingItemDynamicVideoContrast:
       
   215         case ECamSettingItemUserSceneContrast:
       
   216             {
       
   217             if ( configManager && configManager->IsContrastSupported() )
       
   218                 {
       
   219                 configManager->SupportedContrastRangeL( range );
       
   220                 configureRunTime = ETrue;
       
   221                 }           
       
   222             }
       
   223             break;
       
   224 
       
   225         case ECamSettingItemDynamicPhotoExposure:
       
   226         case ECamSettingItemDynamicVideoExposure:
       
   227         case ECamSettingItemUserSceneExposure:
       
   228             {
       
   229             // get range of EV values from product specific utility
       
   230             TCamEvCompRange evRange = 
       
   231                 static_cast<CCamAppUi*>(
       
   232                         iCoeEnv->AppUi() )->AppController().EvRange();
       
   233 
       
   234             iMaxSliderValue = evRange.iMaxValue * evRange.iStepsPerUnit;
       
   235             iMinSliderValue = evRange.iMinValue * evRange.iStepsPerUnit;
       
   236             iNumSliderValues = iMaxSliderValue - iMinSliderValue;
       
   237             }
       
   238             break;
       
   239 
       
   240 		default:
       
   241 			{
       
   242             }
       
   243             break;
       
   244         }
       
   245 
       
   246     if ( configureRunTime )
       
   247         {
       
   248         if ( range.Count() > 0 )
       
   249             {
       
   250             iMinSliderValue = range[0]; //min value
       
   251             iMaxSliderValue = range[1]; // max value
       
   252             iNumSliderValues = range[range.Count()-1]; // steps
       
   253             }
       
   254         }
       
   255 
       
   256     CleanupStack::PopAndDestroy( &range );
       
   257     
       
   258     }
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CCamCaptureSetupSlider::ConstructL
       
   262 // Symbian 2nd phase constructor can leave.
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 void CCamCaptureSetupSlider::ConstructL( const CCoeControl* aParent )
       
   266     {
       
   267     __ASSERT_DEBUG( aParent!=NULL, CamPanic( ECamPanicNullPointer ) );
       
   268     
       
   269     InitializeSliderValuesL();
       
   270     
       
   271     iParentControl = aParent;
       
   272     SetContainerWindowL( *iParentControl );  
       
   273 
       
   274     TFileName resFileName;
       
   275     CamUtility::ResourceFileName( resFileName );
       
   276     TPtrC resname = resFileName;
       
   277 
       
   278     // Create component bitmaps 
       
   279     AknIconUtils::CreateIconL( iBitmapShaft, 
       
   280                                iBitmapShaftMask, 
       
   281                                resname, 
       
   282                                EMbmCameraappQgn_graf_nslider_cam4_empty,
       
   283                                EMbmCameraappQgn_graf_nslider_cam4_empty_mask );
       
   284 
       
   285     AknIconUtils::CreateIconL( iBitmapThumb, 
       
   286                                iBitmapThumbMask, 
       
   287                                resname, 
       
   288                                EMbmCameraappQgn_graf_nslider_cam4_marker,
       
   289                                EMbmCameraappQgn_graf_nslider_cam4_marker_mask );
       
   290 
       
   291     AknIconUtils::CreateIconL( iBitmapThumbSelected, 
       
   292                                iBitmapThumbSelectedMask, 
       
   293                                resname, 
       
   294                                EMbmCameraappQgn_graf_nslider_cam4_marker_selected,
       
   295                                EMbmCameraappQgn_graf_nslider_cam4_marker_selected_mask );
       
   296     iBitmapThumbCurrent = iBitmapThumb;
       
   297     iBitmapThumbCurrentMask = iBitmapThumbMask;
       
   298     }
       
   299 
       
   300 // -----------------------------------------------------------------------------
       
   301 // CCamCaptureSetupSlider::NewL
       
   302 // Two-phased constructor.
       
   303 // -----------------------------------------------------------------------------
       
   304 //
       
   305 CCamCaptureSetupSlider* CCamCaptureSetupSlider::NewL( const CCoeControl* aParent, 
       
   306                                                       MCamSettingValueObserver* aObserver,
       
   307                                                       TCamSettingItemIds aSettingItem,
       
   308                                                       TInt aSteps )
       
   309     {
       
   310     CCamCaptureSetupSlider* self = 
       
   311         new( ELeave ) CCamCaptureSetupSlider( aObserver, aSettingItem, aSteps );
       
   312     CleanupStack::PushL( self );
       
   313     self->ConstructL( aParent );
       
   314     CleanupStack::Pop( self );
       
   315     return self;
       
   316     }
       
   317 
       
   318 // -----------------------------------------------------------------------------
       
   319 // CCamCaptureSetupSlider::~CCamCaptureSetupSlider
       
   320 // Destructor
       
   321 // -----------------------------------------------------------------------------
       
   322 //    
       
   323 CCamCaptureSetupSlider::~CCamCaptureSetupSlider()
       
   324   {
       
   325   PRINT( _L("Camera => ~CCamCaptureSetupSlider") );
       
   326 
       
   327   // Destroy legend strings
       
   328   iLegendArray.ResetAndDestroy();
       
   329 
       
   330   delete iBitmapShaft;
       
   331   delete iBitmapShaftMask;
       
   332   delete iBitmapThumb;
       
   333   delete iBitmapThumbMask;
       
   334   delete iBitmapThumbSelected;
       
   335   delete iBitmapThumbSelectedMask;
       
   336   PRINT( _L("Camera <= ~CCamCaptureSetupSlider") );
       
   337   }
       
   338 
       
   339 // -----------------------------------------------------------------------------
       
   340 // CCamCaptureSetupSlider::InitializeL
       
   341 // Sets up the slider with the initial value
       
   342 // -----------------------------------------------------------------------------
       
   343 //
       
   344 void CCamCaptureSetupSlider::InitializeL( TInt aValue )
       
   345     {
       
   346     // Check the initial value is valid.  If no, leave.
       
   347     if ( aValue < iMinSliderValue ||
       
   348          aValue > iMaxSliderValue )
       
   349         {
       
   350         User::Leave( KErrArgument );
       
   351         }
       
   352            
       
   353     iValue = aValue;
       
   354     }
       
   355 
       
   356 // -----------------------------------------------------------------------------
       
   357 // CCamCaptureSetupSlider::MinValue
       
   358 // Returns the minimum slider value
       
   359 // -----------------------------------------------------------------------------
       
   360 //
       
   361 TInt CCamCaptureSetupSlider::MinValue() const
       
   362     {
       
   363     return iMinSliderValue;
       
   364     }
       
   365 
       
   366 // -----------------------------------------------------------------------------
       
   367 // CCamCaptureSetupSlider::MaxValue
       
   368 // Returns the maximum slider value
       
   369 // -----------------------------------------------------------------------------
       
   370 //
       
   371 TInt CCamCaptureSetupSlider::MaxValue() const
       
   372     {
       
   373     return iMaxSliderValue;
       
   374     }
       
   375     
       
   376       
       
   377 // -----------------------------------------------------------------------------
       
   378 // CCamCaptureSetupSlider::SetRange
       
   379 // Sets the minimum and maximum values of the slider control
       
   380 // -----------------------------------------------------------------------------
       
   381 //
       
   382 void CCamCaptureSetupSlider::SetRange( TInt aMin, TInt aMax ) 
       
   383     {
       
   384     ASSERT( aMin < aMax );
       
   385     iMinSliderValue = aMin;
       
   386     iMaxSliderValue = aMax;    
       
   387     iNumSliderValues = iMaxSliderValue;
       
   388     }
       
   389     
       
   390 
       
   391 // -----------------------------------------------------------------------------
       
   392 // CCamCaptureSetupSlider::Draw
       
   393 // Draws the slider 
       
   394 // -----------------------------------------------------------------------------
       
   395 //
       
   396 void CCamCaptureSetupSlider::Draw( const TRect& /*aRect*/ ) const
       
   397     {
       
   398     CWindowGc& gc = SystemGc();
       
   399 
       
   400     MAknsSkinInstance* skin = AknsUtils::SkinInstance();
       
   401     MAknsControlContext *cc = AknsDrawUtils::ControlContext( iParentControl ); 
       
   402     AknsDrawUtils::Background( skin, cc, iParentControl, gc, Rect() );
       
   403     
       
   404     // STEP 1: Draw the legend text
       
   405     TInt count = iLegendArray.Count();
       
   406     TInt i = 0;
       
   407     for ( i = 0; i < count; i++ )
       
   408         {
       
   409         iLegendArray[i]->Draw( gc );
       
   410         }
       
   411 
       
   412     CFbsBitmap* shaft = iBitmapShaft;
       
   413     CFbsBitmap* shaftMask = iBitmapShaftMask;
       
   414 
       
   415     // Step 2: Draw the shaft bitmap    
       
   416     if ( shaft )
       
   417         {
       
   418         iShaftLayout.DrawImage( gc, shaft, shaftMask );
       
   419         }
       
   420 
       
   421     // Step 3: Work out the position of the thumb
       
   422     TPoint thumbPoint = iThumbPoint;  
       
   423     
       
   424     // This is the max bitmap offset from the top of the shaft that the thumb can be
       
   425     TInt maxVOffset = iShaftLayout.Rect().Size().iHeight - iBitmapThumb->SizeInPixels().iHeight;
       
   426 
       
   427     // This is the no. of pixels for a "step"
       
   428     TInt stepInPixels = ( maxVOffset * KDivisorFactor ) / iNumSliderValues;
       
   429 
       
   430     // Thumb position = top of shaft + delta
       
   431     TInt nbrSteps = iMaxSliderValue - iValue;
       
   432     thumbPoint.iY = iShaftLayout.Rect().iTl.iY + stepInPixels *  nbrSteps / KDivisorFactor;
       
   433         
       
   434     // Step 4: Blit the thumb bitmap
       
   435     gc.BitBltMasked( thumbPoint, iBitmapThumbCurrent, iBitmapThumb->SizeInPixels(), iBitmapThumbCurrentMask, ETrue );
       
   436     }
       
   437 
       
   438 
       
   439 // ---------------------------------------------------------
       
   440 // CCamCaptureSetupSlider::SizeChanged
       
   441 // Calculates the new minimum size
       
   442 // ---------------------------------------------------------
       
   443 //
       
   444 void CCamCaptureSetupSlider::SizeChanged()
       
   445     {        
       
   446     TRAPD( ignore, ReadLayoutL() );
       
   447     if ( ignore )
       
   448         { 
       
   449         // Do nothing ( removes build warning )
       
   450         }                 
       
   451 
       
   452     // Work out the minimum size
       
   453     TInt count = iLegendArray.Count();
       
   454 
       
   455     TRect minimumRect;
       
   456 
       
   457     // Start min rect as first legend text
       
   458     if ( count > 0 )
       
   459         {
       
   460         minimumRect = iLegendArray[0]->Rect();
       
   461         }
       
   462 
       
   463     // Take into account the other legend texts
       
   464     TInt i;
       
   465     for ( i = 1; i < count; i++ )
       
   466         {            
       
   467         minimumRect.BoundingRect( iLegendArray[i]->Rect() );
       
   468         }
       
   469 
       
   470     // Take into account the shaft bitmap
       
   471     minimumRect.BoundingRect( iShaftLayout.Rect() );
       
   472 
       
   473     iMinimumSize = minimumRect.Size();
       
   474     }   
       
   475 
       
   476 
       
   477 // -----------------------------------------------------------------------------
       
   478 // CCamCaptureSetupSlider::OfferKeyEventL
       
   479 // Allows the user to change the current EV value via key presses.
       
   480 // -----------------------------------------------------------------------------
       
   481 //
       
   482 TKeyResponse CCamCaptureSetupSlider::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
       
   483     {
       
   484     PRINT( _L("CCamCaptureSetupSlider::OfferKeyEventL") );
       
   485     if ( aType == EEventKey )
       
   486         {
       
   487         if ( aKeyEvent.iScanCode == EStdKeyUpArrow ) 
       
   488             {
       
   489             if ( iValue <  iMaxSliderValue )
       
   490                 {
       
   491                 iValue ++;
       
   492                 iSettingObserver->HandleSettingValueUpdateL( iValue );  // Tell observer about change
       
   493                 DrawNow();
       
   494                 }
       
   495 
       
   496             return EKeyWasConsumed;
       
   497             }
       
   498         else if ( aKeyEvent.iScanCode == EStdKeyDownArrow ) 
       
   499             {
       
   500             if ( iValue > iMinSliderValue )
       
   501                 {
       
   502                 iValue --;
       
   503                 iSettingObserver->HandleSettingValueUpdateL( iValue );  // Tell observer about change
       
   504                 DrawNow();
       
   505                 }
       
   506             
       
   507             return EKeyWasConsumed;
       
   508             }
       
   509         else if ( aKeyEvent.iCode == EKeyOK && aKeyEvent.iRepeats == 0 )
       
   510             {
       
   511             return EKeyWasConsumed;
       
   512             }
       
   513         // otherwise, do nothing
       
   514         else
       
   515             {
       
   516             // empty statement to remove Lint error
       
   517             }
       
   518         }
       
   519     return EKeyWasNotConsumed;
       
   520     }
       
   521 
       
   522 // ---------------------------------------------------------
       
   523 // CCamCaptureSetupSlider::MinimumSize
       
   524 // ---------------------------------------------------------
       
   525 //
       
   526 TSize CCamCaptureSetupSlider::MinimumSize()
       
   527     {
       
   528     TSize zerosize = TSize( 0, 0 );
       
   529     if ( iMinimumSize == zerosize )
       
   530         {
       
   531         SizeChanged();
       
   532         }
       
   533     return iMinimumSize; 
       
   534     }
       
   535 
       
   536 
       
   537 // ---------------------------------------------------------
       
   538 // CCamCaptureSetupSlider::ReadLayoutL
       
   539 // ---------------------------------------------------------
       
   540 //
       
   541 void CCamCaptureSetupSlider::ReadLayoutL()
       
   542     {
       
   543     TRect shaftRect;
       
   544     TSize shaftSize;
       
   545 
       
   546     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
       
   547                                        iLayoutAreaRect );
       
   548 
       
   549     // layout area rectangle contains the area, where components need to be 
       
   550     // drawn to. the container size is the whole screen, but the layouts are 
       
   551     // for the client area. aRect is the container size that might include or
       
   552     // might not include statuspane area. calculating area self will
       
   553     // go around the problem
       
   554 
       
   555     // We're starting again from scratch, so delete the old legend layouts
       
   556     iLegendArray.ResetAndDestroy();
       
   557     if ( CamUtility::IsNhdDevice() ) 
       
   558         {
       
   559         TouchLayoutL();
       
   560         }
       
   561     else
       
   562         {
       
   563         NonTouchLayoutL();
       
   564         }
       
   565       
       
   566     AknIconUtils::SetSize( iBitmapThumb, 
       
   567                            iThumbLayout.Rect().Size(), EAspectRatioPreserved );
       
   568     AknIconUtils::SetSize( iBitmapThumbSelected, 
       
   569                            iThumbLayout.Rect().Size(), EAspectRatioPreserved );
       
   570 
       
   571     // set the shaft icon size
       
   572     shaftRect = iShaftLayout.Rect();
       
   573     shaftSize = shaftRect.Size();
       
   574     AknIconUtils::SetSize( iBitmapShaft, shaftSize, EAspectRatioNotPreserved );
       
   575 
       
   576     // calculate initial thumb position
       
   577     iThumbPoint = TPoint( shaftRect.iTl.iX + shaftSize.iWidth/2 - 
       
   578                           iBitmapThumb->SizeInPixels().iWidth/2, 
       
   579                           shaftRect.iTl.iY + shaftSize.iHeight/2 - 
       
   580                           iBitmapThumb->SizeInPixels().iHeight/2 );
       
   581     }
       
   582 
       
   583 // ---------------------------------------------------------
       
   584 // CCamCaptureSetupSlider::TouchLayoutL
       
   585 // ---------------------------------------------------------
       
   586 //
       
   587 void CCamCaptureSetupSlider::TouchLayoutL()
       
   588     {      
       
   589     TRect statusPaneRect;
       
   590     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane,
       
   591                                        statusPaneRect );
       
   592     iLayoutAreaRect.BoundingRect( statusPaneRect );
       
   593     
       
   594     // Get the slider layout
       
   595     TAknLayoutRect sliderLayout;
       
   596     sliderLayout.LayoutRect( iLayoutAreaRect, 
       
   597                           AknLayoutScalable_Apps::main_cset_slider_pane( 1 ) );
       
   598     TRect sliderRect( sliderLayout.Rect() );
       
   599 
       
   600     // Set the thumb layout and icon size
       
   601     iThumbLayout.LayoutRect( sliderRect, 
       
   602                       AknLayoutScalable_Apps::main_cset_slider_pane_g18( 0 ) );
       
   603 
       
   604     if ( iSettingType == ECamSettingItemDynamicPhotoContrast ||
       
   605          iSettingType == ECamSettingItemDynamicVideoContrast ||
       
   606          iSettingType == ECamSettingItemUserSceneContrast )
       
   607         {
       
   608         // Set the shaft layout and icon size for Contrast slider
       
   609         iShaftLayout.LayoutRect( sliderRect, 
       
   610                               AknLayoutScalable_Apps::cset_slider_pane( 5 )  );
       
   611         // set Contrast slider legend layouts      
       
   612         TouchContrastLayoutL( sliderRect ); 
       
   613         }   
       
   614     else  
       
   615         {
       
   616         // Set the shaft layout and icon size for EV slider
       
   617         iShaftLayout.LayoutRect( sliderRect, 
       
   618                               AknLayoutScalable_Apps::cset_slider_pane( 7 )  );
       
   619         // set EV slider legend layouts                  
       
   620         TouchEVLayoutL( sliderRect );
       
   621         }   
       
   622     }
       
   623 
       
   624 // -----------------------------------------------------------------------------
       
   625 // CCamCaptureSetupSlider::NonTouchLayout
       
   626 // -----------------------------------------------------------------------------
       
   627 //
       
   628 void CCamCaptureSetupSlider::NonTouchLayoutL()
       
   629     {   
       
   630     // Non-touch has a visible title & status panes
       
   631     TRect titlePaneRect;
       
   632     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ETitlePane, 
       
   633                                        titlePaneRect );
       
   634     iLayoutAreaRect.Move( 0, -titlePaneRect.Height() );
       
   635     
       
   636     iThumbLayout.LayoutRect( Rect(), 
       
   637                       AknLayoutScalable_Apps::main_cset6_slider_pane_g1( 2 ) );
       
   638 
       
   639     if ( iSettingType == ECamSettingItemDynamicPhotoContrast ||
       
   640          iSettingType == ECamSettingItemDynamicVideoContrast ||
       
   641          iSettingType == ECamSettingItemUserSceneContrast )
       
   642         {
       
   643         // Set the shaft layout for Contrast slider
       
   644         iShaftLayout.LayoutRect( Rect(), 
       
   645                               AknLayoutScalable_Apps::cset6_slider_pane( 5 ) );
       
   646         // set Contrast slider legend layouts      
       
   647         NonTouchContrastLayoutL( Rect() );
       
   648         }   
       
   649     else  
       
   650         {
       
   651         // Set the shaft layout for EV slider
       
   652         iShaftLayout.LayoutRect( Rect(), 
       
   653                               AknLayoutScalable_Apps::cset6_slider_pane( 6 ) ); 
       
   654         // set EV slider legend layouts   
       
   655         NonTouchEVLayoutL( Rect() );
       
   656         }      
       
   657     }
       
   658 
       
   659 // -----------------------------------------------------------------------------
       
   660 // CCamCaptureSetupSlider::TouchContrastLayoutL
       
   661 // -----------------------------------------------------------------------------
       
   662 //
       
   663 void CCamCaptureSetupSlider::TouchContrastLayoutL( const TRect& aParentRect )
       
   664     {
       
   665     TInt resourceId = ROID(R_CAM_CAPTURE_SETUP_SLIDER_CONTRAST_ARRAY_ID);
       
   666     TResourceReader reader; 
       
   667     iEikonEnv->CreateResourceReaderLC( reader, resourceId );    
       
   668 
       
   669     const TInt count = reader.ReadInt16();
       
   670     
       
   671     // Read all EV entries from the resource file and construct them with layout
       
   672     for ( TInt i = 0; i < count; i++ )
       
   673         {
       
   674         CCamSliderLegend* legend = new ( ELeave ) CCamSliderLegend;
       
   675         CleanupStack::PushL( legend );
       
   676         switch ( i )
       
   677             {
       
   678             case KContrastPlusInd :
       
   679 			    {
       
   680                 legend->ConstructTextL( 
       
   681                     reader, 
       
   682                     aParentRect, 
       
   683                     AknLayoutScalable_Apps::main_cset_slider_pane_t14( 5 ) );
       
   684                 }
       
   685 			    break;
       
   686             case KContrastMinusInd :
       
   687 			    {
       
   688                 legend->ConstructTextL( 
       
   689                     reader, 
       
   690                     aParentRect, 
       
   691                     AknLayoutScalable_Apps::main_cset_slider_pane_t15( 5 ) );
       
   692                 }
       
   693 			    break;
       
   694             case KContrastIconInd :
       
   695 			    {
       
   696                 legend->ConstructIconL( 
       
   697                     reader, 
       
   698                     aParentRect, 
       
   699                     AknLayoutScalable_Apps::main_cset_slider_pane_g15( 2 ) );
       
   700                 }
       
   701 			    break;
       
   702             default:
       
   703 			    {
       
   704                 }
       
   705 			    break;
       
   706             }
       
   707         User::LeaveIfError( iLegendArray.Append( legend ) );
       
   708         CleanupStack::Pop( legend );
       
   709         }
       
   710         
       
   711     CleanupStack::PopAndDestroy(); // reader
       
   712 	}
       
   713 	
       
   714 // -----------------------------------------------------------------------------
       
   715 // CCamCaptureSetupSlider::NonTouchContrastLayoutL
       
   716 // -----------------------------------------------------------------------------
       
   717 //
       
   718 void CCamCaptureSetupSlider::NonTouchContrastLayoutL( 
       
   719                                                      const TRect& aParentRect )
       
   720     {
       
   721     TInt resourceId = ROID(R_CAM_CAPTURE_SETUP_SLIDER_CONTRAST_ARRAY_ID);
       
   722     TResourceReader reader; 
       
   723     iEikonEnv->CreateResourceReaderLC( reader, resourceId );    
       
   724 
       
   725     const TInt count = reader.ReadInt16();
       
   726     
       
   727     // Read all EV entries from the resource file 
       
   728     // and construct them with layout
       
   729     for ( TInt i = 0; i < count; i++ )
       
   730         {
       
   731         CCamSliderLegend* legend = new ( ELeave ) CCamSliderLegend;
       
   732         CleanupStack::PushL( legend );
       
   733         switch ( i )
       
   734             {
       
   735             case KContrastPlusInd :
       
   736                 {
       
   737                 legend->ConstructTextL( 
       
   738                     reader, 
       
   739                     aParentRect, 
       
   740                     AknLayoutScalable_Apps::main_cset6_slider_pane_t14( 5 ) );  
       
   741                 }
       
   742                 break;
       
   743             case KContrastMinusInd :
       
   744                 {
       
   745                 legend->ConstructTextL( 
       
   746                     reader, 
       
   747                     aParentRect, 
       
   748                     AknLayoutScalable_Apps::main_cset6_slider_pane_t15( 5 ) );
       
   749                 }
       
   750                 break;
       
   751             case KContrastIconInd :
       
   752                 {
       
   753                 legend->ConstructIconL( 
       
   754                     reader, 
       
   755                     aParentRect, 
       
   756                     AknLayoutScalable_Apps::main_cset6_slider_pane_g15( 2 ) );
       
   757                 }
       
   758                 break;
       
   759             default:
       
   760                 {
       
   761                 }
       
   762                 break;
       
   763             }
       
   764         User::LeaveIfError( iLegendArray.Append( legend ) );
       
   765         CleanupStack::Pop( legend );
       
   766         }
       
   767         
       
   768     CleanupStack::PopAndDestroy(); // reader
       
   769     }
       
   770 
       
   771 // -----------------------------------------------------------------------------
       
   772 // CCamCaptureSetupSlider::TouchEVLayoutL
       
   773 // -----------------------------------------------------------------------------
       
   774 //
       
   775 void CCamCaptureSetupSlider::TouchEVLayoutL( const TRect& aParentRect )
       
   776 	{
       
   777 	TInt resourceId = ROID(R_CAM_CAPTURE_SETUP_SLIDER_EV_ARRAY_ID);
       
   778     TResourceReader reader; 
       
   779     iEikonEnv->CreateResourceReaderLC( reader, resourceId );    
       
   780 
       
   781     const TInt count = reader.ReadInt16();
       
   782     
       
   783     // Read all Contrast entries from the resource file 
       
   784     // and construct them with layout
       
   785     for ( TInt i = 0; i < count; i++ )
       
   786         {
       
   787         CCamSliderLegend* legend = new ( ELeave ) CCamSliderLegend;
       
   788         CleanupStack::PushL( legend );
       
   789         switch ( i )
       
   790             {
       
   791             case KEVPlus20Ind :
       
   792 			    {
       
   793                 legend->ConstructTextL( 
       
   794                     reader, 
       
   795                     aParentRect, 
       
   796                     AknLayoutScalable_Apps::main_cset_slider_pane_t1( 6 ) );
       
   797                 }
       
   798 			    break;
       
   799             case KEVPlus15Ind :
       
   800 			    {
       
   801                 legend->ConstructTextL( 
       
   802                     reader, 
       
   803                     aParentRect, 
       
   804                     AknLayoutScalable_Apps::main_cset_slider_pane_t8( 2 ) );
       
   805                 }
       
   806 			    break;
       
   807             case KEVPlus10Ind :
       
   808 			    {
       
   809                 legend->ConstructTextL( 
       
   810                     reader, 
       
   811                     aParentRect, 
       
   812                     AknLayoutScalable_Apps::main_cset_slider_pane_t2( 3 ) );
       
   813                 }
       
   814 			    break;
       
   815             case KEVPlus05Ind :
       
   816 			    {
       
   817                 legend->ConstructTextL( 
       
   818                     reader, 
       
   819                     aParentRect, 
       
   820                     AknLayoutScalable_Apps::main_cset_slider_pane_t9( 2 ) );
       
   821                 }
       
   822 			    break;
       
   823             case KEV0Ind :
       
   824 			    {
       
   825                 legend->ConstructTextL( 
       
   826                     reader, 
       
   827                     aParentRect, 
       
   828                     AknLayoutScalable_Apps::main_cset_slider_pane_t3( 3 ) );
       
   829                 }
       
   830 			    break;
       
   831             case KEVMinus05Ind :
       
   832 			    {
       
   833                 legend->ConstructTextL( 
       
   834                     reader, 
       
   835                     aParentRect, 
       
   836                     AknLayoutScalable_Apps::main_cset_slider_pane_t10( 2 ) );
       
   837                 }
       
   838 			    break;
       
   839             case KEVMinus10Ind :
       
   840 			    {
       
   841                 legend->ConstructTextL( 
       
   842                     reader, 
       
   843                     aParentRect, 
       
   844                     AknLayoutScalable_Apps::main_cset_slider_pane_t4( 3 ) );
       
   845                 }
       
   846 			    break;
       
   847             case KEVMinus15Ind :
       
   848 			    {
       
   849                 legend->ConstructTextL( 
       
   850                     reader, 
       
   851                     aParentRect, 
       
   852                     AknLayoutScalable_Apps::main_cset_slider_pane_t11( 2 ) );
       
   853                 }
       
   854 			    break;
       
   855             case KEVMinus20Ind :
       
   856 			    {
       
   857                 legend->ConstructTextL( 
       
   858                     reader, 
       
   859                     aParentRect, 
       
   860                     AknLayoutScalable_Apps::main_cset_slider_pane_t5( 3 ) );
       
   861                 }
       
   862 			    break;
       
   863             default:
       
   864 			    {
       
   865                 }
       
   866 			    break;
       
   867             }
       
   868         User::LeaveIfError( iLegendArray.Append( legend ) );
       
   869         CleanupStack::Pop( legend );
       
   870         }
       
   871         
       
   872     CleanupStack::PopAndDestroy(); // reader
       
   873 	}
       
   874 
       
   875 
       
   876 
       
   877 // -----------------------------------------------------------------------------
       
   878 // CCamCaptureSetupSlider::NonTouchEVLayoutL
       
   879 // -----------------------------------------------------------------------------
       
   880 //
       
   881 void CCamCaptureSetupSlider::NonTouchEVLayoutL( const TRect& aParentRect )
       
   882     {
       
   883     TInt resourceId = ROID(R_CAM_CAPTURE_SETUP_SLIDER_EV_ARRAY_ID);
       
   884     TResourceReader reader; 
       
   885     iEikonEnv->CreateResourceReaderLC( reader, resourceId );    
       
   886 
       
   887     const TInt count = reader.ReadInt16();
       
   888     
       
   889     // Read all Contrast entries from the resource file 
       
   890     // and construct them with layout
       
   891     for ( TInt i = 0; i < count; i++ )
       
   892         {
       
   893         CCamSliderLegend* legend = new ( ELeave ) CCamSliderLegend;
       
   894         CleanupStack::PushL( legend );
       
   895         switch ( i )
       
   896             {
       
   897             case KEVPlus20Ind :
       
   898                 {
       
   899                 legend->ConstructTextL( reader, aParentRect, 
       
   900                     AknLayoutScalable_Apps::main_cset6_slider_pane_t1( 5 ) );
       
   901                 }
       
   902                 break;
       
   903             case KEVPlus15Ind :
       
   904                 {
       
   905                 legend->ConstructTextL( reader, aParentRect, 
       
   906                     AknLayoutScalable_Apps::main_cset6_slider_pane_t8( 2 ) );
       
   907                 }
       
   908                 break;
       
   909             case KEVPlus10Ind :
       
   910                 {
       
   911                 legend->ConstructTextL( reader, aParentRect, 
       
   912                     AknLayoutScalable_Apps::main_cset6_slider_pane_t2( 3 ) ); 
       
   913                 }
       
   914                 break;
       
   915             case KEVPlus05Ind :
       
   916                 {
       
   917                 legend->ConstructTextL( reader, aParentRect, 
       
   918                     AknLayoutScalable_Apps::main_cset6_slider_pane_t9( 2 ) );
       
   919                 }
       
   920                 break;
       
   921             case KEV0Ind :
       
   922                 {
       
   923                 legend->ConstructTextL( reader, aParentRect, 
       
   924                     AknLayoutScalable_Apps::main_cset6_slider_pane_t3( 3 ) ); 
       
   925                 }
       
   926                 break;
       
   927             case KEVMinus05Ind :
       
   928                 {
       
   929                 legend->ConstructTextL( reader, aParentRect, 
       
   930                     AknLayoutScalable_Apps::main_cset6_slider_pane_t10( 2 ) );
       
   931                 }
       
   932                 break;
       
   933             case KEVMinus10Ind :
       
   934                 {
       
   935                 legend->ConstructTextL( reader, aParentRect, 
       
   936                     AknLayoutScalable_Apps::main_cset6_slider_pane_t4( 3 ) );
       
   937                 }
       
   938                 break;
       
   939             case KEVMinus15Ind :
       
   940                 {
       
   941                 legend->ConstructTextL( reader, aParentRect, 
       
   942                     AknLayoutScalable_Apps::main_cset6_slider_pane_t11( 2 ) );
       
   943                 }
       
   944                 break;
       
   945             case KEVMinus20Ind :
       
   946                 {
       
   947                 legend->ConstructTextL( reader, aParentRect, 
       
   948                     AknLayoutScalable_Apps::main_cset6_slider_pane_t5( 3 ) );
       
   949                 }
       
   950                 break;
       
   951             default:
       
   952                 break;
       
   953             }
       
   954         User::LeaveIfError( iLegendArray.Append( legend ) );
       
   955         CleanupStack::Pop( legend );
       
   956         }
       
   957         
       
   958     CleanupStack::PopAndDestroy(); // reader
       
   959     }
       
   960 
       
   961 // -----------------------------------------------------------------------------
       
   962 // CCamCaptureSetupSlider::HandlePointerEventL
       
   963 // Handles slider pointer events
       
   964 // -----------------------------------------------------------------------------
       
   965 //
       
   966 void CCamCaptureSetupSlider::HandlePointerEventL(const TPointerEvent& aPointerEvent)
       
   967     {   
       
   968    
       
   969     CCoeControl::HandlePointerEventL( aPointerEvent );
       
   970 
       
   971     // This is the max bitmap offset from the top of the shaft that the thumb can be
       
   972     TInt maxVOffset = iShaftLayout.Rect().Size().iHeight - iBitmapThumb->SizeInPixels().iHeight;
       
   973 
       
   974     // This is the no. of pixels for a "step"
       
   975     TInt stepInPixels = ( maxVOffset * KDivisorFactor ) / iNumSliderValues;
       
   976 
       
   977     // Calculate new setting value     
       
   978     TInt oldValue = iValue; 
       
   979     TInt deltaY = aPointerEvent.iPosition.iY - iShaftLayout.Rect().iTl.iY;
       
   980     TInt nbrSteps = deltaY / ( stepInPixels / KDivisorFactor );
       
   981     iValue = iMaxSliderValue - nbrSteps;   
       
   982     
       
   983     if ( iValue < iMinSliderValue )
       
   984         {
       
   985         iValue = iMinSliderValue;
       
   986         }
       
   987     
       
   988     if (iValue > iMaxSliderValue)
       
   989         {
       
   990         iValue = iMaxSliderValue;
       
   991         }
       
   992  
       
   993     if ( iValue != oldValue && aPointerEvent.iType == TPointerEvent::EDrag )  
       
   994         {
       
   995         MTouchFeedback* feedback = MTouchFeedback::Instance(); 
       
   996         if ( feedback )
       
   997             {
       
   998             feedback->InstantFeedback( ETouchFeedbackSensitive );        
       
   999             }
       
  1000         }
       
  1001     
       
  1002     if ( aPointerEvent.iType == TPointerEvent::EButton1Down )
       
  1003         {
       
  1004         // Change thumb marker to selected
       
  1005         iBitmapThumbCurrent = iBitmapThumbSelected; 
       
  1006         iBitmapThumbCurrentMask = iBitmapThumbSelectedMask; 
       
  1007         }    
       
  1008     
       
  1009     if ( aPointerEvent.iType == TPointerEvent::EButton1Up )
       
  1010         {
       
  1011         // Change thumb marker to normal
       
  1012         iBitmapThumbCurrent = iBitmapThumb; 
       
  1013         iBitmapThumbCurrentMask = iBitmapThumbMask; 
       
  1014         }
       
  1015   
       
  1016     iSettingObserver->HandleSettingValueUpdateL( iValue );  // Tell observer about change
       
  1017     DrawNow();
       
  1018     static_cast<CCamAppUi*>( iCoeEnv->AppUi() )->
       
  1019         AppController().StartIdleTimer();
       
  1020     }
       
  1021     
       
  1022 //  End of File  
       
  1023