uiacceltk/hitchcock/coretoolkit/inc/HuiFxTimeLine.h
changeset 0 15bf7259bb7c
equal deleted inserted replaced
-1:000000000000 0:15bf7259bb7c
       
     1 /*
       
     2 * Copyright (c) 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:   
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 #ifndef HUIFXTIMELINE_H_
       
    21 #define HUIFXTIMELINE_H_
       
    22 
       
    23 enum THuiFxLoopingMode
       
    24     {
       
    25     ELoopingModeNone,
       
    26     ELoopingModeRepeat,
       
    27     };
       
    28 
       
    29 enum THuiFxInterpolationMode
       
    30     {
       
    31     EInterpolationModeHold,
       
    32     EInterpolationModeLinear,
       
    33     EInterpolationModeQuadraticBezier,
       
    34     EInterpolationModeCubicBezier,
       
    35     EInterpolationModeInQuad,
       
    36     EInterpolationModeOutQuad,
       
    37     EInterpolationModeInOutQuad,
       
    38     EInterpolationModeOutInQuad,
       
    39     EInterpolationModeInBack,
       
    40     EInterpolationModeOutBack,
       
    41     EInterpolationModeInOutBack,
       
    42     EInterpolationModeOutInBack,
       
    43 /*    
       
    44     EInterpolationModeDecelerate,
       
    45     EInterpolationModeAccelerate,
       
    46     EInterpolationModeImpulse,
       
    47     EInterpolationModeSineWave
       
    48 */    
       
    49     };
       
    50 
       
    51 template <typename TYPE, typename FPTYPE>
       
    52 class RHuiFxTimeLine
       
    53     {
       
    54 public:
       
    55     RHuiFxTimeLine();
       
    56     ~RHuiFxTimeLine();
       
    57 
       
    58     // TODO: tangent control, ease in/out
       
    59     void AppendKeyFrameL(TReal32 aTime, TYPE aValue);
       
    60     void AppendKeyFrameL(TReal32 aTime, TYPE aValue, TYPE aAuxValue1);
       
    61     void AppendKeyFrameL(TReal32 aTime, TYPE aValue, TYPE aAuxValue1, TYPE aAuxValue2);
       
    62      void SetLoopStart(TReal32 aTime);
       
    63     TReal32 LoopStart() const;
       
    64     void SetLoopEnd(TReal32 aTime);
       
    65     TReal32 LoopEnd() const;
       
    66     TReal32 Duration() const;
       
    67     void SetDuration(TReal32 aDuration);
       
    68     void SetInterpolationMode(THuiFxInterpolationMode aMode);
       
    69     THuiFxInterpolationMode InterpolationMode() const;
       
    70     void SetLoopingMode(THuiFxLoopingMode aMode);
       
    71     THuiFxLoopingMode LoopingMode() const;
       
    72     TYPE ValueAt(TReal32 aTime);
       
    73     
       
    74     RHuiFxTimeLine* CloneL();
       
    75 protected:
       
    76     FPTYPE ToFixedPoint(const TYPE& aValue);
       
    77     TYPE FromFixedPoint(const FPTYPE& aValue);
       
    78     FPTYPE Blend(const FPTYPE& aValue1, const FPTYPE& aValue2, TInt32 aAlpha);
       
    79     FPTYPE WeightedSum4(const FPTYPE& aValue1, const FPTYPE& aValue2, const FPTYPE& aValue3, const FPTYPE& aValue4,
       
    80                         TInt32 aWeight1, TInt32 aWeight2, TInt32 aWeight3, TInt32 aWeight4);
       
    81     TReal32 LocalTime(TReal32 aTime) const;
       
    82 
       
    83 private:
       
    84     // Not implemented
       
    85     RHuiFxTimeLine(const RHuiFxTimeLine& aTimeLine);
       
    86     RHuiFxTimeLine& operator=(const RHuiFxTimeLine& aTimeLine);
       
    87     
       
    88 private:
       
    89     class TKeyFrame
       
    90         {
       
    91     public:
       
    92         /** Time */
       
    93         TReal32             iTime;
       
    94         
       
    95         /** Fixed point time */
       
    96         TInt32              iFpTime;
       
    97         
       
    98         /** Value */
       
    99         TYPE                iValue;
       
   100 
       
   101         /** Fixed point value */
       
   102         FPTYPE              iFpValue;
       
   103         
       
   104         /** Auxiliary values for bezier interpolation */
       
   105         TYPE                iAuxValue[2];
       
   106         FPTYPE              iFpAuxValue[2];
       
   107         };
       
   108     
       
   109     typedef RArray<TKeyFrame> TKeyFrames;
       
   110 
       
   111     TReal32                 iTime;
       
   112     TReal32                 iDuration;
       
   113     TKeyFrames              iKeyFrames;
       
   114     TInt                    iLastIndex;
       
   115     TReal32                 iLoopStart;
       
   116     TReal32                 iLoopEnd;
       
   117     THuiFxLoopingMode       iLoopingMode;
       
   118     THuiFxInterpolationMode iInterpolationMode;
       
   119     };
       
   120 
       
   121 #include "HuiFxTimeLine.inl"
       
   122 
       
   123 #endif /*HUIFXTIMELINE_H_*/