skins/AknSkins/alsrc/AknsEffectAnim.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2005-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:  Effect animation.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include <AknsEffectAnim.h>
       
    21 #include <AknsUtils.h>
       
    22 #include "AknsAlAnimatorBmp.h"
       
    23 
       
    24 #include <bitstd.h>
       
    25 #include <coemain.h>
       
    26 #include <eikenv.h>
       
    27 
       
    28 // CONSTANTS
       
    29 
       
    30 // Alpha blended draw is not currently supported. Enable alpha blended draw by
       
    31 // uncommenting the definition below
       
    32 //#define AKNS_EFFECT_ANIM_USE_ALPHA
       
    33 
       
    34 // ============================ MEMBER FUNCTIONS ===============================
       
    35 
       
    36 // -----------------------------------------------------------------------------
       
    37 // CAknsEffectAnim::NewL
       
    38 // -----------------------------------------------------------------------------
       
    39 //
       
    40 EXPORT_C CAknsEffectAnim* CAknsEffectAnim::NewL(
       
    41     MAknsEffectAnimObserver* aObserver )
       
    42     {
       
    43     if( !AknsUtils::AvkonHighlightAnimationEnabled() )
       
    44         User::Leave( KErrNotSupported );
       
    45 
       
    46     if( !AknsUtils::AvkonSkinEnabled() )
       
    47         User::Leave( KErrNotSupported );
       
    48 
       
    49     if( !aObserver )
       
    50         User::Leave( KErrArgument );
       
    51 
       
    52     CAknsEffectAnim* self = new(ELeave) CAknsEffectAnim();
       
    53     CleanupStack::PushL( self );
       
    54     self->ConstructL( aObserver );
       
    55     CleanupStack::Pop( self );
       
    56     return self;
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CAknsEffectAnim::~CAknsEffectAnim
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 EXPORT_C CAknsEffectAnim::~CAknsEffectAnim()
       
    64     {
       
    65     delete iAnim; //lint !e1551 No exception thrown
       
    66     }
       
    67 
       
    68 // -----------------------------------------------------------------------------
       
    69 // CAknsEffectAnim::ConstructFromSkinL
       
    70 // -----------------------------------------------------------------------------
       
    71 //
       
    72 EXPORT_C TBool CAknsEffectAnim::ConstructFromSkinL( const TAknsItemID& aItemID )
       
    73     {
       
    74     return iAnim->ConstructFromSkinL( aItemID );
       
    75     }
       
    76 
       
    77 // -----------------------------------------------------------------------------
       
    78 // CAknsEffectAnim::CAknsEffectAnim
       
    79 // -----------------------------------------------------------------------------
       
    80 //
       
    81 CAknsEffectAnim::CAknsEffectAnim()
       
    82     {
       
    83     // Derived from CBase -> members zeroed
       
    84     }
       
    85 
       
    86 // -----------------------------------------------------------------------------
       
    87 // CAknsEffectAnim::ConstructL
       
    88 // -----------------------------------------------------------------------------
       
    89 //
       
    90 void CAknsEffectAnim::ConstructL( MAknsEffectAnimObserver* aObserver )
       
    91     {
       
    92     iAnim = CAknsAlAnimatorBmp::NewL( aObserver );
       
    93     }
       
    94 
       
    95 // -----------------------------------------------------------------------------
       
    96 // CAknsEffectAnim::Start
       
    97 // -----------------------------------------------------------------------------
       
    98 //
       
    99 EXPORT_C TInt CAknsEffectAnim::Start()
       
   100     {
       
   101     return iAnim->StartAnimation();
       
   102     }
       
   103 
       
   104 // -----------------------------------------------------------------------------
       
   105 // CAknsEffectAnim::Stop
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 EXPORT_C TInt CAknsEffectAnim::Stop()
       
   109     {
       
   110     return iAnim->StopAnimation();
       
   111     }
       
   112 
       
   113 // -----------------------------------------------------------------------------
       
   114 // CAknsEffectAnim::Pause
       
   115 // -----------------------------------------------------------------------------
       
   116 //
       
   117 EXPORT_C TInt CAknsEffectAnim::Pause()
       
   118     {
       
   119     return iAnim->PauseAnimation();
       
   120     }
       
   121 
       
   122 // -----------------------------------------------------------------------------
       
   123 // CAknsEffectAnim::Continue
       
   124 // -----------------------------------------------------------------------------
       
   125 //
       
   126 EXPORT_C TInt CAknsEffectAnim::Continue()
       
   127     {
       
   128     return iAnim->ContinueAnimation();
       
   129     }
       
   130 
       
   131 // -----------------------------------------------------------------------------
       
   132 // CAknsEffectAnim::State
       
   133 // -----------------------------------------------------------------------------
       
   134 //
       
   135 EXPORT_C TInt CAknsEffectAnim::State()
       
   136     {
       
   137     return iAnim->State();
       
   138     }//lint !e1762 changing to const will change export name mangling
       
   139 
       
   140 // -----------------------------------------------------------------------------
       
   141 // CAknsEffectAnim::MinimumSize
       
   142 // -----------------------------------------------------------------------------
       
   143 //
       
   144 EXPORT_C TSize CAknsEffectAnim::MinimumSize() const
       
   145     {
       
   146     return TSize( KAknsAlAnimMinimumWidth, KAknsAlAnimMinimumHeight );
       
   147     }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // CAknsEffectAnim::Size
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 EXPORT_C TSize CAknsEffectAnim::Size() const
       
   154     {
       
   155     return iAnim->LayerSize();
       
   156     }
       
   157 
       
   158 // -----------------------------------------------------------------------------
       
   159 // CAknsEffectAnim::NeedsInputLayer
       
   160 // -----------------------------------------------------------------------------
       
   161 //
       
   162 EXPORT_C TBool CAknsEffectAnim::NeedsInputLayer() const
       
   163     {
       
   164     return iAnim->NeedsInputLayer();
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CAknsEffectAnim::Render
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 EXPORT_C TBool CAknsEffectAnim::Render(
       
   172     CFbsBitGc& aGc, const TRect& aGcRect ) const
       
   173     {
       
   174     return Render( *((CBitmapContext*)&aGc), aGcRect );
       
   175     }
       
   176 
       
   177 // -----------------------------------------------------------------------------
       
   178 // CAknsEffectAnim::Render
       
   179 // -----------------------------------------------------------------------------
       
   180 //
       
   181 EXPORT_C TBool CAknsEffectAnim::Render(
       
   182     CWindowGc& aGc, const TRect& aGcRect ) const
       
   183     {
       
   184     return Render( *((CBitmapContext*)&aGc), aGcRect );
       
   185     }
       
   186 
       
   187 // -----------------------------------------------------------------------------
       
   188 // CAknsEffectAnim::Render
       
   189 // -----------------------------------------------------------------------------
       
   190 //
       
   191 EXPORT_C TBool CAknsEffectAnim::Render(
       
   192     CBitmapContext& aGc, const TRect& aGcRect ) const
       
   193     {
       
   194     if( !iAnim->OutputRgb() )
       
   195         {
       
   196         return EFalse;
       
   197         }
       
   198 
       
   199 #ifdef AKNS_EFFECT_ANIM_USE_ALPHA
       
   200     if( iAnim->OutputAlpha() )
       
   201         {
       
   202         aGc.BitBltMasked( aGcRect.iTl, iAnim->OutputRgb(),
       
   203                           TRect( TPoint(0, 0), aGcRect.Size() ),
       
   204                           iAnim->OutputAlpha(), EFalse );
       
   205         }
       
   206     else
       
   207 #endif // AKNS_EFFECT_ANIM_USE_ALPHA
       
   208         {
       
   209         aGc.BitBlt( aGcRect.iTl, iAnim->OutputRgb(),
       
   210                     TRect( TPoint(0, 0), aGcRect.Size() ) );
       
   211         }
       
   212 
       
   213     return ETrue;
       
   214     }
       
   215 
       
   216 // -----------------------------------------------------------------------------
       
   217 // CAknsEffectAnim::OutputRgb
       
   218 // -----------------------------------------------------------------------------
       
   219 //
       
   220 EXPORT_C const CFbsBitmap* CAknsEffectAnim::OutputRgb() const
       
   221     {
       
   222     return iAnim->OutputRgb();
       
   223     }
       
   224 
       
   225 // -----------------------------------------------------------------------------
       
   226 // CAknsEffectAnim::OutputAlpha
       
   227 // -----------------------------------------------------------------------------
       
   228 //
       
   229 EXPORT_C const CFbsBitmap* CAknsEffectAnim::OutputAlpha() const
       
   230     {
       
   231     return iAnim->OutputAlpha();
       
   232     }
       
   233 
       
   234 // -----------------------------------------------------------------------------
       
   235 // CAknsEffectAnim::BeginConfigInputLayersL
       
   236 // -----------------------------------------------------------------------------
       
   237 //
       
   238 EXPORT_C void CAknsEffectAnim::BeginConfigInputLayersL(
       
   239     const TSize& aNewSize, TBool aAboutToStart )
       
   240     {
       
   241     iAboutToStart = aAboutToStart;
       
   242 
       
   243     // Make sure we have a valid size
       
   244     if( aNewSize.iWidth < KAknsAlAnimMinimumWidth ||
       
   245         aNewSize.iHeight < KAknsAlAnimMinimumHeight )
       
   246         {
       
   247         User::Leave( KErrArgument );
       
   248         }
       
   249 
       
   250     // Determine display mode
       
   251     TDisplayMode mode = CCoeEnv::Static()->SystemGc().Device()->DisplayMode();
       
   252     // Only two RGB display modes are supported by animation plugins
       
   253     if( EColor16M == mode || EColor16MU == mode )
       
   254         mode = EColor16MU;
       
   255     else // In all other cases use 16-bit colors (565-format assumed)
       
   256         mode = EColor64K;
       
   257 
       
   258     iAnim->BeginConfigLayersL( aNewSize, mode );
       
   259     }
       
   260 
       
   261 // -----------------------------------------------------------------------------
       
   262 // CAknsEffectAnim::InputRgbGc
       
   263 // -----------------------------------------------------------------------------
       
   264 //
       
   265 EXPORT_C CFbsBitGc* CAknsEffectAnim::InputRgbGc() const
       
   266     {
       
   267     return iAnim->InputRgbGc();
       
   268     }
       
   269 
       
   270 // -----------------------------------------------------------------------------
       
   271 // CAknsEffectAnim::InputAlphaGc
       
   272 // -----------------------------------------------------------------------------
       
   273 //
       
   274 EXPORT_C CFbsBitGc* CAknsEffectAnim::InputAlphaGc() const
       
   275     {
       
   276     return iAnim->InputAlphaGc();
       
   277     }
       
   278 
       
   279 // -----------------------------------------------------------------------------
       
   280 // CAknsEffectAnim::EndConfigInputLayersL
       
   281 // -----------------------------------------------------------------------------
       
   282 //
       
   283 EXPORT_C void CAknsEffectAnim::EndConfigInputLayersL()
       
   284     {
       
   285     iAnim->EndConfigLayersL( (iAboutToStart!= 0 ? ETrue: EFalse) );
       
   286     }
       
   287 
       
   288 // -----------------------------------------------------------------------------
       
   289 // CAknsEffectAnim::UpdateOutput
       
   290 // -----------------------------------------------------------------------------
       
   291 //
       
   292 EXPORT_C TInt CAknsEffectAnim::UpdateOutput()
       
   293     {
       
   294     return iAnim->UpdateOutput();
       
   295     }
       
   296 
       
   297 // -----------------------------------------------------------------------------
       
   298 // CAknsEffectAnim::SetIdling
       
   299 // -----------------------------------------------------------------------------
       
   300 //
       
   301 EXPORT_C void CAknsEffectAnim::SetIdling( TInt aIntervalMs )
       
   302     {
       
   303     iAnim->SetIdling( aIntervalMs );
       
   304     }
       
   305 
       
   306 // -----------------------------------------------------------------------------
       
   307 // CAknsEffectAnim::IsIdling
       
   308 // -----------------------------------------------------------------------------
       
   309 //
       
   310 EXPORT_C TBool CAknsEffectAnim::IsIdling() const
       
   311     {
       
   312     return iAnim->IsIdling();
       
   313     }
       
   314 
       
   315 // End of file