photosgallery/slideshow/view/src/shwslideshowblackoutcontrol.cpp
changeset 0 4e91876724a2
equal deleted inserted replaced
-1:000000000000 0:4e91876724a2
       
     1 /*
       
     2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). 
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:    Control to create a black background for the slideshow
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #include "shwslideshowblackoutcontrol.h"
       
    21 
       
    22 #include <uiacceltk/huienv.h> 
       
    23 #include <uiacceltk/huidisplay.h>
       
    24 #include <uiacceltk/huiImageVisual.h>
       
    25 #include <uiacceltk/huiAnchorLayout.h>
       
    26 
       
    27 #include "glxhuiutility.h"
       
    28 
       
    29 namespace
       
    30 	{
       
    31 	/**
       
    32 	 * Time to complete blackout
       
    33 	 */
       
    34 	const TInt KShwBlackoutDelay = 0;
       
    35 	/**
       
    36 	 * Opacity value - fully opaque
       
    37 	 */
       
    38 	const TInt KShwOpaque = 1;
       
    39 	/**
       
    40 	 * Opacity value - transparent
       
    41 	 */
       
    42 	const TInt KShwTransparent = 0;
       
    43 	const TInt KShwScreenSizeMultiplier = 3;
       
    44 	const TInt KShwOrigin = 0;
       
    45 	}
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // Constructor
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CShwBlackoutControl* CShwBlackoutControl::NewL( CHuiEnv& aEnv,
       
    52 	CHuiDisplay& aDisplay )
       
    53     {
       
    54     CShwBlackoutControl* self = new( ELeave )
       
    55         CShwBlackoutControl( aEnv, aDisplay );
       
    56     CleanupStack::PushL( self );
       
    57     self->ConstructL();
       
    58     CleanupStack::Pop( self );
       
    59     return self;
       
    60     }
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // Constructor
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 CShwBlackoutControl::CShwBlackoutControl( CHuiEnv& aEnv, CHuiDisplay& aDisplay )
       
    67         : CHuiControl( aEnv ), iDisplay( aDisplay )
       
    68     {    
       
    69     BindDisplay( aDisplay );
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // ConstructL
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void CShwBlackoutControl::ConstructL()
       
    77     {
       
    78     // Create the black background to fade out the rest of the screen
       
    79 	iBlackoutTexture = CHuiTexture::NewL();
       
    80 	CGlxHuiUtility::UploadFlatColourToTextureL( KRgbBlack, iBlackoutTexture );
       
    81 
       
    82 	iBlackoutLayout = CHuiAnchorLayout::AddNewL( *this );
       
    83 	iBlackoutLayout->SetClipping( EFalse );
       
    84 
       
    85 	iBlackoutImageVisual = CHuiImageVisual::AddNewL( *this, iBlackoutLayout );
       
    86 	iBlackoutImageVisual->SetImage( THuiImage( *iBlackoutTexture ) );
       
    87 	iBlackoutImageVisual->iOpacity.Set( KShwTransparent );
       
    88 
       
    89 	iBlackoutImageVisual->SetFlag( EHuiVisualFlagManualLayout );
       
    90 	TSize displaySize = iDisplay.Size();
       
    91 	iBlackoutImageVisual->SetSize( THuiRealSize(
       
    92 	    displaySize.iWidth * KShwScreenSizeMultiplier,
       
    93 		displaySize.iHeight * KShwScreenSizeMultiplier ));
       
    94 
       
    95 	iBlackoutImageVisual->SetPos( THuiRealPoint( KShwOrigin, KShwOrigin) );
       
    96     }
       
    97 
       
    98 // -----------------------------------------------------------------------------
       
    99 // Destructor
       
   100 // -----------------------------------------------------------------------------
       
   101 //
       
   102 CShwBlackoutControl::~CShwBlackoutControl()
       
   103     {   
       
   104     delete iBlackoutTexture;
       
   105     }
       
   106 	
       
   107 // -----------------------------------------------------------------------------
       
   108 // ActivateL
       
   109 // -----------------------------------------------------------------------------
       
   110 //
       
   111 void CShwBlackoutControl::ActivateL()
       
   112     {
       
   113     if ( !iActivated )
       
   114         {        
       
   115         iBlackoutImageVisual->iOpacity.Set( KShwOpaque, KShwBlackoutDelay );
       
   116         iActivated = ETrue;
       
   117         }
       
   118     }
       
   119     
       
   120 // -----------------------------------------------------------------------------
       
   121 // Deactivate
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CShwBlackoutControl::Deactivate()
       
   125     {
       
   126     if ( iActivated )
       
   127         {
       
   128         iBlackoutImageVisual->iOpacity.Set( KShwTransparent,
       
   129             KShwBlackoutDelay );
       
   130         iActivated = EFalse;
       
   131         }
       
   132     }