emailuis/uicomponents/inc/fsinteractioninterval.h
branchRCL_3
changeset 25 3533d4323edc
parent 0 8466d47a6819
equal deleted inserted replaced
24:d189ee25cf9d 25:3533d4323edc
       
     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:  THuiInteractionInterval is a utility class that can be used 
       
    15 *                as specify intervals that adapt to user input.
       
    16 *
       
    17 */
       
    18  
       
    19 
       
    20 #ifndef __FSINTERACTIONINTERVAL_H__
       
    21 #define __FSINTERACTIONINTERVAL_H__
       
    22 
       
    23 
       
    24 #include <e32base.h>
       
    25 
       
    26 /**
       
    27  * THuiInteractionInterval is a utility class that can be used to determine
       
    28  * the correct animation interval time, while taking into account how much time has
       
    29  * elapsed since the last time the interval was determined. 
       
    30  *
       
    31  * An interaction interval is useful for example when animating a list selector. By default,
       
    32  * the time interval for moving between two items could be 500 ms, but if
       
    33  * the user moves faster than this, the selector's animation may be 
       
    34  * unnecessarily delayed. In this situation, the interaction interval would
       
    35  * shorten the time interval for the moving animation, if necessary, to keep
       
    36  * better in sync with how quickly the user is moving in the list.
       
    37  */
       
    38 class CFsInteractionInterval: public CBase 
       
    39     {
       
    40 public:
       
    41 
       
    42     /* Constructors and destructor. */
       
    43 
       
    44     /**
       
    45      * Initializes the interaction interval.
       
    46      *
       
    47      * @param aScalar  Determines how strongly the interval adapts. 
       
    48      *
       
    49      * @see SetScalar()
       
    50      */
       
    51     CFsInteractionInterval(TReal32 aScalar = 2.0f);
       
    52 
       
    53 
       
    54     /* Methods. */
       
    55 
       
    56     /**
       
    57      * Sets the adaptation scalar. Determines how strongly the interval
       
    58      * will adapt to the elapsed time since the last evaluation.
       
    59      *
       
    60      * For example, 1.0 would mean that the maximum interval time is the 
       
    61      * time elapsed between the current evaluation and the
       
    62      * previous one. In this case, when the animation frequency 
       
    63      * stays the same, each sequence would have time to complete
       
    64      * before the next sequence begins. When the scalar is 2.0, the
       
    65      * maximum is twice the elapsed time, meaning that the 
       
    66      * ongoing animation sequence would always be finished halfway 
       
    67      * when the next sequence begins. This produces a smoother
       
    68      * end result.
       
    69      *
       
    70      * @param aScalar  New adaptation scalar.
       
    71      */
       
    72      void SetScalar(TReal32 aScalar);
       
    73     
       
    74     /**
       
    75      * Returns the current adapation scalar.
       
    76      *
       
    77      * @return Adaptation scalar.
       
    78      */
       
    79      TReal32 Scalar() const;
       
    80 
       
    81     /**
       
    82      * Evaluates the current interval. The evaluated interval will always 
       
    83      * be at least as large as the elapsed time since the last evaluation, 
       
    84      * but at most <code>aIntervalTime</code>. 
       
    85      *
       
    86      * @param aIntervalTime  The requested normal interval time.
       
    87      *
       
    88      * @return  The evaluated interval, effective during the current frame.
       
    89      *
       
    90      * @see SetScalar()
       
    91      */
       
    92      TInt Interval(TInt aIntervalTime);
       
    93     
       
    94     
       
    95 private:
       
    96 
       
    97     TTime iLastTime;
       
    98     
       
    99     /** Interval scalar. */
       
   100     TReal32 iScalar;
       
   101     
       
   102     /** Last time interaction interval was determined. */
       
   103     TUint32 iLastTimeMs;
       
   104 
       
   105     };
       
   106 
       
   107 
       
   108 #endif  // __FSINTERACTIONINTERVAL_H__