uiacceltk/hitchcock/Client/src/alftimedvalue.cpp
changeset 0 15bf7259bb7c
child 15 cd0ae4656946
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 2006-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:   Timed value class
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #include "alf/alftimedvalue.h"
       
    20 #include "alf/alfutil.h"
       
    21 
       
    22 EXPORT_C TAlfTimedValue::TAlfTimedValue()
       
    23     :iValueNow(0),
       
    24     iValueTarget(0),
       
    25     iTimeToTarget(0),
       
    26     iInterpolationStyle(0),
       
    27     iMappingFunctionIdentifier(0),
       
    28     iSpeed(0),
       
    29     iFlags(EAlfValueFlagsNone)
       
    30     {
       
    31     }
       
    32 
       
    33 EXPORT_C TAlfTimedValue::TAlfTimedValue(TReal32 aInitialValue) __SOFTFP
       
    34     :iValueNow(aInitialValue),
       
    35     iValueTarget(0),
       
    36     iTimeToTarget(0),
       
    37     iInterpolationStyle(0),
       
    38     iMappingFunctionIdentifier(0),
       
    39     iSpeed(0),
       
    40     iFlags(EAlfValueNowChanged)
       
    41     {
       
    42     }
       
    43 
       
    44 EXPORT_C TAlfTimedValue::TAlfTimedValue(TReal32 aTargetValue, TInt aTime) __SOFTFP
       
    45     :iValueNow(0),
       
    46     iValueTarget(aTargetValue),
       
    47     iTimeToTarget(aTime),
       
    48     iInterpolationStyle(0),
       
    49     iMappingFunctionIdentifier(0),
       
    50     iSpeed(0),
       
    51     iFlags(EAlfValueTargetChanged)
       
    52     {        
       
    53     }
       
    54     
       
    55     
       
    56 EXPORT_C void TAlfTimedValue::SetValueNow(const TReal32& aValueNow)
       
    57     {
       
    58     iFlags |= EAlfValueNowChanged;    
       
    59     iValueNow = aValueNow;
       
    60     }
       
    61     
       
    62 EXPORT_C void TAlfTimedValue::SetTarget(const TReal32& aTarget, TInt aTime)
       
    63     {
       
    64     iFlags |= EAlfValueTargetChanged;    
       
    65     iValueTarget = aTarget;
       
    66     iTimeToTarget = aTime;
       
    67     }
       
    68 
       
    69 EXPORT_C void TAlfTimedValue::SetTargetWithSpeed(TReal32 aValue, TReal32 aUnitsPerSecond) __SOFTFP
       
    70     {
       
    71     iFlags |= EAlfValueTargetChanged;    
       
    72     iFlags |= EAlfSpeedChanged;    
       
    73     iValueTarget = aValue;
       
    74     iSpeed = aUnitsPerSecond;    
       
    75     }
       
    76 
       
    77 EXPORT_C TReal32 TAlfTimedValue::Speed() const __SOFTFP
       
    78     {
       
    79     return iSpeed;    
       
    80     }
       
    81 
       
    82 
       
    83 EXPORT_C void TAlfTimedValue::SetStyle(TAlfInterpolationStyle aStyle)
       
    84     {
       
    85     iFlags |= EAlfInterpolationStyleChanged;    
       
    86     iInterpolationStyle = aStyle;
       
    87     }
       
    88 
       
    89 EXPORT_C TAlfInterpolationStyle TAlfTimedValue::Style()
       
    90     {
       
    91     return TAlfInterpolationStyle(iInterpolationStyle);        
       
    92     }
       
    93     
       
    94 EXPORT_C void TAlfTimedValue::SetMappingFunctionIdentifier(TInt aIdentifier) 
       
    95     {
       
    96     iFlags |= EAlfMappingFunctionChanged;    
       
    97     iMappingFunctionIdentifier = aIdentifier;
       
    98     }
       
    99 
       
   100 // Todo: real use case for inline perhaps    
       
   101 EXPORT_C TReal32 TAlfTimedValue::ValueNow() const __SOFTFP
       
   102     {
       
   103     return iValueNow;
       
   104     }
       
   105 
       
   106 // Todo: real use case for inline perhaps        
       
   107 EXPORT_C TReal32 TAlfTimedValue::Target() const __SOFTFP
       
   108     {
       
   109     return iValueTarget;    
       
   110     }
       
   111 // Todo: real use case for inline perhaps        
       
   112 EXPORT_C TInt TAlfTimedValue::TimeToTargetinMilliSeconds() const
       
   113     {
       
   114     return iTimeToTarget;
       
   115     }
       
   116 
       
   117 EXPORT_C TInt& TAlfTimedValue::Flags()
       
   118     {
       
   119     return iFlags;
       
   120     }
       
   121 
       
   122 EXPORT_C TInt TAlfTimedValue::MappingFunctionIdentifier() const 
       
   123     {
       
   124     if (iFlags&EAlfMappingFunctionChanged)
       
   125         {
       
   126         return iMappingFunctionIdentifier;
       
   127         }
       
   128         
       
   129     return KErrNotFound;
       
   130     }
       
   131 
       
   132 
       
   133 
       
   134 EXPORT_C TAlfTimedPoint::TAlfTimedPoint()
       
   135     {}
       
   136 
       
   137 EXPORT_C TAlfTimedPoint::TAlfTimedPoint(TReal32 aX, TReal32 aY) __SOFTFP
       
   138     {
       
   139     iX = TAlfTimedValue(aX);
       
   140     iY = TAlfTimedValue(aY);    
       
   141     }
       
   142 
       
   143 EXPORT_C TAlfTimedPoint::TAlfTimedPoint(TReal32 aXTarget, TReal32 aYTarget, TInt aTransitionTime) __SOFTFP
       
   144     {
       
   145     iX = TAlfTimedValue(aXTarget, aTransitionTime);
       
   146     iY = TAlfTimedValue(aYTarget, aTransitionTime);            
       
   147     }
       
   148     
       
   149 
       
   150 EXPORT_C void TAlfTimedPoint::SetMappingFunctionIdentifier(TInt aIdentifier)
       
   151     {
       
   152     // Both use the same function, but the components are different.
       
   153     iX.SetMappingFunctionIdentifier(aIdentifier);
       
   154     iY.SetMappingFunctionIdentifier(aIdentifier);        
       
   155     }
       
   156 
       
   157 EXPORT_C void TAlfTimedPoint::SetStyle(TAlfInterpolationStyle aStyle)
       
   158     {
       
   159     iX.SetStyle(aStyle);
       
   160     iY.SetStyle(aStyle);        
       
   161     }
       
   162 
       
   163 EXPORT_C void TAlfTimedPoint::SetTarget(const TAlfRealPoint& aPoint, TInt aTransitionTime)
       
   164     {
       
   165     iX.SetTarget(aPoint.iX, aTransitionTime);
       
   166     iY.SetTarget(aPoint.iY, aTransitionTime);                
       
   167     }
       
   168     
       
   169 EXPORT_C void TAlfTimedPoint::SetTarget(TReal32 aValue, TInt aTransitionTime) __SOFTFP
       
   170     {
       
   171     iX.SetTarget(aValue, aTransitionTime);
       
   172     iY.SetTarget(aValue, aTransitionTime);                        
       
   173     }
       
   174 
       
   175 EXPORT_C void TAlfTimedPoint::SetTargetWithSpeed(const TAlfRealPoint& aPoint, TReal32 aUnitsPerSecond) __SOFTFP
       
   176     {
       
   177     iX.SetTargetWithSpeed(aPoint.iX, aUnitsPerSecond);
       
   178     iY.SetTargetWithSpeed(aPoint.iY, aUnitsPerSecond);                        
       
   179     }
       
   180   
       
   181 EXPORT_C void TAlfTimedPoint::SetTargetWithSpeed(TReal32 aValue, TReal32 aUnitsPerSecond) __SOFTFP
       
   182     {
       
   183     iX.SetTargetWithSpeed(aValue, aUnitsPerSecond);
       
   184     iY.SetTargetWithSpeed(aValue, aUnitsPerSecond);                                
       
   185     }
       
   186     
       
   187 EXPORT_C TPoint TAlfTimedPoint::IntValueNow() const
       
   188     {
       
   189     // Round the float returned by ValueNow to the closest integer.
       
   190     return TPoint(AlfUtil::RoundFloatToInt(iX.ValueNow()), AlfUtil::RoundFloatToInt(iY.ValueNow()));
       
   191     }
       
   192 
       
   193 EXPORT_C TPoint TAlfTimedPoint::IntTarget() const
       
   194     {
       
   195     // Round the float returned by ValueNow to the closest integer.
       
   196     return TPoint(AlfUtil::RoundFloatToInt(iX.Target()), AlfUtil::RoundFloatToInt(iY.Target()));
       
   197     }
       
   198 
       
   199 
       
   200 
       
   201 // End of file
       
   202