|
1 /* |
|
2 * Copyright (c) 2004-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: Real-time timing model. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef AKNSALTIMINGMODELREALTIME_H |
|
19 #define AKNSALTIMINGMODELREALTIME_H |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "AknsAlTimingModel.h" |
|
23 |
|
24 // CONSTANTS |
|
25 |
|
26 // Timing model UID |
|
27 const TInt KAknsAlTimingModelRealTimeUID = 0x10207624; |
|
28 |
|
29 const TInt KAlMaxDurationVal = 65536; // In milliseconds, ~65 seconds |
|
30 |
|
31 // Constants for parameter names |
|
32 _LIT( KAknsAlRealTimeDuration, "d" ); |
|
33 _LIT( KAknsAlRealTimeRepeatCount, "rc" ); |
|
34 _LIT( KAknsAlRealTimeRepeatDuration, "rd" ); |
|
35 _LIT( KAknsAlRealTimeWrap, "w" ); |
|
36 |
|
37 // CLASS DECLARATION |
|
38 /** |
|
39 Real-time timing model that advances by keeping track on elapsed time between |
|
40 subsequent updates. The next named parameters are supported: |
|
41 - "d", duration |
|
42 - "rc", repeat count |
|
43 - "rd", repeat duration |
|
44 - "w", wrap mode |
|
45 |
|
46 Timing model configuration works as follows: |
|
47 |
|
48 Duration undefined: |
|
49 D RC RD Single duration Total duration |
|
50 0 Inf 0 Inf Inf |
|
51 0 Inf Def RD RD |
|
52 0 Inf Inf Inf Inf |
|
53 0 0 0 0 0 |
|
54 0 0 Def RD RD |
|
55 0 0 Inf Inf Inf |
|
56 0 Def 0 0 0 |
|
57 0 Def Def RD RD |
|
58 0 Def Inf Inf Inf |
|
59 |
|
60 Duration defined: |
|
61 D RC RD Single duration Total duration |
|
62 Def Inf 0 D Inf |
|
63 Def Inf Def D RD |
|
64 Def Inf Inf D Inf |
|
65 Def 0 0 D D |
|
66 Def 0 Def D RD |
|
67 Def 0 Inf D Inf |
|
68 Def Def 0 D D * RC |
|
69 Def Def Def D MIN(D * RC, RD) |
|
70 Def Def Inf D D * RC |
|
71 |
|
72 Duration infinite: |
|
73 D RC RD Single duration Total duration |
|
74 Inf Inf 0 Inf Inf |
|
75 Inf Inf Def RD RD |
|
76 Inf Inf Inf Inf Inf |
|
77 Inf 0 0 Inf Inf |
|
78 Inf 0 Def RD RD |
|
79 Inf 0 Inf Inf Inf |
|
80 Inf Def 0 Inf Inf |
|
81 Inf Def Def RD RD |
|
82 Inf Def Inf Inf Inf |
|
83 |
|
84 The above tables can reduced to: |
|
85 D RC RD Single duration Total duration |
|
86 #1 0 * Def RD RD |
|
87 #2 0 * Inf Inf Inf |
|
88 #3 0 Inf 0 Inf Inf |
|
89 #4 0 0 0 0 0 |
|
90 #5 0 Def 0 0 0 |
|
91 #6 Def Inf 0 D Inf |
|
92 #7 Def Inf Def D RD |
|
93 #8 Def Inf Inf D Inf |
|
94 #9 Def 0 0 D D |
|
95 #10 Def 0 Def D RD |
|
96 #11 Def 0 Inf D Inf |
|
97 #12 Def Def 0 D D * RC |
|
98 #13 Def Def Def D MIN(D * RC, RD) |
|
99 #14 Def Def Inf D D * RC |
|
100 #15 Inf * Def RD RD |
|
101 #16 Inf * Inf Inf Inf |
|
102 #17 Inf * 0 Inf Inf |
|
103 |
|
104 Abbreviations used: |
|
105 D duration |
|
106 RC repeat count |
|
107 RD repeat duration |
|
108 Def defined |
|
109 0 undefined (zero in resulting durations) |
|
110 Inf infinite |
|
111 * any value (defined, undefined, infinite) |
|
112 |
|
113 Note: Case #3 follows SMIL, it could have been defined to produce the same |
|
114 result as #4 and #5. Cases #4 and #5 could have been implemented as impossible |
|
115 case that causes a leave. Current implementation just sets the total duration |
|
116 to zero which produces an animation that finishes immediately. |
|
117 |
|
118 Configuration value formats: |
|
119 - Duration, repeat count and repeat duration are all defined as follows: |
|
120 < 0, value is infinite |
|
121 0, value is undefined |
|
122 > 0, value is defined |
|
123 - Duration is milliseconds, when defined |
|
124 - Repeat count is the number of repeated durations, when defined |
|
125 - Repeat duration is milliseconds, when defined |
|
126 - Because fixed point calculations are used, durations and repeat durations |
|
127 larger than KAlMaxDurationVal are clamped to KAlMaxDurationVal. It is |
|
128 possible to produce longer total durations by using repeat count. |
|
129 |
|
130 Wrap: |
|
131 If duration is repeated, wrapping defines how successive durations are mapped |
|
132 to relative values ranges. |
|
133 - If ETrue the sequence is wrapped [0,1][1,0][0,1]... |
|
134 - If EFalse the sequence is tiled [0,1][0,1][0,1]... |
|
135 - The default wrap mode is tiled. Wrapping is ignored if the duration is not |
|
136 repeated. |
|
137 |
|
138 Relative value format: |
|
139 - 32-bit unsigned integer, fixed point, 16.16 format. |
|
140 - Relative value range [0, 65536] maps effectively to real number range [0, 1]. |
|
141 - Relative value is quaranteed to be in range [0, 65536]. |
|
142 - If animation duration is infinite the relative value is always 0. |
|
143 |
|
144 @since 3.0 |
|
145 */ |
|
146 NONSHARABLE_CLASS( CAknsAlTimingModelRealTime ): public MAknsAlTimingModel |
|
147 { |
|
148 public: |
|
149 |
|
150 static inline TBool Infinite( TInt aValue ) |
|
151 { |
|
152 return ( aValue < 0 ? ETrue: EFalse ); |
|
153 } |
|
154 |
|
155 static inline TBool Undefined( TInt aValue ) |
|
156 { |
|
157 return ( aValue == 0 ? ETrue: EFalse ); |
|
158 } |
|
159 |
|
160 static inline TBool Defined( TInt aValue ) |
|
161 { |
|
162 return ( aValue > 0 ? ETrue: EFalse ); |
|
163 } |
|
164 |
|
165 protected: |
|
166 CAknsAlTimingModelRealTime(); |
|
167 |
|
168 public: |
|
169 static CAknsAlTimingModelRealTime* NewL(); |
|
170 virtual ~CAknsAlTimingModelRealTime(); |
|
171 |
|
172 TInt Duration() const; |
|
173 TInt TotalDuration() const; |
|
174 |
|
175 public: // Implementation of MAknsAlTimingModel |
|
176 |
|
177 /** |
|
178 * Supported named parameters are: |
|
179 * - "d", integer, duration |
|
180 * - "rc", integer, repeat count |
|
181 * - "rd", integer, repeat duration |
|
182 * - "w", boolean (0/1), wrap mode |
|
183 * |
|
184 * For documentation see the extensive class comment. |
|
185 * |
|
186 * Default parameter values are: |
|
187 * - "d" = 0 |
|
188 * - "rc" = 0 |
|
189 * - "rd" = 0 |
|
190 * - "w" = EFalse (0) |
|
191 */ |
|
192 void SetParametersL( MAknsRlParameterIterator& aParameters ); |
|
193 /** |
|
194 * Advances the timing model by the provided delta time. |
|
195 */ |
|
196 void Tick( const TInt aDeltaTime ); |
|
197 /** |
|
198 * Timestamp based ticking is ignored. |
|
199 */ |
|
200 void Tick( const TTime& aStamp ); |
|
201 TUint32 RelativeValue() const; |
|
202 TBool IsFinished() const; |
|
203 void Begin(); |
|
204 |
|
205 private: |
|
206 void Configure( TInt aD, TInt aRC, TInt aRD, TBool aWrap ); |
|
207 |
|
208 private: |
|
209 |
|
210 /// The length of one active duration, in milliseconds |
|
211 TInt iDuration; |
|
212 |
|
213 /// The total animation length, in milliseconds |
|
214 TInt iTotalDuration; |
|
215 |
|
216 /// Elapsed time since the start of the animation, in milliseconds |
|
217 TInt iElapsedTime; |
|
218 |
|
219 /// The current relative value, fixed point 16.16 format. |
|
220 TUint32 iRelative; |
|
221 |
|
222 /// Used wrapping mode. |
|
223 TBool iWrap; |
|
224 }; |
|
225 |
|
226 #endif // AKNSALTIMINGMODELREALTIME_H |
|
227 |
|
228 // End of File |
|
229 |