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