camerauis/activepalette/Src/ActivePalette2SemiTransparentFadingStyler.cpp
changeset 0 1ddebce53859
equal deleted inserted replaced
-1:000000000000 0:1ddebce53859
       
     1 /*
       
     2 * Copyright (c) 2007 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:  
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #include <gdi.h>
       
    22 #include <fbs.h>
       
    23 
       
    24 #include <activepalette2graphics.mbg>
       
    25 
       
    26 #include "ActivePalette2Logger.h"
       
    27 #include "ActivePalette2Cfg.h"
       
    28 #include "ActivePalette2Utils.h"
       
    29 #include "ActivePalette2SemiTransparentFadingStyler.h"
       
    30 
       
    31 
       
    32 static const TInt KAlphaMask = 0xFF;
       
    33 
       
    34 // -----------------------------------------------------------------------------
       
    35 // 2-phase constructor <<static>>
       
    36 // -----------------------------------------------------------------------------
       
    37 //
       
    38 CActivePalette2SemiTransparentFadingStyler* 
       
    39 CActivePalette2SemiTransparentFadingStyler::NewL()
       
    40   {
       
    41   CActivePalette2SemiTransparentFadingStyler* self = 
       
    42       new (ELeave) CActivePalette2SemiTransparentFadingStyler();
       
    43 
       
    44   CleanupStack::PushL(self);
       
    45   self->ConstructL();
       
    46   CleanupStack::Pop( self );
       
    47 
       
    48   return self;
       
    49   }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // Destructor <<virtual>>
       
    53 // -----------------------------------------------------------------------------
       
    54 //
       
    55 CActivePalette2SemiTransparentFadingStyler
       
    56 ::~CActivePalette2SemiTransparentFadingStyler()
       
    57   {
       
    58   ReleaseTooltipBuf();
       
    59   }
       
    60 
       
    61 
       
    62 // -----------------------------------------------------------------------------
       
    63 // BlitTooltip <<virtual>>
       
    64 // -----------------------------------------------------------------------------
       
    65 //
       
    66 void 
       
    67 CActivePalette2SemiTransparentFadingStyler
       
    68 ::BlitTooltip( CBitmapContext* aGc, 
       
    69                const TPoint&   aPos, 
       
    70                TInt            aCurrentPhase, 
       
    71                TInt            aTotalPhases )
       
    72   {
       
    73   TInt alpha_orig  = ( KAlphaMask * aCurrentPhase ) / aTotalPhases;
       
    74   TInt alpha_value = alpha_orig & KAlphaMask; // Limit to 0..255
       
    75   TRgb alpha       = TRgb::Gray256( alpha_value );
       
    76 
       
    77   LOGTEXT1( _L("CActivePalette2SemiTransparentFadingStyler::BlitTooltip, alpha=%d"), alpha_value );
       
    78 
       
    79   iTooltipAlphaContext->SetBrushColor( alpha );
       
    80   iTooltipAlphaContext->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
    81   iTooltipAlphaContext->Clear();
       
    82 
       
    83   iTooltipBlendedMaskContext->SetBrushColor( KRgbBlack );
       
    84   iTooltipBlendedMaskContext->SetBrushStyle( CGraphicsContext::ESolidBrush );
       
    85   iTooltipBlendedMaskContext->Clear();
       
    86   iTooltipBlendedMaskContext->BitBltMasked( TPoint( 0,0 ), 
       
    87                                             iTooltipAlphaBitmap, 
       
    88                                             TooltipSize(),
       
    89                                             iTooltipBufMaskBitmap, 
       
    90                                             EFalse );
       
    91 
       
    92   aGc->BitBltMasked( aPos, 
       
    93                      iTooltipBufBitmap, 
       
    94                      TooltipSize(),
       
    95                      iTooltipBlendedMaskBitmap, 
       
    96                      EFalse );
       
    97   }
       
    98 
       
    99 
       
   100 
       
   101     
       
   102 // -----------------------------------------------------------------------------
       
   103 // TooltipNoseMaskId <<virtual>>
       
   104 // -----------------------------------------------------------------------------
       
   105 //
       
   106 TInt 
       
   107 CActivePalette2SemiTransparentFadingStyler::TooltipNoseMaskId()
       
   108   {
       
   109   return EMbmActivepalette2graphicsQgn_graf_cam4_tb_tooltip_end_mask;
       
   110   }
       
   111     
       
   112 // -----------------------------------------------------------------------------
       
   113 // TooltipBodyMaskId <<virtual>>
       
   114 // -----------------------------------------------------------------------------
       
   115 //
       
   116 TInt 
       
   117 CActivePalette2SemiTransparentFadingStyler::TooltipBodyMaskId()
       
   118   {
       
   119   return EMbmActivepalette2graphicsQgn_graf_cam4_tb_tooltip_body_mask;
       
   120   }
       
   121 
       
   122 
       
   123 // -----------------------------------------------------------------------------
       
   124 // AllocateTooltipBufL <<virtual>>
       
   125 // -----------------------------------------------------------------------------
       
   126 //
       
   127 void 
       
   128 CActivePalette2SemiTransparentFadingStyler::AllocateTooltipBufL()
       
   129   {
       
   130   ReleaseTooltipBuf();
       
   131 
       
   132   ActivePalette2Utils::CreateDrawingObjectsL( TooltipSize(),
       
   133                                               &iTooltipBufBitmap,
       
   134                                               &iTooltipBufDevice,
       
   135                                               &iTooltipBufContext );
       
   136 
       
   137   ActivePalette2Utils::CreateDrawingObjectsL( EGray2,
       
   138                                               TooltipSize(),
       
   139                                               &iTooltipBufMaskBitmap,
       
   140                                               &iTooltipBufMaskDevice,
       
   141                                               &iTooltipBufMaskContext );
       
   142 
       
   143   ActivePalette2Utils::CreateDrawingObjectsL( EGray256, 
       
   144                                               TooltipSize(),
       
   145                                               &iTooltipAlphaBitmap,
       
   146                                               &iTooltipAlphaDevice,
       
   147                                               &iTooltipAlphaContext );
       
   148 
       
   149   ActivePalette2Utils::CreateDrawingObjectsL( EGray256, 
       
   150                                               TooltipSize(),
       
   151                                               &iTooltipBlendedMaskBitmap,
       
   152                                               &iTooltipBlendedMaskDevice,
       
   153                                               &iTooltipBlendedMaskContext );
       
   154   }
       
   155 
       
   156 // -----------------------------------------------------------------------------
       
   157 // ReleaseTooltipBuf <<virtual>>
       
   158 // -----------------------------------------------------------------------------
       
   159 //
       
   160 void 
       
   161 CActivePalette2SemiTransparentFadingStyler::ReleaseTooltipBuf()
       
   162   {
       
   163   ActivePalette2Utils::DeleteDrawingObjects( &iTooltipBufBitmap,
       
   164                                              &iTooltipBufDevice,
       
   165                                              &iTooltipBufContext );
       
   166 
       
   167   ActivePalette2Utils::DeleteDrawingObjects( &iTooltipBufMaskBitmap,
       
   168                                              &iTooltipBufMaskDevice,
       
   169                                              &iTooltipBufMaskContext );
       
   170 
       
   171   ActivePalette2Utils::DeleteDrawingObjects( &iTooltipAlphaBitmap,
       
   172                                              &iTooltipAlphaDevice,
       
   173                                              &iTooltipAlphaContext );
       
   174 
       
   175   ActivePalette2Utils::DeleteDrawingObjects( &iTooltipBlendedMaskBitmap,
       
   176                                              &iTooltipBlendedMaskDevice,
       
   177                                              &iTooltipBlendedMaskContext );
       
   178   }
       
   179