widgetmodel/alfwidgetmodel/src/alfanimationoutput.cpp
changeset 17 3eca7e70b1b8
parent 3 4526337fb576
equal deleted inserted replaced
3:4526337fb576 17:3eca7e70b1b8
     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:  Animation class for alfred widget model.
       
    15 				  This class creates the animation and commands.
       
    16 *
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 
       
    22 
       
    23 //INCLUDES
       
    24 #include "alf/alfreferencetovisual.h"
       
    25 #include "alf/ialfattributesetter.h"
       
    26 #include "alf/alfattributecontainer.h"
       
    27 #include <alf/alfvisual.h>
       
    28 #include <alf/alfcontrol.h>
       
    29 #include <alf/alfenv.h>
       
    30 #include <alf/alfexceptions.h>
       
    31 //#include "alf/alfperf.h"
       
    32 #include "alfanimationoutput.h"
       
    33 
       
    34 namespace Alf
       
    35     {
       
    36 
       
    37 ////////////////////// AlfAnimationOutput //////////////////////
       
    38 
       
    39 
       
    40 // ============================ MEMBER FUNCTIONS ===============================
       
    41 
       
    42 // -----------------------------------------------------------------------------
       
    43 // Description : Constructor
       
    44 // -----------------------------------------------------------------------------
       
    45 //
       
    46 OSN_EXPORT AlfAnimationOutput::AlfAnimationOutput(
       
    47     AlfReferenceToVisual* aTargetVisual,
       
    48     AlfReferenceToVisual* aReferenceVisual,
       
    49     IAlfAttributeSetter* aAttributeSetter,
       
    50     AlfAttributeContainer* aAttributeContainer,
       
    51     unsigned int aAnimationTime,
       
    52     unsigned int aDelay)
       
    53     {
       
    54     if (!aTargetVisual || !aAttributeSetter || !aAttributeContainer )
       
    55         {
       
    56         ALF_THROW( AlfException, EInvalidArgument, "AlfAnimationOutput" )
       
    57         }
       
    58         
       
    59     mTargetVisual = aTargetVisual;
       
    60     mReferenceVisual = aReferenceVisual;
       
    61     mAttributeSetter = aAttributeSetter;
       
    62     mAttributeContainer = aAttributeContainer;
       
    63     mAnimationTime = aAnimationTime;
       
    64     mDelay = aDelay;
       
    65     }
       
    66 
       
    67 // -----------------------------------------------------------------------------
       
    68 // Description : Destructor
       
    69 // -----------------------------------------------------------------------------
       
    70 //
       
    71 OSN_EXPORT AlfAnimationOutput::~AlfAnimationOutput()
       
    72     {
       
    73     delete mTargetVisual;
       
    74     delete mReferenceVisual;
       
    75     delete mAttributeSetter;
       
    76     delete mAttributeContainer;
       
    77     }
       
    78 
       
    79 // -----------------------------------------------------------------------------
       
    80 // Description : Create and send the animation command
       
    81 // -----------------------------------------------------------------------------
       
    82 //
       
    83 OSN_EXPORT void AlfAnimationOutput::sendCommand(
       
    84     CAlfWidgetControl& aControl, unsigned int aDataID )
       
    85     {
       
    86     CAlfVisual* ref = 0;
       
    87 
       
    88     if ( mReferenceVisual )
       
    89         {
       
    90         // Find the reference visual
       
    91         ref = mReferenceVisual->resolve( aControl, aDataID );
       
    92         }
       
    93     // Find the animated visual
       
    94     CAlfVisual* visual = NULL;
       
    95     visual = mTargetVisual->resolve( aControl, aDataID );
       
    96     if ( visual )
       
    97         {
       
    98         // Create the animation command(s) and send them through the env.
       
    99         //ALF_PERF_START( perfdata, "AlfAnimationOutput-sendCommand-createAndSendCommands" )
       
   100         // reference visual is optional, it may be 0.
       
   101         mAttributeSetter->createAndSendCommands( *visual, mAttributeContainer, ref );
       
   102         //ALF_PERF_STOP( perfdata, "AlfAnimationOutput-sendCommand-createAndSendCommands" )
       
   103         }
       
   104     }
       
   105 
       
   106     } // namespace Alf
       
   107 
       
   108 // end of file