1 /* |
|
2 * Copyright (c) 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: Definition of the class CFMRadioAlfMediaIdle. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #ifndef FMRADIOALFMEDIAIDLE_H_ |
|
20 #define FMRADIOALFMEDIAIDLE_H_ |
|
21 |
|
22 // INCLUDES |
|
23 |
|
24 #include <AknUtils.h> |
|
25 #include <alf/alfcontrol.h> |
|
26 #include <alf/alfanchorlayout.h> |
|
27 |
|
28 #include "fmradioidlecontrolinterface.h" |
|
29 |
|
30 // FORWARD DECLARATIONS |
|
31 |
|
32 class CAlfGradientBrush; |
|
33 class CAlfEnv; |
|
34 class CAlfVisual; |
|
35 |
|
36 // CONSTANTS |
|
37 |
|
38 // CLASS DEFINITIONS |
|
39 |
|
40 /** |
|
41 * CFMRadioAlfMediaIdle class |
|
42 * |
|
43 * Class launches animated information in the defined subregion of the display. |
|
44 */ |
|
45 NONSHARABLE_CLASS(CFMRadioAlfMediaIdle) : public CAlfControl, |
|
46 public MFMRadioIdleControlInterface |
|
47 { |
|
48 public: // Constructors and destructor |
|
49 |
|
50 /** Display orientations. */ |
|
51 enum TOrientation |
|
52 { |
|
53 EPortrait = 0x4A, |
|
54 ELandscape, |
|
55 EOrientationNone |
|
56 }; |
|
57 |
|
58 /** |
|
59 * Epoc two-phased constructor. |
|
60 * @param aEnv Reference to Alfred environment instance. |
|
61 * @return Pointer to this media idle component. |
|
62 */ |
|
63 static CFMRadioAlfMediaIdle* NewL( CAlfEnv& aEnv ); |
|
64 /** |
|
65 * Destructor |
|
66 */ |
|
67 virtual ~CFMRadioAlfMediaIdle(); |
|
68 public: // Functions from base classes |
|
69 /** |
|
70 * From CAlfControl, takes care of alfred event handling. |
|
71 */ |
|
72 TBool OfferEventL( const TAlfEvent& aEvent ); |
|
73 |
|
74 public: // New functions |
|
75 |
|
76 /** Media idle modes. */ |
|
77 enum TMediaIdleMode |
|
78 { |
|
79 EOnlyBackgroundText = 0xB0, |
|
80 EBackgroundTextAndMediaIdleItems |
|
81 }; |
|
82 |
|
83 /** |
|
84 * Adds media idle item text to be used in the media idle |
|
85 * @param aMediaIdleItemText Text of the media idle item |
|
86 */ |
|
87 void AddMediaIdleContentL( const TDesC& aMediaIdleItemText ); |
|
88 /** |
|
89 * Removes all media idle item texts |
|
90 */ |
|
91 void ResetMediaIdleContent(); |
|
92 /** |
|
93 * Returns number of media idle content items |
|
94 * @return content count |
|
95 */ |
|
96 TInt MediaIdleContentCount() const; |
|
97 /** |
|
98 * Sets the mode request for mode change. The mode |
|
99 * will be changed as soon as possible. |
|
100 * @param aRequestedMode Requested mode |
|
101 */ |
|
102 void SetModeChangeRequestL( TMediaIdleMode aRequestedMode ); |
|
103 /** |
|
104 * Retrieves the media idle mode |
|
105 */ |
|
106 CFMRadioAlfMediaIdle::TMediaIdleMode Mode(); |
|
107 /** |
|
108 * Sets primary color for the media idle |
|
109 * @param aColor The color that is used as primary color of media idle |
|
110 */ |
|
111 void SetPrimaryColor( const TRgb& aColor ); |
|
112 /** |
|
113 * Sets secondary color for the media idle |
|
114 * @param aColor The color that is used as secondary color of media idle |
|
115 */ |
|
116 void SetSecondaryColor( const TRgb& aColor ); |
|
117 |
|
118 /** |
|
119 * Return orientation of the display |
|
120 */ |
|
121 CFMRadioAlfMediaIdle::TOrientation Orientation(); |
|
122 /** |
|
123 * Set orientation of the display |
|
124 * @param aOrientation The display orientation |
|
125 */ |
|
126 void SetOrientation( TOrientation aOrientation ); |
|
127 /** |
|
128 * Calculates display layout |
|
129 */ |
|
130 void UpdateLayout(); |
|
131 /** |
|
132 * Adds PS name to the media idle item array |
|
133 */ |
|
134 void AddPsNameToMediaIdleL( const TDesC& aPsName ); |
|
135 |
|
136 private: |
|
137 /** |
|
138 * C++ default constructor |
|
139 */ |
|
140 CFMRadioAlfMediaIdle( ); |
|
141 /** |
|
142 * EPOC second phase constructor. |
|
143 * @param aEnv Reference to the Hitchcock environment instance. |
|
144 */ |
|
145 void ConstructL( CAlfEnv& aEnv ); |
|
146 |
|
147 private: // New functions |
|
148 |
|
149 /** Scroll directions for the media idle item. */ |
|
150 enum TMediaIdleItemScrollDirection |
|
151 { |
|
152 EScrollLeftToRight = 0xA0, |
|
153 EScrollRightToLeft, |
|
154 EScrollNone |
|
155 }; |
|
156 |
|
157 /** States of media idle. */ |
|
158 enum TMediaIdleState |
|
159 { |
|
160 ERunning = 0xA0, |
|
161 EStopped |
|
162 }; |
|
163 |
|
164 /** Custom events for the media idle. */ |
|
165 enum TMediaIdleCustomEvent |
|
166 { |
|
167 EMediaIdleItemTransformationEnd = 0x5B, |
|
168 EMediaIdleBackgroundTextScrollEnd, |
|
169 EMediaIdleFadeOutAnimationEnd, |
|
170 EMediaIdleChangeMode, |
|
171 EMediaIdleEventNone |
|
172 }; |
|
173 |
|
174 /** |
|
175 * Launches media idle immediately. |
|
176 */ |
|
177 void StartMediaIdleL(); |
|
178 /** |
|
179 * Creates media idle with passed number of the media idle items |
|
180 * @param aNumberOfMediaIdleItems Number of the media idle items |
|
181 */ |
|
182 void AddMediaIdleL( const TInt aNumberOfMediaIdleItems ); |
|
183 /** |
|
184 * Creates the media idle item to the passed media idle view port. |
|
185 * @param aMediaIdle The view port of the media idle |
|
186 * @param aMediaIdleItemText Text of the media idle item |
|
187 * @param aMediaIdleItemHasBackground TBool to indicate background visibility |
|
188 * @param aBackgroundColor The background color of the media idle item |
|
189 * @param aBackgroundOpacity The background opacity of the media idle item |
|
190 */ |
|
191 CAlfTextVisual* AddMediaIdleItemL( CAlfLayout* aMediaIdle, |
|
192 const TDesC& aMediaIdleItemText, |
|
193 TBool aMediaIdleItemHasBackground = EFalse, |
|
194 const TRgb& aBackgroundColor = KRgbWhite, |
|
195 const TReal aBackgroundOpacity = 0.5f ); |
|
196 /** |
|
197 * Initializes the media idle items |
|
198 * @param aNumberOfMediaIdleItems Number of the media idle items |
|
199 */ |
|
200 void InitializeMediaIdleItemsL( const TInt aNumberOfMediaIdleItems ); |
|
201 /** |
|
202 * Sets defined animation to the created media idle items |
|
203 */ |
|
204 void AnimateMediaIdleItems(); |
|
205 /** |
|
206 * Retrieves text from randomly chousen media idle item |
|
207 */ |
|
208 HBufC* GetRandomMediaIdleContentL(); |
|
209 /** |
|
210 * Sets color, opacity and scaling settings to the media idle item |
|
211 * @param aMediaIdleItem The media idle item |
|
212 * @param aMediaIdleItemText Text of the media idle item |
|
213 * @param aTextStyleId Text style for text of the media idle item |
|
214 */ |
|
215 void SetMediaIdleItemSettingsL( CAlfTextVisual* aMediaIdleItem, const TDesC& aMediaIdleItemText, const TInt aTextStyleId ); |
|
216 /** |
|
217 * Sets translating animations to the media idle item |
|
218 * @param aMediaIdleItem The media idle item |
|
219 */ |
|
220 void SetMediaIdleItemAnimation( CAlfTextVisual* aMediaIdleItem ); |
|
221 /** |
|
222 * Sets the media idle mode |
|
223 */ |
|
224 void SetMode( TMediaIdleMode aMode ); |
|
225 /** |
|
226 * Sets image to display |
|
227 * @param aBitmapFileName Full path to image file |
|
228 * @param aAbsoluteRect Rect of the image |
|
229 * @param aBorders |
|
230 * @param aParentLayout |
|
231 */ |
|
232 void SetImageByAbsoluteRectL( const TDesC& aBitmapFileName, |
|
233 const TRect& aAbsoluteRect, |
|
234 TBool aBorders, |
|
235 CAlfLayout* aParentLayout = 0 ); |
|
236 /** |
|
237 * Fades in media idle |
|
238 * @param aNow If ETrue shows media idle immediately otherwise |
|
239 * fades with defined fading duration |
|
240 */ |
|
241 void MediaIdleFadeIn( TBool aNow = EFalse ); |
|
242 /** |
|
243 * Fades out media idle |
|
244 * @param aNow If ETrue hides media idle immediately otherwise |
|
245 * fades with defined fading duration |
|
246 */ |
|
247 void MediaIdleFadeOut( TBool aNow = EFalse ); |
|
248 |
|
249 /** |
|
250 * @param aVisual a pointer to the visual object |
|
251 * @param aTransitionTime Duration for reaching the target. |
|
252 * @param aEventAfterScrollingEnd custom even that will be sent when transition time is end |
|
253 */ |
|
254 void SetScrollingToBackgroundText( CAlfTextVisual* aVisual, |
|
255 TInt aTransitionTime, |
|
256 TMediaIdleCustomEvent aEventAfterScrollingEnd = EMediaIdleEventNone ) ; |
|
257 /** |
|
258 * Sets fade-in animation to the CAlfVisual. |
|
259 * @param aVisual a pointer to the visual object |
|
260 * @param aFadingTime Time duration after the visual object has been faded in. |
|
261 * Fading duration in milliseconds |
|
262 * @param aOpacity Target opacity value |
|
263 */ |
|
264 void FadeIn( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity = 1.0f ) const; |
|
265 /** |
|
266 * Sets fade-out animation to the CAlfVisual. |
|
267 * @param aVisual a pointer to the visual object |
|
268 * @param aFadingTime Time duration after the visual object has been faded out. |
|
269 * Fading duration in milliseconds |
|
270 * @param aOpacity Target opacity value |
|
271 */ |
|
272 void FadeOut( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity = 0.0f ) const; |
|
273 /** |
|
274 * Translates the visual object with passed arguments |
|
275 * @param aTextVisual a pointer to the visual object |
|
276 * @param aX Translation value in the horizontal direction |
|
277 * @param aY Translation value in the vertical direction |
|
278 */ |
|
279 void Translate( CAlfTextVisual* aTextVisual, const TAlfTimedValue& aX, const TAlfTimedValue& aY ); |
|
280 /** |
|
281 * Removes all transformations of the visual object such as the scaling and translating. |
|
282 * @param aTextVisual a pointer to the visual object |
|
283 */ |
|
284 void LoadTextVisualIdentity( CAlfTextVisual* aTextVisual ); |
|
285 /** |
|
286 * Sets absolute rect of the anchor by top left and bottom right points. |
|
287 * @param aAnchor Anchor layout for setting placement |
|
288 * @param aOrdinal Index of visual element |
|
289 * @param aTopLeftPosition Top left point of the rect |
|
290 * @param aBottomRightPosition Bottom right point of the rect |
|
291 */ |
|
292 void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, |
|
293 TInt aOrdinal, |
|
294 const TPoint& aTopLeftPosition, |
|
295 const TPoint& aBottomRightPosition ); |
|
296 /* |
|
297 * Transformation end event received |
|
298 */ |
|
299 void HandleMediaIdleItemTransformationEndEventL( const TAlfEvent& aEvent ); |
|
300 |
|
301 /** |
|
302 * Background text scroll end event received |
|
303 */ |
|
304 void HandleBackgroundTextScrollEndEventL( const TAlfEvent& aEvent ); |
|
305 |
|
306 /** |
|
307 ** Create fonts for media idle; based on a list of relative font sizes |
|
308 */ |
|
309 void CreateFontsL(); |
|
310 |
|
311 /** |
|
312 * Create a background idle text visual |
|
313 */ |
|
314 void CreateBackgroundTextL(); |
|
315 /** |
|
316 * Stops media idle |
|
317 */ |
|
318 void StopAndFadeOutMediaIdle(); |
|
319 |
|
320 // from MFMRadioIdleControlInterface |
|
321 void Show(); |
|
322 |
|
323 /** |
|
324 * from MFMRadioIdleControlInterface |
|
325 */ |
|
326 void Hide(); |
|
327 |
|
328 /** |
|
329 * from MFMRadioIdleControlInterface |
|
330 */ |
|
331 void Deactivate(); |
|
332 |
|
333 private: // Data |
|
334 /** Status flag for knowing should the fonts be recreated or not */ |
|
335 TOrientation iFontsOrientation; |
|
336 /** Display orientation */ |
|
337 TOrientation iOrientation; |
|
338 |
|
339 /** Layout for media idle */ |
|
340 TAknLayoutRect iMediaIdleLayout; |
|
341 /** Text style id of the media idle background text */ |
|
342 TInt iMediaIdleItemBackgroundTextStyleId; |
|
343 /** States of media idle */ |
|
344 TMediaIdleState iMediaIdleState; |
|
345 /** Keeps track of the current media idle mode */ |
|
346 TMediaIdleMode iMediaIdleMode; |
|
347 /** Keeps track of the requested mode */ |
|
348 TMediaIdleMode iMediaIdleRequestedMode; |
|
349 /** Counts the items that have finished their transformations for mode change */ |
|
350 TInt iItemsTransformationEndEventCounter; |
|
351 |
|
352 /** Color to be used for the media idle items */ |
|
353 TRgb iMediaIdlePrimaryColor; |
|
354 /** Color to be used for the media idle items */ |
|
355 TRgb iMediaIdleSecondaryColor; |
|
356 /** Scroll direction for the media idle item */ |
|
357 TMediaIdleItemScrollDirection iScrollDirection; |
|
358 |
|
359 /** Array for the strings of the media idle items */ |
|
360 CDesCArrayFlat* iMediaIdleItemArray; |
|
361 /** Array for the text styles of the media idle items */ |
|
362 RArray<TInt> iTextStyleIdArray; |
|
363 /** Scroll direction for the media idle background text */ |
|
364 TMediaIdleItemScrollDirection iBackgroundTextScrollDirection; |
|
365 /** Indicates whether the instance is fully constructed */ |
|
366 TBool iIsConstructed; |
|
367 /** the latest PS name added to the media idle item array. Owned */ |
|
368 HBufC* iPsName; |
|
369 /** The last size for font creation */ |
|
370 TInt iFontReferenceHeight; |
|
371 }; |
|
372 |
|
373 #endif /*FMRADIOALFMEDIAIDLE_H_*/ |
|