camerauis/cameraapp/generic/src/CamSidePane.cpp
changeset 0 1ddebce53859
child 3 8b2d6d0384b0
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:  Side Pane control*
       
    15 */
       
    16 
       
    17 
       
    18 // INCLUDE FILES
       
    19 #include <aknview.h>
       
    20 
       
    21 #include <eikenv.h>
       
    22 #include <eikappui.h>   // For CCoeAppUiBase
       
    23 #include <eikapp.h>     // For CEikApplication
       
    24 
       
    25 #include <barsc.h>
       
    26 #include <barsread.h>
       
    27 #include <cameraapp.rsg>
       
    28 #include <vgacamsettings.rsg>
       
    29 #include <aknlayoutscalable_apps.cdl.h>
       
    30 #include <layoutmetadata.cdl.h>
       
    31 #include "CamAppUiBase.h"
       
    32 #include "CamAppUi.h"
       
    33 
       
    34 #include "CamAppController.h"
       
    35 #include "CamSidePane.h"
       
    36 
       
    37 #include "CamIndicator.h"
       
    38 #include "CamIndicatorData.h"
       
    39 #include "CamIndicatorResourceReader.h"
       
    40 #include "CamTimer.h"
       
    41 #include "CamSelfTimer.h"
       
    42 #include "CamLogger.h"
       
    43 #include "CamSettings.hrh"
       
    44 #include "CamUtility.h"
       
    45 #include "CameraUiConfigManager.h"
       
    46 #include "Cam.hrh"
       
    47 
       
    48     
       
    49 // CONSTANTS
       
    50 
       
    51 
       
    52 // ================= MEMBER FUNCTIONS =======================
       
    53 
       
    54 // ---------------------------------------------------------------------------
       
    55 // CCamSidePane::NewL
       
    56 // Symbian OS two-phased constructor
       
    57 // ---------------------------------------------------------------------------
       
    58 //
       
    59 CCamSidePane* CCamSidePane::NewL( CCamAppController& aController,
       
    60                                   TBool aOverlayViewFinder )
       
    61     {
       
    62     CCamSidePane* self = new( ELeave ) CCamSidePane( aController, 
       
    63                                                      aOverlayViewFinder );
       
    64     CleanupStack::PushL( self );
       
    65     self->ConstructL();
       
    66     CleanupStack::Pop( self ); 
       
    67     return self;
       
    68     }
       
    69 
       
    70 // Destructor
       
    71 CCamSidePane::~CCamSidePane()
       
    72   {
       
    73   PRINT( _L("Camera => ~CCamSidePane") );
       
    74   RemoveObservers();
       
    75   CCamSidePane::UnloadResourceData();
       
    76   PRINT( _L("Camera <= ~CCamSidePane") );
       
    77   }
       
    78 
       
    79 // ---------------------------------------------------------
       
    80 // CCamSidePane::ConstructL
       
    81 // Symbian OS 2nd phase constructor
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 void CCamSidePane::ConstructL()
       
    85     {
       
    86     LoadResourceDataL();
       
    87 
       
    88     // side pane is a controller, self timer and burst mode observer
       
    89     RegisterObserversL();
       
    90     iVisible = ETrue;
       
    91 
       
    92     UpdateLayout();
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CCamSidePane::LoadResourceDataL()
       
    97 // Reads in all information needed from resources
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 void CCamSidePane::LoadResourceDataL()
       
   101     {
       
   102     TResourceReader reader;                                                                                     
       
   103     CEikonEnv* eikEnv = CEikonEnv::Static();
       
   104     eikEnv->CreateResourceReaderLC( reader, ROID(R_CAM_SIDEPANE_ID));
       
   105 
       
   106     // create reader
       
   107     CCamIndicatorResourceReader* resourceReader = 
       
   108         CCamIndicatorResourceReader::NewLC( reader );
       
   109     // get indicator data from reader   
       
   110     CArrayPtrFlat<CCamIndicatorData>& indArray = resourceReader->IndicatorData();
       
   111 
       
   112     // set up indicator data
       
   113     TInt numindicators = indArray.Count(); // number of indicators
       
   114     TInt numbitmaps = 0;
       
   115     CCamIndicator* indicator = NULL;
       
   116 
       
   117     TInt i = 0;
       
   118 
       
   119     for ( i = 0; i < ECamIndicatorTotal; i++ )
       
   120         {
       
   121         User::LeaveIfError( iIndicators.Append( static_cast<CCamIndicator*>(NULL) ) );
       
   122         }
       
   123 
       
   124     for ( i = 0; i < numindicators; i++ )
       
   125         {
       
   126         CCamIndicatorData& indData = *( indArray.At( i ) );
       
   127         indicator = CCamIndicator::NewL( indData.IndicatorRect() );
       
   128         CleanupStack::PushL( indicator );
       
   129         numbitmaps = indData.IndicatorBitmapCount(); // no of bitmaps for indicator
       
   130         TInt j;
       
   131         for ( j = 0; j < numbitmaps; j++ )
       
   132             {
       
   133             // side pane assumes that mask bitmap is defined after the
       
   134             // normal one in the resource file
       
   135             indicator->AddIconL( indData.IndicatorBitmapId( j ), // bitmap
       
   136                                  indData.IndicatorBitmapId( j + 1 )); // mask
       
   137             j++; // increment past the mask
       
   138             }
       
   139         iIndicators[indData.IndicatorId()] = indicator;
       
   140         CleanupStack::Pop( indicator );
       
   141         }
       
   142 
       
   143     CleanupStack::PopAndDestroy( resourceReader );
       
   144     CleanupStack::PopAndDestroy(); // reader
       
   145     }
       
   146 
       
   147 // -----------------------------------------------------------------------------
       
   148 // CCamSidePane::ReloadResourceDataL()
       
   149 // Refreshes all resource-based information stored in the class
       
   150 // -----------------------------------------------------------------------------
       
   151 //
       
   152 void CCamSidePane::ReloadResourceDataL()
       
   153     {
       
   154     UnloadResourceData();
       
   155     LoadResourceDataL();
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CCamSidePane::UnloadResourceData()
       
   160 // Frees all dynamic resources allocated in LoadResourceDataL
       
   161 // -----------------------------------------------------------------------------
       
   162 //
       
   163 void CCamSidePane::UnloadResourceData()
       
   164     {
       
   165     iIndicators.ResetAndDestroy();
       
   166     iIndicators.Close();
       
   167     }
       
   168 
       
   169 // ---------------------------------------------------------------------------
       
   170 // CCamSidePane::CCamSidePane
       
   171 // C++ constructor
       
   172 // ---------------------------------------------------------------------------
       
   173 //
       
   174 CCamSidePane::CCamSidePane( CCamAppController& aController, 
       
   175                             TBool aOverlayViewFinder )
       
   176 :   iController( aController ), 
       
   177     iOverlayViewFinder( aOverlayViewFinder )
       
   178     {
       
   179     }
       
   180   
       
   181 // ---------------------------------------------------------
       
   182 // CCamSidePane::HandleControllerEventL
       
   183 // Handle an event from CCamAppController.
       
   184 // ---------------------------------------------------------
       
   185 //
       
   186 void CCamSidePane::HandleControllerEventL(
       
   187     TCamControllerEvent aEvent, TInt /* aError */ )
       
   188     {
       
   189     switch ( aEvent )
       
   190         {        
       
   191         case ECamEventFlashStateChanged:
       
   192             {
       
   193             if ( iIndicators[ECamIndicatorFlash]
       
   194                 && iMode != ECamControllerVideo 
       
   195                 && !IsSecondaryCameraEnabled() 
       
   196                 )
       
   197                 {
       
   198                 TCamFlashId flash = static_cast< TCamFlashId > 
       
   199                     ( iController.IntegerSettingValue( ECamSettingItemDynamicPhotoFlash ) );
       
   200                 switch ( flash )
       
   201                     {
       
   202                     case ECamFlashAuto:
       
   203                         {
       
   204                         iIndicators[ECamIndicatorFlash]->SetIcon( 0 );
       
   205                         }
       
   206                         break;
       
   207                     case ECamFlashOff:
       
   208                         {
       
   209                         iIndicators[ECamIndicatorFlash]->SetIcon( 2 );
       
   210                         }
       
   211                         break;
       
   212                     case ECamFlashAntiRedEye:
       
   213                         {
       
   214                         iIndicators[ECamIndicatorFlash]->SetIcon( 4 );
       
   215                         }
       
   216                         break;
       
   217                     case ECamFlashForced:
       
   218                         {
       
   219                         iIndicators[ECamIndicatorFlash]->SetIcon( 6 );
       
   220                         }
       
   221                         break;
       
   222                     default:
       
   223                         break;
       
   224                     }
       
   225                 iIndicators[ECamIndicatorFlash]->SetFlashing( EFalse );
       
   226                 }
       
   227             else
       
   228                 {
       
   229                 // empty statement to remove Lint error.
       
   230                 }
       
   231 
       
   232             if ( iController.UiConfigManagerPtr()->IsVideoLightSupported() )
       
   233                 {
       
   234                 if ( iIndicators[ECamIndicatorVideoFlash]
       
   235                     && iMode == ECamControllerVideo 
       
   236                     && !IsSecondaryCameraEnabled() 
       
   237                     )
       
   238                     {
       
   239                     TCamFlashId flash = static_cast< TCamFlashId > 
       
   240                         ( iController.IntegerSettingValue( ECamSettingItemDynamicVideoFlash ) );
       
   241                     switch ( flash )
       
   242                         {
       
   243                         case ECamFlashOff:
       
   244                             {
       
   245                             iIndicators[ECamIndicatorVideoFlash]->SetIcon( 0 );
       
   246                             }
       
   247                             break;
       
   248                         case ECamFlashForced:
       
   249                             {
       
   250                             iIndicators[ECamIndicatorVideoFlash]->SetIcon( 2 );
       
   251                             }
       
   252                             break;
       
   253                         default:
       
   254                             break;
       
   255                         }
       
   256                     iIndicators[ECamIndicatorVideoFlash]->SetFlashing( EFalse );
       
   257                     }
       
   258                 else
       
   259                     {
       
   260                     // empty statement to remove Lint error.
       
   261                     }
       
   262                 }
       
   263             } // end case statement
       
   264             break;
       
   265         case ECamEventSceneStateChanged:
       
   266             {
       
   267             if ( iMode == ECamControllerVideo )
       
   268                 {
       
   269                 SetVideoSceneIndicator();
       
   270                 }
       
   271             else
       
   272                 {
       
   273                 SetPhotoSceneIndicator();
       
   274                 }
       
   275             }
       
   276             break;          
       
   277 
       
   278         case ECamEventCameraChanged:
       
   279             {
       
   280             if ( !IsSecondaryCameraEnabled() )
       
   281                 {
       
   282                 if ( iMode == ECamControllerVideo )
       
   283                     {
       
   284                     SetVideoSceneIndicator();
       
   285                     if ( !iController.UiConfigManagerPtr()->IsVideoLightSupported() )
       
   286                         {
       
   287                         if ( iIndicators[ECamIndicatorFlash] )
       
   288                             {
       
   289                             iIndicators[ECamIndicatorFlash]->ClearIcon();
       
   290                             }                        
       
   291                         }
       
   292                     }
       
   293                 else
       
   294                     {
       
   295                     SetPhotoSceneIndicator();
       
   296                     if ( !iController.UiConfigManagerPtr()->IsVideoLightSupported() )
       
   297                         {
       
   298                         if ( iIndicators[ECamIndicatorFlash] )
       
   299                             {
       
   300                             iIndicators[ECamIndicatorFlash]->DisplayIcon();
       
   301                             }                        
       
   302                         }
       
   303                     }
       
   304                 }
       
   305             }
       
   306             break;
       
   307 
       
   308 #ifdef PRODUCT_USES_GENERIC_SETUP_INDICATOR
       
   309 #ifndef PRODUCT_SUPPORTS_NAVIPANE_GENERIC_SETUP_INDICATOR
       
   310         case ECamEventSetupStateChanged:
       
   311             {
       
   312             SetGenericSetupIndicator();
       
   313             }
       
   314             break;
       
   315 #endif // !PRODUCT_SUPPORTS_NAVIPANE_GENERIC_SETUP_INDICATOR
       
   316 #endif // PRODUCT_USES_GENERIC_SETUP_INDICATOR
       
   317 
       
   318         case ECamEventVideoStabChanged:
       
   319             {
       
   320             if ( iController.UiConfigManagerPtr()->IsVideoStabilizationSupported() )
       
   321                 {
       
   322                 SetVideoStabilisationIndicator();                
       
   323                 }
       
   324             break;
       
   325             }
       
   326 
       
   327         case ECamEventFaceTrackingStateChanged:
       
   328             {
       
   329             if ( iController.UiConfigManagerPtr()->IsFaceTrackingSupported() )
       
   330                 {
       
   331                 SetFaceTrackingIndicator();
       
   332                 }
       
   333             break;
       
   334             }
       
   335 
       
   336         default:
       
   337             break;
       
   338         }
       
   339     }
       
   340 
       
   341 
       
   342 // -----------------------------------------------------------------------------
       
   343 // CCamSidePane::IsVisible
       
   344 // Is the side pane invisible
       
   345 // -----------------------------------------------------------------------------
       
   346 //
       
   347 TBool CCamSidePane::IsVisible()
       
   348     {
       
   349     return iVisible;
       
   350     }
       
   351 
       
   352 // -----------------------------------------------------------------------------
       
   353 // CCamSidePane::MakeVisible
       
   354 // Makes the side pane visible
       
   355 // -----------------------------------------------------------------------------
       
   356 //
       
   357 void CCamSidePane::MakeVisible( TBool aVisible )
       
   358     {
       
   359     iVisible = aVisible;
       
   360     }
       
   361 
       
   362 // ----------------------------------------------------
       
   363 // CCamSidePane::Draw
       
   364 // Draws side pane indicators
       
   365 // ----------------------------------------------------
       
   366 //
       
   367 void CCamSidePane::Draw( CBitmapContext& aGc ) const
       
   368     {
       
   369     // if not overlaying the viewfinder then
       
   370     // just clear the side pane area
       
   371     if ( !iOverlayViewFinder )
       
   372         {
       
   373         aGc.Clear( iRect );
       
   374         }
       
   375     TInt numIndicators = iIndicators.Count();
       
   376     TInt i;
       
   377     
       
   378     CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
       
   379 
       
   380     if ( appUi )
       
   381         {
       
   382         appUi->DrawPreCaptureCourtesyUI();
       
   383         }
       
   384 
       
   385     for ( i = 0; i < numIndicators; i++ )
       
   386         {
       
   387         if ( iIndicators[i] )
       
   388             {
       
   389             iIndicators[i]->Draw( aGc );
       
   390             }
       
   391         }
       
   392     }
       
   393 
       
   394 
       
   395 // ----------------------------------------------------
       
   396 // CCamSidePane::SetRect
       
   397 // Sets rect to draw into
       
   398 // ----------------------------------------------------
       
   399 //
       
   400 void 
       
   401 CCamSidePane::SetRect( TRect& aRect ) 
       
   402   {
       
   403   iRect.SetRect( aRect.iTl, aRect.iBr );
       
   404   }
       
   405 
       
   406 
       
   407 // ----------------------------------------------------
       
   408 // CCamSidePane::SetCaptureMode
       
   409 // Sets rect to draw into
       
   410 // ----------------------------------------------------
       
   411 //
       
   412 void 
       
   413 CCamSidePane::SetCaptureMode( TCamCameraMode aMode )
       
   414   {
       
   415   iMode = aMode;
       
   416   SetInitialState();
       
   417   }
       
   418 
       
   419 // ----------------------------------------------------
       
   420 // CCamSidePane::SetInitialState
       
   421 // Notification that the burst mode has been activated/deactivated
       
   422 // ----------------------------------------------------
       
   423 //
       
   424 void CCamSidePane::SetInitialState()
       
   425   {
       
   426   CCamAppUiBase* appUi = 
       
   427       static_cast<CCamAppUiBase*>( CEikonEnv::Static()->AppUi() );
       
   428 
       
   429   // set up indicator data
       
   430   TInt numindicators = iIndicators.Count(); // number of indicators
       
   431   // set initial state for each indicator
       
   432   for ( TInt i = 0; i < numindicators; i++ )
       
   433     {
       
   434     if ( iIndicators[i] )
       
   435       {
       
   436       switch( i )
       
   437         {
       
   438         // -------------------------------------------------
       
   439         // Scene indicator
       
   440         case ECamIndicatorScene:
       
   441           {
       
   442           if( ECamControllerVideo == iMode )
       
   443             SetVideoSceneIndicator();
       
   444           else
       
   445             SetPhotoSceneIndicator();
       
   446           break;
       
   447           }
       
   448         // -------------------------------------------------
       
   449         // Flash indicator
       
   450         case ECamIndicatorFlash:
       
   451           {
       
   452           // don't show the icon if in video mode or the second 
       
   453           // camera is active
       
   454           // second camera doesn't support flash
       
   455           if ( ECamControllerVideo == iMode 
       
   456             || IsSecondaryCameraEnabled() 
       
   457              )
       
   458             {
       
   459             iIndicators[ECamIndicatorFlash]->ClearIcon();
       
   460             }
       
   461           else
       
   462             {
       
   463             TInt iconIndex = GetFlashIconIndex( iMode );
       
   464             if( KErrNotFound != iconIndex )
       
   465               {
       
   466               iIndicators[ECamIndicatorFlash]->SetIcon( iconIndex );
       
   467               }
       
   468             }
       
   469           break;
       
   470           }
       
   471         // -------------------------------------------------
       
   472         // Video Flash indicator
       
   473         case ECamIndicatorVideoFlash:
       
   474           {
       
   475           // don't show the icon if in video mode or the second 
       
   476           // camera is active
       
   477           // second camera doesn't support flash
       
   478           if ( iController.UiConfigManagerPtr()->IsVideoLightSupported()  )
       
   479               {
       
   480               if ( ECamControllerVideo != iMode 
       
   481                 || IsSecondaryCameraEnabled() 
       
   482                  )
       
   483                 {
       
   484                 iIndicators[ECamIndicatorVideoFlash]->ClearIcon();
       
   485                 }
       
   486               else
       
   487                 {
       
   488                 TInt iconIndex = GetFlashIconIndex( iMode );
       
   489                 if( KErrNotFound != iconIndex )
       
   490                   {
       
   491                   iIndicators[ECamIndicatorVideoFlash]->SetIcon( iconIndex );
       
   492                   }
       
   493                 }              
       
   494               }
       
   495           break;
       
   496           }
       
   497         // -------------------------------------------------
       
   498         // Burst mode indicator
       
   499         case ECamIndicatorBurstMode:
       
   500           {
       
   501           if ( appUi && appUi->IsBurstEnabled() )
       
   502             {
       
   503             iIndicators[ECamIndicatorBurstMode]->SetIcon( 0 );
       
   504             }
       
   505           else
       
   506             {
       
   507             iIndicators[ECamIndicatorBurstMode]->ClearIcon();
       
   508             }
       
   509           break;
       
   510           }
       
   511         // -------------------------------------------------
       
   512         // Self timer indicator
       
   513         case ECamIndicatorSelfTimer:
       
   514           {
       
   515           iIndicators[ECamIndicatorSelfTimer]->ClearIcon();
       
   516           break;
       
   517           }            
       
   518         // -------------------------------------------------
       
   519         case ECamIndicatorVideoStabiliser:
       
   520           {
       
   521           if ( iController.UiConfigManagerPtr()->IsVideoStabilizationSupported() )
       
   522               {
       
   523               SetVideoStabilisationIndicator();              
       
   524               }
       
   525           else
       
   526               {
       
   527               iIndicators[ECamIndicatorVideoStabiliser]->ClearIcon(); 
       
   528               }
       
   529           break;
       
   530           }
       
   531         // -------------------------------------------------
       
   532         case ECamIndicatorFaceTracking:
       
   533           {
       
   534           if ( iController.UiConfigManagerPtr()->IsFaceTrackingSupported() )
       
   535               {
       
   536               SetFaceTrackingIndicator();
       
   537               }
       
   538           else 
       
   539               {
       
   540               iIndicators[ECamIndicatorFaceTracking]->ClearIcon();
       
   541               }
       
   542           break;
       
   543           }
       
   544         // -------------------------------------------------
       
   545         case ECamIndicatorCaptureMode:
       
   546           {
       
   547           if( appUi && !appUi->IsSecondCameraEnabled() || 
       
   548               appUi &&  appUi->IsQwerty2ndCamera() )  
       
   549             {
       
   550             if ( ECamControllerVideo == iMode ) 
       
   551                 {
       
   552                 iIndicators[ECamIndicatorCaptureMode]->SetIcon( 2 );
       
   553                 }
       
   554             else
       
   555               iIndicators[ECamIndicatorCaptureMode]->SetIcon( 0 );
       
   556             }
       
   557           else
       
   558             iIndicators[ECamIndicatorCaptureMode]->ClearIcon();
       
   559           break;
       
   560           }
       
   561         // -------------------------------------------------
       
   562         // other indicators
       
   563         default:
       
   564           {
       
   565           iIndicators[i]->ClearIcon();
       
   566           break;
       
   567           }
       
   568         // -------------------------------------------------
       
   569         } // switch
       
   570       }
       
   571     } // for
       
   572   }
       
   573 
       
   574 
       
   575 // ---------------------------------------------------------------------------
       
   576 // GetFlashIconIndex
       
   577 // ---------------------------------------------------------------------------
       
   578 //
       
   579 TInt 
       
   580 CCamSidePane::GetFlashIconIndex( const TCamCameraMode& aMode )
       
   581   {
       
   582   TInt index( KErrNotFound );
       
   583   if( ECamControllerVideo == aMode )
       
   584     {
       
   585     TCamFlashId flashId = 
       
   586       static_cast<TCamFlashId>(
       
   587         iController.IntegerSettingValue( ECamSettingItemDynamicVideoFlash ) );
       
   588     switch ( flashId )
       
   589       {
       
   590       case ECamFlashOff:    index = 0; break;
       
   591       case ECamFlashForced: index = 2; break;
       
   592       default:                         break;
       
   593       }
       
   594     }
       
   595   else
       
   596     {
       
   597     TCamFlashId flashId = 
       
   598       static_cast<TCamFlashId> ( 
       
   599         iController.IntegerSettingValue( ECamSettingItemDynamicPhotoFlash ) );
       
   600 
       
   601     switch ( flashId )
       
   602       {
       
   603       case ECamFlashAuto:       index = 0; break;
       
   604       case ECamFlashOff:        index = 2; break;
       
   605       case ECamFlashAntiRedEye: index = 4; break;
       
   606       case ECamFlashForced:     index = 6; break;
       
   607 
       
   608       default:                             break;
       
   609       }
       
   610     }
       
   611   return index;
       
   612   }
       
   613 
       
   614 
       
   615 // ----------------------------------------------------
       
   616 // CCamSidePane::RegisterObserversL
       
   617 // Register with observed classes
       
   618 // ----------------------------------------------------
       
   619 //
       
   620 void CCamSidePane::RegisterObserversL()
       
   621     {
       
   622     CEikonEnv* eikEnv = CEikonEnv::Static();
       
   623     CCamAppUi* appUi = static_cast<CCamAppUi*>( eikEnv->AppUi() );
       
   624 
       
   625     if ( appUi )
       
   626         {
       
   627 // burst mode icon is displayed in either the navipane or sidepane
       
   628 #ifndef PRODUCT_SUPPORTS_NAVIPANE_SEQUENCE 
       
   629         // Register as burst mode observer
       
   630         appUi->AddBurstModeObserverL( this );
       
   631 #endif // !PRODUCT_SUPPORTS_NAVIPANE_SEQUENCE
       
   632         }
       
   633     // Register as controller observer
       
   634     iController.AddControllerObserverL( this );
       
   635     }
       
   636 
       
   637 // ----------------------------------------------------
       
   638 // CCamSidePane::RemoveObservers
       
   639 // Dergister with observed classes
       
   640 // ----------------------------------------------------
       
   641 //
       
   642 void CCamSidePane::RemoveObservers()
       
   643     {
       
   644     iController.RemoveControllerObserver( this );
       
   645     // if shutting down then self timer will remove the observer
       
   646     if ( !iController.IsInShutdownMode() )
       
   647         {
       
   648         CEikonEnv* eikEnv = CEikonEnv::Static();
       
   649         CCamAppUi* appUi  = static_cast<CCamAppUi*>( eikEnv->AppUi() );
       
   650         if ( appUi )
       
   651             {
       
   652 // burst mode icon is displayed in either the navipane or sidepane
       
   653 #ifndef PRODUCT_SUPPORTS_NAVIPANE_SEQUENCE 
       
   654             // Deregister as burst mode observer
       
   655             appUi->RemoveBurstModeObserver( this );
       
   656 #endif // !PRODUCT_SUPPORTS_NAVIPANE_SEQUENCE
       
   657             }
       
   658         }
       
   659     }
       
   660 
       
   661 #ifdef PRODUCT_USES_GENERIC_SETUP_INDICATOR
       
   662 #ifndef PRODUCT_SUPPORTS_NAVIPANE_GENERIC_SETUP_INDICATOR
       
   663 // ----------------------------------------------------
       
   664 // CCamSidePane::SetDefaultSetupIndicator
       
   665 // Sets the default setup indicator depending on the 
       
   666 // current setup settings.
       
   667 // ----------------------------------------------------
       
   668 //
       
   669 void CCamSidePane::SetGenericSetupIndicator()
       
   670     {
       
   671     if ( iIndicators[ECamIndicatorGenericSetup] )
       
   672         {
       
   673         // If the current mode is video and the video setup settings
       
   674         // are generic to the current video scene then do not show 
       
   675         // the generic setup tampered indicator.
       
   676         if ( ( iMode == ECamControllerVideo ) && 
       
   677              ( iController.VideoSceneDefaultsAreSet() ) )
       
   678             {
       
   679             iIndicators[ECamIndicatorGenericSetup]->ClearIcon();
       
   680             }
       
   681         // Otherwise, if the current mode is photo and the photo setup settings
       
   682         // are generic to the current photo scene then do not show 
       
   683         // the generic setup tampered indicator.
       
   684         else if ( ( iMode != ECamControllerVideo ) &&
       
   685                   ( iController.PhotoSceneDefaultsAreSet() ) )
       
   686             {
       
   687             iIndicators[ECamIndicatorGenericSetup]->ClearIcon();
       
   688             }
       
   689         // Otherwise do not show the indicator.
       
   690         else
       
   691             {
       
   692             iIndicators[ECamIndicatorGenericSetup]->SetIcon( 0 );
       
   693             }
       
   694         }
       
   695     }
       
   696 #endif // !PRODUCT_SUPPORTS_NAVIPANE_GENERIC_SETUP_INDICATOR
       
   697 #endif // PRODUCT_USES_GENERIC_SETUP_INDICATOR
       
   698 
       
   699 
       
   700 // ----------------------------------------------------
       
   701 // CCamSidePane::SetVideoStabilisationIndicator
       
   702 // Sets the image stabilisation indicator for video capture mode
       
   703 // ----------------------------------------------------
       
   704 //
       
   705 void CCamSidePane::SetVideoStabilisationIndicator()
       
   706     {
       
   707     if ( iController.UiConfigManagerPtr()->IsVideoStabilizationSupported() )
       
   708         {
       
   709         if ( iIndicators[ECamIndicatorVideoStabiliser] )
       
   710             {
       
   711             TCamSettingsOnOff stabilisation  = static_cast< TCamSettingsOnOff > 
       
   712                 ( iController.IntegerSettingValue( ECamSettingItemVideoStab ) );
       
   713                 
       
   714             // If the current mode is video
       
   715             if ( stabilisation == ECamSettOn && 
       
   716                     iMode == ECamControllerVideo &&
       
   717                     !IsSecondaryCameraEnabled() )
       
   718                 {
       
   719                 iIndicators[ECamIndicatorVideoStabiliser]->SetIcon( 0 );
       
   720                 } 
       
   721             // Otherwise, draw nothing.
       
   722             else
       
   723                 {
       
   724                 iIndicators[ECamIndicatorVideoStabiliser]->ClearIcon();
       
   725                 }
       
   726             }        
       
   727         }
       
   728     }
       
   729 
       
   730 // ----------------------------------------------------
       
   731 // CCamSidePane::SetFaceTrackingIndicator
       
   732 // Sets the facetracking indicator for video capture mode
       
   733 // ----------------------------------------------------
       
   734 //
       
   735 void CCamSidePane::SetFaceTrackingIndicator()
       
   736     {
       
   737     if ( iController.UiConfigManagerPtr()->IsFaceTrackingSupported() )
       
   738         {
       
   739         if ( iIndicators[ECamIndicatorFaceTracking] )
       
   740             {
       
   741             TCamSettingsOnOff facetracking  = static_cast< TCamSettingsOnOff > 
       
   742                 ( iController.IntegerSettingValue( ECamSettingItemFaceTracking ) );
       
   743                 
       
   744             // If the current mode is still image
       
   745             if ( facetracking == ECamSettOn && iMode == ECamControllerImage && !IsSecondaryCameraEnabled() ) 
       
   746                 {
       
   747                 iIndicators[ECamIndicatorFaceTracking]->SetIcon( 0 );
       
   748                 } 
       
   749             // Otherwise, draw nothing.
       
   750             else
       
   751                 {
       
   752                 iIndicators[ECamIndicatorFaceTracking]->ClearIcon();
       
   753                 }
       
   754             }        
       
   755         }
       
   756     }
       
   757 
       
   758 // ----------------------------------------------------
       
   759 // CCamSidePane::SetVideoSceneIndicator
       
   760 // Set the scene indicator depending on the current video scene setting
       
   761 // ----------------------------------------------------
       
   762 //
       
   763 void CCamSidePane::SetVideoSceneIndicator()
       
   764     {
       
   765     if ( iIndicators[ECamIndicatorScene] )
       
   766         {
       
   767         TCamSceneId scene = static_cast< TCamSceneId > ( 
       
   768             iController.IntegerSettingValue( ECamSettingItemDynamicVideoScene ) );
       
   769         switch ( scene )
       
   770             {
       
   771             case ECamSceneNormal:
       
   772                 {
       
   773                 iIndicators[ECamIndicatorScene]->SetIcon( 0 );
       
   774                 }
       
   775                 break;
       
   776             case ECamSceneNight:
       
   777                 {
       
   778                 iIndicators[ECamIndicatorScene]->SetIcon( 2 );
       
   779                 }
       
   780                 break;
       
   781             case ECamSceneUser:
       
   782                 {
       
   783                 iIndicators[ECamIndicatorScene]->SetIcon( 4 );
       
   784                 }
       
   785                 break;
       
   786             default:
       
   787                 {
       
   788                 iIndicators[ECamIndicatorScene]->ClearIcon();
       
   789                 }
       
   790                 break;
       
   791             }
       
   792         }
       
   793     }
       
   794 
       
   795 // ----------------------------------------------------
       
   796 // CCamSidePane::SetPhotoSceneIndicator
       
   797 // Set the scene indicator depending on the current photo scene setting
       
   798 // ----------------------------------------------------
       
   799 //
       
   800 void CCamSidePane::SetPhotoSceneIndicator()
       
   801     {
       
   802     if ( iIndicators[ECamIndicatorScene] )
       
   803         {
       
   804         TCamSceneId scene = static_cast< TCamSceneId > ( 
       
   805             iController.IntegerSettingValue( ECamSettingItemDynamicPhotoScene ) );
       
   806         switch ( scene )
       
   807             {
       
   808             case ECamSceneAuto:
       
   809                 {
       
   810                 iIndicators[ECamIndicatorScene]->SetIcon( 4 );
       
   811                 }
       
   812                 break;
       
   813             case ECamSceneUser:
       
   814                 {
       
   815                 iIndicators[ECamIndicatorScene]->SetIcon( 6 );
       
   816                 }
       
   817                 break;
       
   818             case ECamSceneMacro:
       
   819                 {
       
   820                 iIndicators[ECamIndicatorScene]->SetIcon( 8 );
       
   821                 }
       
   822                 break;
       
   823             case ECamScenePortrait:
       
   824                 {
       
   825                 iIndicators[ECamIndicatorScene]->SetIcon( 10 );
       
   826                 }
       
   827                 break;
       
   828             case ECamSceneScenery:
       
   829                 {
       
   830                 iIndicators[ECamIndicatorScene]->SetIcon( 12 );
       
   831                 }
       
   832                 break;
       
   833             case ECamSceneNight:
       
   834                 {
       
   835                 iIndicators[ECamIndicatorScene]->SetIcon( 14 );
       
   836                 }
       
   837                 break;
       
   838             case ECamSceneSports:
       
   839                 {
       
   840                 iIndicators[ECamIndicatorScene]->SetIcon( 16 );
       
   841                 }
       
   842                 break;
       
   843             case ECamSceneNightScenery:
       
   844                 {
       
   845                 iIndicators[ECamIndicatorScene]->SetIcon( 22 );
       
   846                 }
       
   847                 break;
       
   848             case ECamSceneNightPortrait:
       
   849                 {
       
   850                 iIndicators[ECamIndicatorScene]->SetIcon( 24 );
       
   851                 }
       
   852                 break;
       
   853             case ECamSceneCandlelight:
       
   854                 {
       
   855                 iIndicators[ECamIndicatorScene]->SetIcon( 26 );
       
   856                 }
       
   857                 break;
       
   858             default:
       
   859                 {
       
   860                 iIndicators[ECamIndicatorScene]->ClearIcon();
       
   861                 }
       
   862                 break;
       
   863             }
       
   864         }
       
   865     }  
       
   866 
       
   867 // ----------------------------------------------------
       
   868 // CCamSidePane::BurstModeActiveL
       
   869 // Notification that the burst mode has been activated/deactivated
       
   870 // ----------------------------------------------------
       
   871 //
       
   872 // Burst mode icon is displayed in either the navipane or sidepane
       
   873 #ifndef PRODUCT_SUPPORTS_NAVIPANE_SEQUENCE 
       
   874 void CCamSidePane::BurstModeActiveL( TBool aActive, TBool /*aStillModeActive*/ )
       
   875     {
       
   876     if ( iIndicators[ECamIndicatorBurstMode] )
       
   877         {
       
   878         // If burst mode has been activated
       
   879         if ( aActive )
       
   880             {
       
   881             iIndicators[ECamIndicatorBurstMode]->SetIcon( 0 );
       
   882             }
       
   883         else // otherwise, burst mode has been deactivated
       
   884             {
       
   885             iIndicators[ECamIndicatorBurstMode]->ClearIcon();
       
   886             }
       
   887         }
       
   888     }
       
   889 #endif // !PRODUCT_SUPPORTS_NAVIPANE_SEQUENCE 
       
   890 
       
   891 // ----------------------------------------------------
       
   892 // CCamSidePane::IsSecondaryCameraEnabled
       
   893 // Checks if the secondary camera is enabled
       
   894 // ----------------------------------------------------
       
   895 //
       
   896 TBool CCamSidePane::IsSecondaryCameraEnabled() const
       
   897     {
       
   898     return static_cast<CCamAppUiBase*>( 
       
   899         CEikonEnv::Static()->AppUi() )->IsSecondCameraEnabled();
       
   900     }
       
   901 
       
   902 // ----------------------------------------------------
       
   903 // CCamSidePane::UpdateLayout
       
   904 // ----------------------------------------------------
       
   905 //
       
   906 void CCamSidePane::UpdateLayout()
       
   907     {
       
   908     if ( CamUtility::IsNhdDevice() )
       
   909         {
       
   910         TouchLayout();
       
   911         }
       
   912     else
       
   913         {
       
   914         NonTouchLayout();
       
   915         }
       
   916     }
       
   917 
       
   918 // ----------------------------------------------------
       
   919 // CCamSidePane::NonTouchLayout
       
   920 // ----------------------------------------------------
       
   921 void CCamSidePane::NonTouchLayout() const
       
   922     {
       
   923     TRect rect;
       
   924     AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EScreen, rect );
       
   925     TInt cba =  AknLayoutUtils::CbaLocation() == 
       
   926                 AknLayoutUtils::EAknCbaLocationLeft;
       
   927     TAknLayoutRect parent;
       
   928     parent.LayoutRect( rect, AknLayoutScalable_Apps::cam6_mode_pane( cba ) );  
       
   929 
       
   930     // update coords for each indicator
       
   931     for ( TInt i = 0; i < iIndicators.Count(); i++ )
       
   932         {
       
   933         TAknLayoutRect l;
       
   934         if ( iIndicators[i] )
       
   935             {
       
   936             switch ( i )
       
   937                 {
       
   938                 case ECamIndicatorCaptureMode:
       
   939                     {
       
   940                     l.LayoutRect( parent.Rect(),
       
   941                         AknLayoutScalable_Apps::cam6_mode_pane_g1( cba ) );
       
   942                     iIndicators[i]->SetRect( l.Rect() );
       
   943                     break;
       
   944                     }
       
   945                 case ECamIndicatorBurstMode:
       
   946                     {
       
   947                     l.LayoutRect( parent.Rect(),
       
   948                         AknLayoutScalable_Apps::cam6_mode_pane_g2( cba ) );
       
   949                     iIndicators[i]->SetRect( l.Rect() );
       
   950                     break;
       
   951                     }    
       
   952                 case ECamIndicatorImageShakeWarning:
       
   953                     {
       
   954                     l.LayoutRect( parent.Rect(),
       
   955                         AknLayoutScalable_Apps::cam6_mode_pane_g3( cba ) );
       
   956                     iIndicators[i]->SetRect( l.Rect() );
       
   957                     break;
       
   958                     }
       
   959                 case ECamIndicatorVideoStabiliser: 
       
   960                     {
       
   961                     l.LayoutRect( parent.Rect(),
       
   962                         AknLayoutScalable_Apps::cam6_mode_pane_g3( cba ) );
       
   963                     iIndicators[i]->SetRect( l.Rect() );
       
   964                     break;
       
   965                     }
       
   966                 case ECamIndicatorFaceTracking: 
       
   967                     {
       
   968                     l.LayoutRect( parent.Rect(),
       
   969                         AknLayoutScalable_Apps::cam6_mode_pane_g4( cba ) );
       
   970                     iIndicators[i]->SetRect( l.Rect() );
       
   971                     break;
       
   972                     }
       
   973                 default:
       
   974                     {
       
   975                     break;
       
   976                     }
       
   977                 }
       
   978             }
       
   979         }
       
   980     }
       
   981 
       
   982 // ---------------------------------------------------------------------------
       
   983 // CCamSidePane::TouchLayout
       
   984 // ---------------------------------------------------------------------------
       
   985 void CCamSidePane::TouchLayout() const
       
   986     {  
       
   987     TSize screenSize;
       
   988     AknLayoutUtils::LayoutMetricsSize( AknLayoutUtils::EScreen, screenSize );
       
   989     TRect rect( TPoint(), screenSize );
       
   990     TInt variant = Layout_Meta_Data::IsLandscapeOrientation();
       
   991 
       
   992     // update coords for each indicator
       
   993     for ( TInt i = 0; i < iIndicators.Count(); i++ )
       
   994         {
       
   995         TAknLayoutRect l;
       
   996         if ( iIndicators[i] )
       
   997             {
       
   998             switch ( i )
       
   999                 {
       
  1000                 case ECamIndicatorCaptureMode:
       
  1001                     {
       
  1002                     l.LayoutRect( rect,
       
  1003                            AknLayoutScalable_Apps::main_camera4_pane_g1( variant ) );
       
  1004                     iIndicators[i]->SetRect( l.Rect() );
       
  1005                     break;
       
  1006                     }
       
  1007                 case ECamIndicatorBurstMode:
       
  1008                     {
       
  1009                     l.LayoutRect( rect,
       
  1010                         AknLayoutScalable_Apps::main_camera4_pane_g2( variant ) );
       
  1011                     iIndicators[i]->SetRect( l.Rect() );
       
  1012                     break;
       
  1013                     }                    
       
  1014                 case ECamIndicatorImageShakeWarning:
       
  1015                     {
       
  1016                     l.LayoutRect( rect,
       
  1017                         AknLayoutScalable_Apps::main_camera4_pane_g3( variant ) );
       
  1018                     iIndicators[i]->SetRect( l.Rect() );
       
  1019                     break;
       
  1020                     }
       
  1021                 case ECamIndicatorVideoStabiliser: 
       
  1022                     {
       
  1023                     l.LayoutRect( rect,
       
  1024                         AknLayoutScalable_Apps::main_video4_pane_g5( variant ) );
       
  1025                     iIndicators[i]->SetRect( l.Rect() );
       
  1026                     break;
       
  1027                     }
       
  1028 			    case ECamIndicatorFaceTracking: 
       
  1029                     {
       
  1030                      l.LayoutRect( rect,
       
  1031                         AknLayoutScalable_Apps::main_camera4_pane_g6( variant ) );
       
  1032                      iIndicators[i]->SetRect( l.Rect() );
       
  1033                      break;  
       
  1034                     }
       
  1035                 default:
       
  1036                     {
       
  1037                     break;
       
  1038                     }
       
  1039                 }
       
  1040             }
       
  1041         }
       
  1042     }
       
  1043    
       
  1044 // End of File