20
|
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 CFMRadioAlfVisualizer.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef FMRADIOALFVISUALIZER_H
|
|
20 |
#define FMRADIOALFVISUALIZER_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
|
|
24 |
#include <AknUtils.h>
|
|
25 |
#include <alf/alfcontrol.h>
|
|
26 |
#include <alf/alfanchorlayout.h>
|
|
27 |
#include <gesturecontrol.h>
|
|
28 |
#include <gestureobserver.h>
|
|
29 |
|
|
30 |
#include "fmradiodefines.h"
|
|
31 |
#include "fmradio.hrh"
|
|
32 |
|
|
33 |
// CONSTANTS
|
|
34 |
|
|
35 |
/** Scroll directions of the visual objects. */
|
|
36 |
enum TScrollDirection
|
|
37 |
{
|
|
38 |
EScrollLeftToRight = 0xA0,
|
|
39 |
EScrollRightToLeft,
|
|
40 |
EScrollNone
|
|
41 |
};
|
|
42 |
|
|
43 |
/** Possible display styles. */
|
|
44 |
enum TFMRadioDisplayStyle
|
|
45 |
{
|
|
46 |
EFMRadioDisplaySingleLine = 0, /**< Single line display. */
|
|
47 |
EFMRadioDisplayDoubleLine, /**< Double line display. */
|
|
48 |
EFMRadioDisplayTuning, /**< Tuning display. */
|
|
49 |
EFMRadioDisplayNoDisplay /**< No display used. */
|
|
50 |
};
|
|
51 |
|
|
52 |
/** Display orientations. */
|
|
53 |
enum TDisplayOrientation
|
|
54 |
{
|
|
55 |
EPortrait = 0x4A,
|
|
56 |
ELandscape,
|
|
57 |
EOrientationNone
|
|
58 |
};
|
|
59 |
|
|
60 |
// FORWARD DECLARATIONS
|
|
61 |
|
|
62 |
class CAlfTextVisual;
|
|
63 |
class CAlfViewportLayout;
|
|
64 |
class CAlfGradientBrush;
|
|
65 |
class CFMRadioAlfBitmapAnimation;
|
|
66 |
class CFMRadioAppUi;
|
|
67 |
class MTouchFeedback;
|
|
68 |
|
|
69 |
using namespace GestureHelper;
|
|
70 |
// CLASS DEFINITION
|
|
71 |
|
|
72 |
/**
|
|
73 |
* CFMRadioAlfVisualizer class
|
|
74 |
*
|
|
75 |
* Visualizes informations of the FMRadio to the display by Hitchcock UI Toolkit
|
|
76 |
*/
|
|
77 |
NONSHARABLE_CLASS(CFMRadioAlfVisualizer) : public CGestureControl, public MGestureObserver
|
|
78 |
{
|
|
79 |
public: // Constructors and destructor
|
|
80 |
|
|
81 |
/**
|
|
82 |
* Epoc two-phased constructor.
|
|
83 |
* @param aEnv Reference to the HitchCock environment instance.
|
|
84 |
* @return Pointer to this Visualizer component.
|
|
85 |
*/
|
|
86 |
static CFMRadioAlfVisualizer* NewL( CAlfEnv& aEnv );
|
|
87 |
/**
|
|
88 |
* Destructor
|
|
89 |
*/
|
|
90 |
virtual ~CFMRadioAlfVisualizer();
|
|
91 |
public: // Functions from base classes
|
|
92 |
/**
|
|
93 |
* From CGestureControl/CAlfControl, takes care of alfred event handling.
|
|
94 |
* @param aEvent
|
|
95 |
*/
|
|
96 |
TBool OfferEventL( const TAlfEvent& aEvent );
|
|
97 |
|
|
98 |
/**
|
|
99 |
* From CGestureControl, takes care of gesture event handling.
|
|
100 |
* @param aEvent
|
|
101 |
*/
|
|
102 |
void HandleGestureL( const MGestureEvent& aEvent );
|
|
103 |
public: // New functions
|
|
104 |
/**
|
|
105 |
* Changes station to next with scrolling and fading station's
|
|
106 |
* information (name, frequency, etc.).
|
|
107 |
* @param aChangeType The change type
|
|
108 |
* @param aFirstLine The text shown in the first line
|
|
109 |
* @param aSecondLine The text shown in the second line, or NULL
|
|
110 |
*/
|
|
111 |
void ChangeStationL( TFMRadioStationChangeType aChangeType,
|
|
112 |
const TDesC& aFirstLine,
|
|
113 |
const TDesC* aSecondLine = NULL );
|
|
114 |
/**
|
|
115 |
* Scrolls out the current station information lines by
|
|
116 |
* hiding actual visuals and scrolling out the created temporary information lines.
|
|
117 |
* @param aChangeType Station change type
|
|
118 |
*/
|
|
119 |
void ScrollOutCurrentStationInformationL( TFMRadioStationChangeType aChangeType );
|
|
120 |
/**
|
|
121 |
* Resets the station information and sets static text to the third line
|
|
122 |
* @param aInfoText an information text to show
|
|
123 |
* @param aChangeType The change type
|
|
124 |
*/
|
|
125 |
void SetStaticInfoTextL( TFMRadioStationChangeType aChangeType, const TDesC& aInfoText );
|
|
126 |
/**
|
|
127 |
* Change text color of the text visuals
|
|
128 |
* @param aTextColor Color of the visual texts
|
|
129 |
*/
|
|
130 |
void SetStationInformationTextColor( const TRgb& aTextColor );
|
|
131 |
/**
|
|
132 |
* Sets the display style in use.
|
|
133 |
* @param aDisplayStyle Display style to use.
|
|
134 |
*/
|
|
135 |
void SetDisplayStyle( TFMRadioDisplayStyle aDisplayStyle );
|
|
136 |
/**
|
|
137 |
* Returns the display style.
|
|
138 |
* @return Display style.
|
|
139 |
*/
|
|
140 |
TFMRadioDisplayStyle DisplayStyle() const;
|
|
141 |
/**
|
|
142 |
* Calculates display layout
|
|
143 |
*/
|
|
144 |
void UpdateLayout();
|
|
145 |
/**
|
|
146 |
* Return orientation of the display
|
|
147 |
*/
|
|
148 |
TDisplayOrientation Orientation();
|
|
149 |
/**
|
|
150 |
* Set orientation of the display
|
|
151 |
* @param aOrientation Orientation of the display
|
|
152 |
*/
|
|
153 |
void SetOrientation( TDisplayOrientation aOrientation );
|
|
154 |
/**
|
|
155 |
* Set mirrored layout state
|
|
156 |
* @param aIsMirrored state
|
|
157 |
*/
|
|
158 |
void SetMirrored( const TBool aIsMirrored );
|
|
159 |
/**
|
|
160 |
* @return Mirrored layout state
|
|
161 |
*/
|
|
162 |
TBool IsMirrored() const;
|
|
163 |
|
|
164 |
/**
|
|
165 |
* Starts tuning animation after delay
|
|
166 |
*/
|
|
167 |
void StartTuningAnimation();
|
|
168 |
|
|
169 |
/**
|
|
170 |
* Stops tuning animation by fading it away
|
|
171 |
*/
|
|
172 |
void StopTuningAnimation();
|
|
173 |
private:
|
|
174 |
/**
|
|
175 |
* C++ default constructor
|
|
176 |
*/
|
|
177 |
CFMRadioAlfVisualizer( );
|
|
178 |
/**
|
|
179 |
* EPOC second phase constructor.
|
|
180 |
* @param aEnv Reference to the Hitchcock environment instance.
|
|
181 |
*/
|
|
182 |
void ConstructL( CAlfEnv& aEnv );
|
|
183 |
private: // New functions
|
|
184 |
|
|
185 |
/** The visuals of the station information display. */
|
|
186 |
enum TStationInformationVisual
|
|
187 |
{
|
|
188 |
EFirstLineTextVisual = 0x1, /**< Text visual of the first line. */
|
|
189 |
ESecondLineTextVisual = 0x2, /**< Text visual of the second line. */
|
|
190 |
ETuningTextVisual = 0x4, /* Tuning text visual. */
|
|
191 |
EAllVisuals = EFirstLineTextVisual |
|
|
192 |
ESecondLineTextVisual |
|
|
193 |
ETuningTextVisual
|
|
194 |
};
|
|
195 |
|
|
196 |
/**
|
|
197 |
* Specifies the axis that is currently used in the station info drag
|
|
198 |
*/
|
|
199 |
enum TFMRadioDragAxis
|
|
200 |
{
|
|
201 |
EFMRadioDragAxisNone = 0,
|
|
202 |
EFMRadioDragAxisX,
|
|
203 |
EFMRadioDragAxisY
|
|
204 |
};
|
|
205 |
|
|
206 |
/**
|
|
207 |
* Sets text to the defined station information visual.
|
|
208 |
* @param aVisual The text visual object for showing
|
|
209 |
* @param aText Text
|
|
210 |
*/
|
|
211 |
void SetVisualTextL( TStationInformationVisual aVisual, const TDesC& aText );
|
|
212 |
/**
|
|
213 |
* Shows the defined station information visual.
|
|
214 |
* @param aVisual The text visual object for showing
|
|
215 |
* @param aFade <code>ETrue</code> if fade effect it to be used, <code>EFalse</code> otherwise.
|
|
216 |
*/
|
|
217 |
void ShowVisual( TStationInformationVisual aVisual, TBool aFade );
|
|
218 |
/**
|
|
219 |
* Hides the defined station information visual.
|
|
220 |
* @param aVisual The text visual object for hiding
|
|
221 |
*/
|
|
222 |
void HideVisual( TStationInformationVisual aVisual );
|
|
223 |
/**
|
|
224 |
* Sets and starts scrolling and fading animations to CAlfTextVisual.
|
|
225 |
* The visual object is scrolled from right side of the display to
|
|
226 |
* original position of the visual object.
|
|
227 |
* @param aVisual a pointer to the visual object
|
|
228 |
*/
|
|
229 |
void ScrollRightToLeftWithFadeIn( CAlfVisual& aVisual ) const;
|
|
230 |
/**
|
|
231 |
* Sets and starts scrolling and fading animations to CAlfTextVisual.
|
|
232 |
* The visual object is scrolled from left side of the display to
|
|
233 |
* original position of the visual object.
|
|
234 |
* @param aVisual a pointer to the visual object
|
|
235 |
*/
|
|
236 |
void ScrollLeftToRightWithFadeIn( CAlfVisual& aVisual ) const;
|
|
237 |
/**
|
|
238 |
* Sets and starts scrolling and fading animations to CAlfTextVisual.
|
|
239 |
* The visual object is scrolled from top of the display to
|
|
240 |
* original position of the visual object.
|
|
241 |
* @param aVisual a pointer to the visual object
|
|
242 |
*/
|
|
243 |
void ScrollInFromTop( CAlfVisual& aVisual ) const;
|
|
244 |
/**
|
|
245 |
* Sets and starts scrolling and fading animations to CAlfTextVisual.
|
|
246 |
* The visual object is scrolled from bottom of the display to
|
|
247 |
* original position of the visual object.
|
|
248 |
* @param aVisual a pointer to the visual object
|
|
249 |
*/
|
|
250 |
void ScrollInFromBottom( CAlfVisual& aVisual ) const;
|
|
251 |
/**
|
|
252 |
* Moves the visual back to it's original position
|
|
253 |
* @param aVisual The visual to be moved
|
|
254 |
*/
|
|
255 |
void RevertVisual( CAlfVisual& aVisual );
|
|
256 |
/**
|
|
257 |
* Sets and starts scrolling animation to CAlfVisual.
|
|
258 |
* The visual object is scrolled from current position to
|
|
259 |
* right side of the display
|
|
260 |
* @param aVisual a reference to the visual object
|
|
261 |
* @param aTime Time duration after the visual object has been scrolled to the target.
|
|
262 |
* Scrolling duration in milliseconds.
|
|
263 |
*/
|
|
264 |
void ScrollToRight( CAlfVisual& aVisual, TInt aTime ) const;
|
|
265 |
/**
|
|
266 |
* Sets and starts scrolling animation to CAlfVisual.
|
|
267 |
* The visual object is scrolled from current position to
|
|
268 |
* left side of the display
|
|
269 |
* @param aVisual a reference to the visual object
|
|
270 |
* @param aTime Time duration after the visual object has been scrolled to the target.
|
|
271 |
* Scrolling duration in milliseconds.
|
|
272 |
*/
|
|
273 |
void ScrollToLeft( CAlfVisual& aVisual, TInt aTime ) const;
|
|
274 |
/**
|
|
275 |
* Sets and starts scrolling animation to CAlfVisual.
|
|
276 |
* The visual object is scrolled from current position above the the display
|
|
277 |
* @param aVisual a reference to the visual object
|
|
278 |
* @param aTime Time duration after the visual object has been scrolled to the target.
|
|
279 |
* Scrolling duration in milliseconds.
|
|
280 |
*/
|
|
281 |
void ScrollUp( CAlfVisual& aVisual, TInt aTime ) const;
|
|
282 |
/**
|
|
283 |
* Sets and starts scrolling animation to CAlfVisual.
|
|
284 |
* The visual object is scrolled from current position below the the display
|
|
285 |
* @param aVisual a reference to the visual object
|
|
286 |
* @param aTime Time duration after the visual object has been scrolled to the target.
|
|
287 |
* Scrolling duration in milliseconds.
|
|
288 |
*/
|
|
289 |
void ScrollDown( CAlfVisual& aVisual, TInt aTime ) const;
|
|
290 |
/**
|
|
291 |
* Sets fade-in animation to the CAlfVisual.
|
|
292 |
* @param aVisual a reference to the visual object
|
|
293 |
* @param aFadingTime Time duration after the visual object has been faded in.
|
|
294 |
* Fading duration in milliseconds
|
|
295 |
* @param aOpacity Target opacity value
|
|
296 |
*/
|
|
297 |
void FadeIn( CAlfVisual& aVisual, TInt aFadingTime, TReal aOpacity = 1.0f ) const;
|
|
298 |
/**
|
|
299 |
* Sets fade-out animation to the CAlfVisual.
|
|
300 |
* @param aVisual a reference to the visual object
|
|
301 |
* @param aFadingTime Time duration after the visual object has been faded out.
|
|
302 |
* Fading duration in milliseconds
|
|
303 |
* @param aOpacity Target opacity value
|
|
304 |
*/
|
|
305 |
void FadeOut( CAlfVisual& aVisual, TInt aFadingTime, TReal aOpacity = 0.0f ) const;
|
|
306 |
/**
|
|
307 |
* Translates the visual object with passed arguments
|
|
308 |
* @param aTextVisual a pointer to the visual object
|
|
309 |
* @param aX Translation value in the horizontal direction
|
|
310 |
* @param aY Translation value in the vertical direction
|
|
311 |
*/
|
|
312 |
void Translate( CAlfTextVisual* aTextVisual, const TAlfTimedValue& aX, const TAlfTimedValue& aY );
|
|
313 |
/**
|
|
314 |
* Removes all transformations of the visual object such as the scaling and translating.
|
|
315 |
* @param aTextVisual a pointer to the visual object
|
|
316 |
*/
|
|
317 |
void LoadTextVisualIdentity( CAlfTextVisual* aTextVisual );
|
|
318 |
/**
|
|
319 |
* Sets absolute rect of the anchor by top left and bottom right points.
|
|
320 |
* @param aAnchor Anchor layout for setting placement
|
|
321 |
* @param aOrdinal Index of visual element
|
|
322 |
* @param aTopLeftPosition Top left point of the rect
|
|
323 |
* @param aBottomRightPosition Bottom right point of the rect
|
|
324 |
*/
|
|
325 |
void SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor,
|
|
326 |
TInt aOrdinal,
|
|
327 |
const TPoint& aTopLeftPosition,
|
|
328 |
const TPoint& aBottomRightPosition );
|
|
329 |
|
|
330 |
/**
|
|
331 |
* Creates the needed drawing layers and visual objects
|
|
332 |
* for visualiazing the station information.
|
|
333 |
*/
|
|
334 |
void AddInformationLayersL();
|
|
335 |
/**
|
|
336 |
* Creates the text styles to be used by station information visualiazing
|
|
337 |
*/
|
|
338 |
void CreateTextStylesForStationInformationL();
|
|
339 |
/**
|
|
340 |
* Creates copy of current station information
|
|
341 |
*/
|
|
342 |
void CreateTemporaryStationInformationVisualsL();
|
|
343 |
/**
|
|
344 |
* Animates temporary station infoout of the display
|
|
345 |
* @param aChangeType Change type
|
|
346 |
*/
|
|
347 |
void AnimateTemporaryStationInformationVisuals( TFMRadioStationChangeType aChangeType );
|
|
348 |
/**
|
|
349 |
* Triggers the command to view handling
|
|
350 |
* @param aCommand command id
|
|
351 |
*/
|
|
352 |
void TriggerCommandL( TInt aCommand = 0 );
|
|
353 |
/**
|
|
354 |
* Static call back for the long key press timer.
|
|
355 |
* @param aSelf Pointer to self.
|
|
356 |
* @return KErrNone
|
|
357 |
*/
|
|
358 |
static TInt StaticLongPressCallBack( TAny* aSelf );
|
|
359 |
private: // Data
|
|
360 |
|
|
361 |
/** Layout for the station information */
|
|
362 |
TAknLayoutRect iStationInformationLayout;
|
|
363 |
/** Layout for the transparent background layer of the station information */
|
|
364 |
TAknLayoutRect iTransparentBackgroundLayout;
|
|
365 |
|
|
366 |
/** Layout for the first line. */
|
|
367 |
TAknLayoutText iFirstLineLayout;
|
|
368 |
/** Layout for the second line */
|
|
369 |
TAknLayoutText iSecondLineLayout;
|
|
370 |
/** Layout for the tuning text. */
|
|
371 |
TAknLayoutText iTuningTextLayout;
|
|
372 |
/** Layout for the tuning animation. */
|
|
373 |
TAknLayoutRect iTuningAnimationLayout;
|
|
374 |
|
|
375 |
/** Visual object of the first line. Not owned. */
|
|
376 |
CAlfTextVisual* iFirstLineVisualText;
|
|
377 |
/** Visual object of the second line. Not owned. */
|
|
378 |
CAlfTextVisual* iSecondLineVisualText;
|
|
379 |
/** Visual text for tuning text. Not owned */
|
|
380 |
CAlfTextVisual* iTuningVisualText;
|
|
381 |
|
|
382 |
/** The layout for the station info visuals */
|
|
383 |
CAlfAnchorLayout* iStationInformationAnchorLayout;
|
|
384 |
/** The layout for temporary station info fade out effect */
|
|
385 |
CAlfAnchorLayout* iStationInformationTempAnchorLayout;
|
|
386 |
|
|
387 |
/** Text color of the station information visuals */
|
|
388 |
TRgb iStationInformationTextColor;
|
|
389 |
|
|
390 |
/** Text style id of the first line */
|
|
391 |
TInt iFirstLineTextStyleId;
|
|
392 |
/** Text style id of the second line */
|
|
393 |
TInt iSecondLineTextStyleId;
|
|
394 |
/** Text style id of the tuning text line */
|
|
395 |
TInt iTuningTextStyleId;
|
|
396 |
|
|
397 |
/** Display style */
|
|
398 |
TFMRadioDisplayStyle iDisplayStyle;
|
|
399 |
/** Display orientation */
|
|
400 |
TDisplayOrientation iOrientation;
|
|
401 |
/** Scroll direction */
|
|
402 |
TScrollDirection iScrollDirection;
|
|
403 |
// Bitmap Animation
|
|
404 |
CFMRadioAlfBitmapAnimation* iBmpAnimation;
|
|
405 |
// Flag to indicate mirrored layout usage
|
|
406 |
TBool iMirrored;
|
|
407 |
// visual size for bitmap animation positioning
|
|
408 |
TSize iTuningTextVisualSize;
|
|
409 |
// counts rt text (3rd line) scrollout -events for rt-timeout.
|
|
410 |
TInt iScrollOutCounter;
|
|
411 |
// Pointer to CFMRadioAppUi. Not owned
|
|
412 |
CFMRadioAppUi* iAppUi;
|
|
413 |
// key event
|
|
414 |
TInt iKeyScanCode;
|
|
415 |
/**
|
|
416 |
* If the long key event was detected or not. If it was, the subsequent key up should be ignored
|
|
417 |
*/
|
|
418 |
TBool iLongKeyTriggered;
|
|
419 |
/**
|
|
420 |
* Long key press timer. Owned.
|
|
421 |
*/
|
|
422 |
CPeriodic* iLongPressTimer;
|
|
423 |
// The position of the visual before the dragging started
|
|
424 |
TAlfTimedPoint iDragStartPosition;
|
|
425 |
// Status for determinging whether or not to revert the visual back to it's original position
|
|
426 |
TBool iRevertGestureDrag;
|
|
427 |
// The axis for the currently ongoing stroke
|
|
428 |
TFMRadioDragAxis iDragAxis;
|
|
429 |
// Tactile feedback for closing the popup
|
|
430 |
MTouchFeedback* iTouchFeedback; // For Tactile feedback
|
|
431 |
};
|
|
432 |
|
|
433 |
#endif //FMRADIOALFVISUALIZER_H
|