uiacceltk/hitchcock/coretoolkit/src/HuiInteractionInterval.cpp
changeset 0 15bf7259bb7c
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:   THuiInteractionInterval is a utility class that can be used 
       
    15 *                as specify intervals that adapt to user input.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 #include "uiacceltk/HuiInteractionInterval.h"  // Class definition
       
    22 #include "uiacceltk/HuiStatic.h"
       
    23 
       
    24 
       
    25 EXPORT_C THuiInteractionInterval::THuiInteractionInterval(TReal32 aScalar) __SOFTFP
       
    26         : iScalar(aScalar), iLastTimeMs(0)
       
    27     {
       
    28     }
       
    29 
       
    30 
       
    31 EXPORT_C void THuiInteractionInterval::SetScalar(TReal32 aScalar) __SOFTFP
       
    32     {
       
    33     iScalar = aScalar;
       
    34     }
       
    35     
       
    36     
       
    37 EXPORT_C TReal32 THuiInteractionInterval::Scalar() const __SOFTFP
       
    38     {
       
    39     return iScalar;
       
    40     }
       
    41     
       
    42 
       
    43 EXPORT_C TInt THuiInteractionInterval::Interval(TInt aIntervalTime)
       
    44     {
       
    45     TUint32 now = CHuiStatic::MilliSecondsSinceStart();
       
    46     TUint32 elapsed = now - iLastTimeMs;
       
    47     
       
    48     if(iScalar * elapsed < aIntervalTime)
       
    49         {
       
    50         // The last movement is probably still going on.
       
    51         aIntervalTime = TInt(elapsed * iScalar);
       
    52         }
       
    53         
       
    54     iLastTimeMs = now;
       
    55     
       
    56     return aIntervalTime;
       
    57     }