|
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: Implementation of the class CFMRadioAlfVisualizer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include <aknlayoutscalable_apps.cdl.h> |
|
22 #include <alf/alfbatchbuffer.h> |
|
23 #include <alf/alfcontrolgroup.h> |
|
24 #include <alf/alfenv.h> |
|
25 #include <alf/alftextvisual.h> |
|
26 #include <alf/alfevent.h> |
|
27 #include <alf/alftransformation.h> |
|
28 #include <alf/alfgradientbrush.h> |
|
29 #include <alf/alfbrusharray.h> |
|
30 #include <alf/alfborderbrush.h> |
|
31 #include <alf/alfimagevisual.h> |
|
32 #include <alf/alfimagebrush.h> |
|
33 #include <alf/alftexturemanager.h> |
|
34 #include <alf/alfdisplay.h> |
|
35 #include <alf/alfviewportlayout.h> |
|
36 #include <alf/alfdecklayout.h> |
|
37 #include <alf/alfutil.h> |
|
38 #include <alf/alftextstyle.h> |
|
39 #include <AknsItemID.h> |
|
40 #include <e32math.h> |
|
41 #include <eikenv.h> |
|
42 #include <fmradio.mbg> |
|
43 #include <aknview.h> |
|
44 #include <aknViewAppUi.h> |
|
45 #include <AknVolumePopup.h> |
|
46 |
|
47 #include "fmradioalfvisualizer.h" |
|
48 #include "fmradioappui.h" |
|
49 #include "fmradioalfbitmapanimation.h" |
|
50 #include "fmradio.hrh" |
|
51 #include "debug.h" |
|
52 |
|
53 using namespace GestureHelper; |
|
54 |
|
55 // CONSTANTS |
|
56 const TInt KFMRadioStationInformationFadeDurationTime = 200; |
|
57 const TInt KFMRadioStationInformationScrollDurationTime = 300; |
|
58 // The delay, in microseconds, after which long keypress is activated. Taken from S60 UI style guide |
|
59 const TInt KFMRadioRockerLongPressDelay = 600000; |
|
60 |
|
61 // values from fmradio LAF document |
|
62 const TInt KLAFVarietyTuningAnimationPortrait = 7; |
|
63 const TInt KLAFVarietyTuningAnimationLandscape = 7; |
|
64 const TInt KLAFVarietyTuningTextPortrait = 7; |
|
65 const TInt KLAFVarietyTuningTextLandscape = 7; |
|
66 const TInt KLAFVarietyInfoPaneFirstLinePortrait = 0; |
|
67 const TInt KLAFVarietyInfoPaneFirstLineLandscape = 1; |
|
68 const TInt KLAFVarietyInfoPaneSecondLinePortrait = 0; |
|
69 const TInt KLAFVarietyInfoPaneSecondLineLandscape = 1; |
|
70 const TInt KLAFVarietyStationInfoPanePortrait = 0; |
|
71 const TInt KLAFVarietyStationInfoPaneLandscape = 1; |
|
72 |
|
73 |
|
74 // ============================ MEMBER FUNCTIONS =============================== |
|
75 |
|
76 // --------------------------------------------------------------------------- |
|
77 // CFMRadioAlfVisualizer::NewL |
|
78 // Two-phase constructor of CFMRadioAlfVisualizer |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CFMRadioAlfVisualizer* CFMRadioAlfVisualizer::NewL( CAlfEnv& aEnv ) |
|
82 { |
|
83 CFMRadioAlfVisualizer* self = new (ELeave) CFMRadioAlfVisualizer( ); |
|
84 CleanupStack::PushL(self); |
|
85 self->ConstructL( aEnv ); |
|
86 CleanupStack::Pop(self); |
|
87 return self; |
|
88 } |
|
89 |
|
90 // ---------------------------------------------------------------------------- |
|
91 // CFMRadioAlfVisualizer::CFMRadioAlfVisualizer |
|
92 // Default constructor |
|
93 // ---------------------------------------------------------------------------- |
|
94 // |
|
95 CFMRadioAlfVisualizer::CFMRadioAlfVisualizer( ) |
|
96 : iOrientation ( EOrientationNone ) |
|
97 { |
|
98 //No implementation needed |
|
99 } |
|
100 |
|
101 // ---------------------------------------------------------------------------- |
|
102 // CFMRadioAlfVisualizer::ConstructL |
|
103 // Symbian 2nd phase constructor can leave. |
|
104 // ---------------------------------------------------------------------------- |
|
105 // |
|
106 void CFMRadioAlfVisualizer::ConstructL( CAlfEnv& aEnv ) |
|
107 { |
|
108 CGestureControl::ConstructL( *this, aEnv, aEnv.PrimaryDisplay(), KFMRadioVisualizerGestureControlGroupId ); |
|
109 |
|
110 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
111 iAppUi = static_cast<CFMRadioAppUi*>( coeEnv->AppUi() ); |
|
112 |
|
113 SetDisplayStyle( EFMRadioDisplayNoDisplay ); |
|
114 AddInformationLayersL(); |
|
115 |
|
116 iBmpAnimation = CFMRadioAlfBitmapAnimation::NewL( aEnv ); |
|
117 CAlfControlGroup& group = aEnv.ControlGroup( KFMRadioVisualControlsGroupId ); |
|
118 group.AppendL( iBmpAnimation ); |
|
119 |
|
120 UpdateLayout(); |
|
121 |
|
122 if ( AknLayoutUtils::PenEnabled() ) |
|
123 { |
|
124 iLongPressTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
125 } |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // ~CFMRadioAlfVisualizer::~CFMRadioAlfVisualizer |
|
130 // Destructor |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 CFMRadioAlfVisualizer::~CFMRadioAlfVisualizer() |
|
134 { |
|
135 CAlfTextStyleManager& manager = Env().TextStyleManager(); |
|
136 manager.DeleteTextStyle( iFirstLineTextStyleId ); |
|
137 manager.DeleteTextStyle( iSecondLineTextStyleId ); |
|
138 manager.DeleteTextStyle( iTuningTextStyleId ); |
|
139 |
|
140 delete iLongPressTimer; |
|
141 } |
|
142 |
|
143 // ---------------------------------------------------------------------------- |
|
144 // CFMRadioAlfVisualizer::UpdateLayout |
|
145 // Calculates display layout |
|
146 // ---------------------------------------------------------------------------- |
|
147 // |
|
148 void CFMRadioAlfVisualizer::UpdateLayout() |
|
149 { |
|
150 TRect mainPaneRect; |
|
151 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); |
|
152 TRect displayRect( mainPaneRect.Size() ); |
|
153 |
|
154 TInt lafVarietyAnimation = 0; |
|
155 TInt lafVarietyTuningText = 0; |
|
156 TInt lafVarietyStationInfoPane = 0; |
|
157 TInt lafVarietyFirstLineText = 0; |
|
158 TInt lafVarietySecondLineText = 0; |
|
159 |
|
160 TFMRadioDisplayStyle displayStyle = DisplayStyle(); |
|
161 |
|
162 // Adjust positions of the visual elements |
|
163 if ( iOrientation == EPortrait || iOrientation == EOrientationNone ) |
|
164 { |
|
165 lafVarietyAnimation = KLAFVarietyTuningAnimationPortrait; |
|
166 lafVarietyTuningText = KLAFVarietyTuningTextPortrait; |
|
167 lafVarietyStationInfoPane = KLAFVarietyStationInfoPanePortrait; |
|
168 lafVarietyFirstLineText = KLAFVarietyInfoPaneFirstLinePortrait; |
|
169 lafVarietySecondLineText = KLAFVarietyInfoPaneSecondLinePortrait; |
|
170 } |
|
171 else if ( iOrientation == ELandscape ) |
|
172 { |
|
173 lafVarietyAnimation = KLAFVarietyTuningAnimationLandscape; |
|
174 lafVarietyTuningText = KLAFVarietyTuningTextLandscape; |
|
175 lafVarietyStationInfoPane = KLAFVarietyStationInfoPaneLandscape; |
|
176 lafVarietyFirstLineText = KLAFVarietyInfoPaneFirstLineLandscape; |
|
177 lafVarietySecondLineText = KLAFVarietyInfoPaneSecondLineLandscape; |
|
178 } |
|
179 |
|
180 iStationInformationLayout.LayoutRect( displayRect, |
|
181 AknLayoutScalable_Apps::area_fmrd2_info_pane( lafVarietyStationInfoPane ).LayoutLine() ); |
|
182 |
|
183 if ( EFMRadioDisplayDoubleLine == displayStyle ) |
|
184 { |
|
185 iFirstLineLayout.LayoutText( iStationInformationLayout.Rect(), |
|
186 AknLayoutScalable_Apps::area_fmrd2_info_pane_t1( lafVarietyFirstLineText ).LayoutLine() ); |
|
187 } |
|
188 else // use bigger area for first line because it is the only visible line |
|
189 { |
|
190 iFirstLineLayout.LayoutText( iStationInformationLayout.Rect(), |
|
191 AknLayoutScalable_Apps::area_fmrd2_info_pane_t3( lafVarietyFirstLineText ).LayoutLine() ); |
|
192 } |
|
193 |
|
194 iSecondLineLayout.LayoutText( iStationInformationLayout.Rect(), |
|
195 AknLayoutScalable_Apps::area_fmrd2_info_pane_t2( lafVarietySecondLineText ).LayoutLine() ); |
|
196 |
|
197 iTuningTextLayout.LayoutText( iStationInformationLayout.Rect(), |
|
198 AknLayoutScalable_Apps::area_fmrd2_info_pane_t4( lafVarietyTuningText ).LayoutLine() ); |
|
199 |
|
200 iTuningAnimationLayout.LayoutRect( iStationInformationLayout.Rect(), |
|
201 AknLayoutScalable_Apps::area_fmrd2_info_pane_g1( lafVarietyAnimation ) ); |
|
202 |
|
203 CAlfTextStyleManager& manager = Env().TextStyleManager(); |
|
204 CAlfTextStyle* style = NULL; |
|
205 style = manager.TextStyle( iFirstLineTextStyleId ); |
|
206 if ( style->TextSizeInPixels() != iFirstLineLayout.TextRect().Height() ) |
|
207 { // Update text size according to height of layout in LS & PT modes |
|
208 style->SetTextSizeInPixels( iFirstLineLayout.TextRect().Height(), ETrue ); |
|
209 iFirstLineVisualText->SetTextStyle( iFirstLineTextStyleId ); |
|
210 } |
|
211 |
|
212 style = manager.TextStyle( iSecondLineTextStyleId ); |
|
213 if ( style->TextSizeInPixels() != iSecondLineLayout.TextRect().Height() ) |
|
214 { // Update text size according to height of layout in LS & PT modes |
|
215 style->SetTextSizeInPixels( iSecondLineLayout.TextRect().Height(), ETrue ); |
|
216 iSecondLineVisualText->SetTextStyle( iSecondLineTextStyleId ); |
|
217 } |
|
218 |
|
219 style = manager.TextStyle( iTuningTextStyleId ); |
|
220 if ( style->TextSizeInPixels() != iTuningTextLayout.TextRect().Height() ) |
|
221 { // Update text size according to height of layout in LS & PT modes |
|
222 style->SetTextSizeInPixels( iTuningTextLayout.TextRect().Height(), ETrue ); |
|
223 iTuningVisualText->SetTextStyle( iTuningTextStyleId ); |
|
224 } |
|
225 |
|
226 SetAbsoluteCornerAnchors( iStationInformationAnchorLayout, 0, iFirstLineLayout.TextRect().iTl, iFirstLineLayout.TextRect().iBr ); |
|
227 SetAbsoluteCornerAnchors( iStationInformationAnchorLayout, 1, iSecondLineLayout.TextRect().iTl, iSecondLineLayout.TextRect().iBr ); |
|
228 SetAbsoluteCornerAnchors( iStationInformationAnchorLayout, 2, iTuningTextLayout.TextRect().iTl, iTuningTextLayout.TextRect().iBr ); |
|
229 iStationInformationAnchorLayout->UpdateChildrenLayout(); |
|
230 iBmpAnimation->SetRect( iTuningAnimationLayout.Rect() ); |
|
231 } |
|
232 |
|
233 // ---------------------------------------------------------------------------- |
|
234 // CFMRadioAlfVisualizer::Orientation |
|
235 // Return orientation of the display |
|
236 // ---------------------------------------------------------------------------- |
|
237 // |
|
238 TDisplayOrientation CFMRadioAlfVisualizer::Orientation() |
|
239 { |
|
240 return iOrientation; |
|
241 } |
|
242 |
|
243 // ---------------------------------------------------------------------------- |
|
244 // CFMRadioAlfVisualizer::Orientation |
|
245 // Set orientation of the display |
|
246 // ---------------------------------------------------------------------------- |
|
247 // |
|
248 void CFMRadioAlfVisualizer::SetOrientation( TDisplayOrientation aOrientation ) |
|
249 { |
|
250 iOrientation = aOrientation; |
|
251 } |
|
252 |
|
253 // ---------------------------------------------------------------------------- |
|
254 // CFMRadioAlfVisualizer::SetMirrored |
|
255 // ---------------------------------------------------------------------------- |
|
256 // |
|
257 void CFMRadioAlfVisualizer::SetMirrored( const TBool aIsMirrored ) |
|
258 { |
|
259 iMirrored = aIsMirrored; |
|
260 } |
|
261 |
|
262 |
|
263 // --------------------------------------------------------------------------- |
|
264 // CFMRadioAlfVisualizer::IsMirroredL |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 TBool CFMRadioAlfVisualizer::IsMirrored() const |
|
268 { |
|
269 return iMirrored; |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 // CFMRadioAlfVisualizer::AddInformationLayersL |
|
274 // Creates the needed drawing layers and visual objects |
|
275 // for visualiazing the station information. |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 void CFMRadioAlfVisualizer::AddInformationLayersL() |
|
279 { |
|
280 CreateTextStylesForStationInformationL(); |
|
281 // Create an anchor for layout of texts |
|
282 iStationInformationAnchorLayout = CAlfAnchorLayout::AddNewL( *this ); |
|
283 |
|
284 // Create anchor to be used when preset channel is changed |
|
285 iStationInformationTempAnchorLayout = CAlfAnchorLayout::AddNewL( *this ); |
|
286 iStationInformationTempAnchorLayout->SetOpacity( TAlfTimedValue( 0.0 ) ); |
|
287 |
|
288 for ( TInt i = 0; i < 3; i++ ) |
|
289 { |
|
290 CAlfTextVisual* tempTextVisual = CAlfTextVisual::AddNewL( *this, iStationInformationTempAnchorLayout ); |
|
291 tempTextVisual->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); |
|
292 tempTextVisual->SetAlign( EAlfAlignHCenter, EAlfAlignVCenter ); |
|
293 } |
|
294 |
|
295 // Create visual object for the station name |
|
296 iFirstLineVisualText = CAlfTextVisual::AddNewL( *this, iStationInformationAnchorLayout ); |
|
297 iFirstLineVisualText->SetTextStyle( iFirstLineTextStyleId ); |
|
298 iFirstLineVisualText->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); |
|
299 iFirstLineVisualText->SetAlign( EAlfAlignHCenter, EAlfAlignVCenter ); |
|
300 // Create visual object for frequency information |
|
301 iSecondLineVisualText = CAlfTextVisual::AddNewL( *this, iStationInformationAnchorLayout ); |
|
302 iSecondLineVisualText->SetTextStyle( iSecondLineTextStyleId ); |
|
303 iSecondLineVisualText->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); |
|
304 iSecondLineVisualText->SetAlign( EAlfAlignHCenter, EAlfAlignVCenter ); |
|
305 // Visual for tuning text |
|
306 iTuningVisualText = CAlfTextVisual::AddNewL( *this, iStationInformationAnchorLayout ); |
|
307 iTuningVisualText->SetTextStyle( iTuningTextStyleId ); |
|
308 iTuningVisualText->SetWrapping( CAlfTextVisual::ELineWrapTruncate ); |
|
309 iTuningVisualText->SetAlign( EAlfAlignHCenter, EAlfAlignVCenter ); |
|
310 } |
|
311 |
|
312 // --------------------------------------------------------------------------- |
|
313 // CFMRadioAlfVisualizer::CreateTextStylesForStationInformationL |
|
314 // Creates the text styles to be used by station information visualiazing |
|
315 // --------------------------------------------------------------------------- |
|
316 // |
|
317 void CFMRadioAlfVisualizer::CreateTextStylesForStationInformationL() |
|
318 { |
|
319 CAlfTextStyleManager& manager = Env().TextStyleManager(); |
|
320 |
|
321 iFirstLineTextStyleId = manager.CreatePlatformTextStyleL( |
|
322 EAknLogicalFontPrimaryFont, |
|
323 EAlfTextStyleNormal ); |
|
324 |
|
325 iSecondLineTextStyleId = manager.CreatePlatformTextStyleL( |
|
326 EAknLogicalFontSecondaryFont, |
|
327 EAlfTextStyleNormal ); |
|
328 |
|
329 iTuningTextStyleId = manager.CreatePlatformTextStyleL( |
|
330 EAknLogicalFontSecondaryFont, |
|
331 EAlfTextStyleNormal ); |
|
332 } |
|
333 |
|
334 // --------------------------------------------------------------------------- |
|
335 // CFMRadioAlfVisualizer::SetVisualText |
|
336 // Sets text to the defined station information visual. |
|
337 // --------------------------------------------------------------------------- |
|
338 // |
|
339 void CFMRadioAlfVisualizer::SetVisualTextL( TStationInformationVisual aVisual, const TDesC& aText ) |
|
340 { |
|
341 if( aVisual & EFirstLineTextVisual ) |
|
342 { |
|
343 iFirstLineVisualText->SetTextL( aText ); |
|
344 iFirstLineVisualText->SetSize( iFirstLineVisualText->TextExtents() ); |
|
345 } |
|
346 if( aVisual & ESecondLineTextVisual ) |
|
347 { |
|
348 iSecondLineVisualText->SetTextL( aText ); |
|
349 iSecondLineVisualText->SetSize( iSecondLineVisualText->TextExtents() ); |
|
350 } |
|
351 if ( aVisual & ETuningTextVisual ) |
|
352 { |
|
353 iTuningVisualText->SetTextL( aText ); |
|
354 iTuningVisualText->SetSize( iTuningVisualText->TextExtents() ); |
|
355 } |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // CFMRadioAlfVisualizer::ShowVisual |
|
360 // Shows the defined station information visual. |
|
361 // --------------------------------------------------------------------------- |
|
362 // |
|
363 void CFMRadioAlfVisualizer::ShowVisual( TStationInformationVisual aVisual, TBool aFade ) |
|
364 { |
|
365 if ( aVisual & EFirstLineTextVisual ) |
|
366 { |
|
367 if ( aFade ) |
|
368 { |
|
369 FadeIn( *iFirstLineVisualText, KFMRadioStationInformationFadeDurationTime ); |
|
370 } |
|
371 else |
|
372 { |
|
373 FadeIn( *iFirstLineVisualText, 0 ); |
|
374 } |
|
375 } |
|
376 if ( aVisual & ESecondLineTextVisual ) |
|
377 { |
|
378 if ( aFade ) |
|
379 { |
|
380 FadeIn( *iSecondLineVisualText, KFMRadioStationInformationFadeDurationTime ); |
|
381 } |
|
382 else |
|
383 { |
|
384 FadeIn( *iSecondLineVisualText, 0 ); |
|
385 } |
|
386 } |
|
387 if ( aVisual & ETuningTextVisual ) |
|
388 { |
|
389 if ( aFade ) |
|
390 { |
|
391 FadeIn( *iTuningVisualText, KFMRadioStationInformationFadeDurationTime ); |
|
392 } |
|
393 else |
|
394 { |
|
395 FadeIn( *iTuningVisualText, 0 ); |
|
396 } |
|
397 } |
|
398 } |
|
399 |
|
400 // --------------------------------------------------------------------------- |
|
401 // CFMRadioAlfVisualizer::HideVisual |
|
402 // Hides the defined station information visual. |
|
403 // --------------------------------------------------------------------------- |
|
404 // |
|
405 void CFMRadioAlfVisualizer::HideVisual( TStationInformationVisual aVisual ) |
|
406 { |
|
407 if ( aVisual & EFirstLineTextVisual ) |
|
408 { |
|
409 FadeOut( *iFirstLineVisualText, 0 ); |
|
410 } |
|
411 if ( aVisual & ESecondLineTextVisual ) |
|
412 { |
|
413 FadeOut( *iSecondLineVisualText, 0 ); |
|
414 } |
|
415 if ( aVisual & ETuningTextVisual ) |
|
416 { |
|
417 FadeOut( *iTuningVisualText, 0 ); |
|
418 } |
|
419 } |
|
420 |
|
421 // --------------------------------------------------------------------------- |
|
422 // CFMRadioAlfVisualizer::SetStationInformationTextColor |
|
423 // Change text color of the text visuals. |
|
424 // --------------------------------------------------------------------------- |
|
425 // |
|
426 void CFMRadioAlfVisualizer::SetStationInformationTextColor( const TRgb& aTextColor ) |
|
427 { |
|
428 iStationInformationTextColor = aTextColor; |
|
429 iFirstLineVisualText->SetColor( aTextColor ); |
|
430 iSecondLineVisualText->SetColor( aTextColor ); |
|
431 iTuningVisualText->SetColor( aTextColor ); |
|
432 }; |
|
433 |
|
434 // ---------------------------------------------------------------------------- |
|
435 // CFMRadioAlfVisualizer::ScrollOutCurrentStationInformationL |
|
436 // Scrolls out the current station information lines by hiding actual visuals and scrolling out |
|
437 // the created temporary information lines |
|
438 // ---------------------------------------------------------------------------- |
|
439 // |
|
440 void CFMRadioAlfVisualizer::ScrollOutCurrentStationInformationL( TFMRadioStationChangeType aChangeType ) |
|
441 { |
|
442 // Don't start any effects if the current station info is already disappeared |
|
443 if ( iStationInformationAnchorLayout->Opacity().Target() != 0 ) |
|
444 { |
|
445 // Hide the actual station information visuals |
|
446 CreateTemporaryStationInformationVisualsL(); |
|
447 AnimateTemporaryStationInformationVisuals( aChangeType ); |
|
448 // Hide the original and set it to origin by default |
|
449 HideVisual( EAllVisuals ); |
|
450 FadeOut( *iStationInformationAnchorLayout, 0 ); |
|
451 iStationInformationAnchorLayout->SetPos( TAlfRealPoint() ); |
|
452 // Flush manually |
|
453 Env().BatchBufferHandler().FlushBatchBuffer(); |
|
454 } |
|
455 } |
|
456 |
|
457 // ---------------------------------------------------------------------------- |
|
458 // CFMRadioAlfVisualizer::CreateTemporaryStationInformationVisualsL |
|
459 // Creates copy of current station information |
|
460 // ---------------------------------------------------------------------------- |
|
461 // |
|
462 void CFMRadioAlfVisualizer::CreateTemporaryStationInformationVisualsL() |
|
463 { |
|
464 // update layout and attributes for child visuals |
|
465 for ( TInt i = 0, count = iStationInformationAnchorLayout->Count(); i < count; i++ ) |
|
466 { |
|
467 TPoint childPosition; |
|
468 TSize childSize; |
|
469 |
|
470 iStationInformationAnchorLayout->ChildPos( i , childPosition ); |
|
471 iStationInformationAnchorLayout->ChildSize( i , childSize ); |
|
472 TAlfRealRect childRect( TRect( childPosition, childSize ) ); |
|
473 |
|
474 CAlfTextVisual* textVisual = static_cast<CAlfTextVisual*>( &iStationInformationAnchorLayout->Visual( i ) ); |
|
475 CAlfTextVisual* tempTextVisual = static_cast<CAlfTextVisual*>( &iStationInformationTempAnchorLayout->Visual( i ) ); |
|
476 |
|
477 tempTextVisual->SetTextL( textVisual->Text() ); |
|
478 tempTextVisual->SetTextStyle( textVisual->TextStyle() ); |
|
479 tempTextVisual->SetColor( iStationInformationTextColor ); |
|
480 tempTextVisual->SetOpacity( textVisual->Opacity() ); |
|
481 |
|
482 SetAbsoluteCornerAnchors( iStationInformationTempAnchorLayout, i, childRect.iTl, childRect.iBr ); |
|
483 } |
|
484 iStationInformationTempAnchorLayout->UpdateChildrenLayout(); |
|
485 |
|
486 // Flush manually |
|
487 Env().BatchBufferHandler().FlushBatchBuffer(); |
|
488 |
|
489 iStationInformationTempAnchorLayout->SetOpacity( iStationInformationAnchorLayout->Opacity() ); |
|
490 iStationInformationTempAnchorLayout->SetPos( iStationInformationAnchorLayout->Pos() ); |
|
491 } |
|
492 |
|
493 // ---------------------------------------------------------------------------- |
|
494 // CFMRadioAlfVisualizer::AnimateTemporaryStationInformationVisuals |
|
495 // Animates temporary station infoout of the display |
|
496 // ---------------------------------------------------------------------------- |
|
497 // |
|
498 void CFMRadioAlfVisualizer::AnimateTemporaryStationInformationVisuals( TFMRadioStationChangeType aChangeType ) |
|
499 { |
|
500 FadeOut( *iStationInformationTempAnchorLayout, KFMRadioStationInformationFadeDurationTime ); |
|
501 switch ( aChangeType ) |
|
502 { |
|
503 // Swipe visuals in the opposite direction to give the right impression |
|
504 case EFMRadioStationChangePrevious: |
|
505 { |
|
506 ScrollToRight( *iStationInformationTempAnchorLayout, KFMRadioStationInformationScrollDurationTime ); |
|
507 break; |
|
508 } |
|
509 case EFMRadioStationChangeNext: |
|
510 { |
|
511 ScrollToLeft( *iStationInformationTempAnchorLayout, KFMRadioStationInformationScrollDurationTime ); |
|
512 break; |
|
513 } |
|
514 case EFMRadioStationChangeScanUp: |
|
515 { |
|
516 ScrollUp( *iStationInformationTempAnchorLayout, KFMRadioStationInformationScrollDurationTime ); |
|
517 break; |
|
518 } |
|
519 case EFMRadioStationChangeScanDown: |
|
520 { |
|
521 ScrollDown( *iStationInformationTempAnchorLayout, KFMRadioStationInformationScrollDurationTime ); |
|
522 break; |
|
523 } |
|
524 default: |
|
525 break; |
|
526 }; |
|
527 } |
|
528 |
|
529 // --------------------------------------------------------------------------- |
|
530 // From class MGestureObserver. |
|
531 // Called when user makes gestures. |
|
532 // --------------------------------------------------------------------------- |
|
533 // |
|
534 void CFMRadioAlfVisualizer::HandleGestureL( const MGestureEvent& aEvent ) |
|
535 { |
|
536 TGestureCode eventCode( aEvent.Code( MGestureEvent::EAxisBoth ) ); |
|
537 FTRACE( FPrint( _L("CFMRadioAlfVisualizer::HandleGestureL(eventCode=%d)"), eventCode ) ); |
|
538 |
|
539 CFMRadioAppUi* appUi = static_cast<CFMRadioAppUi*>( CCoeEnv::Static()->AppUi() ); |
|
540 // handle gestures only if there is no call ongoing |
|
541 if ( !appUi->RadioEngine()->IsInCall() ) |
|
542 { |
|
543 switch ( eventCode ) |
|
544 { |
|
545 case EGestureTap: |
|
546 { |
|
547 CAknVolumePopup* volPopup = appUi->ActiveVolumePopup(); |
|
548 if ( volPopup ) |
|
549 { |
|
550 if ( volPopup->IsVisible() ) |
|
551 { |
|
552 volPopup->CloseVolumePopup(); |
|
553 } |
|
554 else |
|
555 { |
|
556 volPopup->ShowVolumePopupL(); |
|
557 } |
|
558 } |
|
559 break; |
|
560 } |
|
561 case EGestureSwipeLeft: |
|
562 { |
|
563 if ( iDragAxis == EFMRadioDragAxisX ) |
|
564 { |
|
565 if ( appUi->NumberOfChannelsStored() ) |
|
566 { |
|
567 iRevertGestureDrag = EFalse; |
|
568 } |
|
569 appUi->HandleCommandL( EFMRadioCmdNextChannel ); |
|
570 } |
|
571 break; |
|
572 } |
|
573 case EGestureSwipeRight: |
|
574 { |
|
575 if ( iDragAxis == EFMRadioDragAxisX ) |
|
576 { |
|
577 if ( appUi->NumberOfChannelsStored() ) |
|
578 { |
|
579 iRevertGestureDrag = EFalse; |
|
580 } |
|
581 appUi->HandleCommandL( EFMRadioCmdPrevChannel ); |
|
582 } |
|
583 break; |
|
584 } |
|
585 case EGestureSwipeUp: |
|
586 { |
|
587 if ( iDragAxis == EFMRadioDragAxisY ) |
|
588 { |
|
589 iRevertGestureDrag = EFalse; |
|
590 appUi->HandleCommandL( EFMRadioCmdSeekUp ); |
|
591 } |
|
592 break; |
|
593 } |
|
594 case EGestureSwipeDown: |
|
595 { |
|
596 if ( iDragAxis == EFMRadioDragAxisY ) |
|
597 { |
|
598 iRevertGestureDrag = EFalse; |
|
599 appUi->HandleCommandL( EFMRadioCmdSeekDown ); |
|
600 } |
|
601 break; |
|
602 } |
|
603 case EGestureStart: |
|
604 { |
|
605 iDragAxis = EFMRadioDragAxisNone; |
|
606 iRevertGestureDrag = ETrue; |
|
607 iDragStartPosition = iStationInformationAnchorLayout->Pos(); |
|
608 break; |
|
609 } |
|
610 case EGestureDrag: |
|
611 { |
|
612 TPoint delta = aEvent.CurrentPos() - aEvent.StartPos(); |
|
613 |
|
614 // Determine the dragging axis |
|
615 if ( iDragAxis == EFMRadioDragAxisNone ) |
|
616 { |
|
617 TInt absX = Abs( delta.iX ); |
|
618 TInt absY = Abs( delta.iY ); |
|
619 if ( absX > absY ) |
|
620 { |
|
621 iDragAxis = EFMRadioDragAxisX; |
|
622 } |
|
623 else if ( absY > absX ) |
|
624 { |
|
625 iDragAxis = EFMRadioDragAxisY; |
|
626 } |
|
627 else |
|
628 { |
|
629 //X and Y are equal, can't determine the axis |
|
630 } |
|
631 } |
|
632 |
|
633 |
|
634 if ( iRevertGestureDrag && iDragAxis != EFMRadioDragAxisNone ) // gesture is ongoing, ok to move visual |
|
635 { |
|
636 TAlfRealPoint newPosition; |
|
637 newPosition.iX = iDragStartPosition.iX.ValueNow(); |
|
638 newPosition.iY = iDragStartPosition.iY.ValueNow(); |
|
639 |
|
640 if ( iDragAxis == EFMRadioDragAxisX ) |
|
641 { |
|
642 newPosition.iX += delta.iX; |
|
643 } |
|
644 else |
|
645 { |
|
646 newPosition.iY += delta.iY; |
|
647 } |
|
648 iStationInformationAnchorLayout->SetPos( newPosition ); |
|
649 } |
|
650 break; |
|
651 } |
|
652 case EGestureUnknown: |
|
653 case EGestureReleased: |
|
654 { |
|
655 if ( iRevertGestureDrag ) |
|
656 { |
|
657 RevertVisual( *iStationInformationAnchorLayout ); |
|
658 } |
|
659 break; |
|
660 } |
|
661 case EGestureHoldLeft: |
|
662 case EGestureHoldRight: |
|
663 case EGestureHoldUp: |
|
664 case EGestureHoldDown: |
|
665 { |
|
666 // gesture "timed out" |
|
667 if ( iRevertGestureDrag ) |
|
668 { |
|
669 // change revert status so that the following |
|
670 // EGestureDrag event doesn't change visual position |
|
671 // anymore |
|
672 iRevertGestureDrag = EFalse; |
|
673 RevertVisual( *iStationInformationAnchorLayout ); |
|
674 } |
|
675 break; |
|
676 } |
|
677 default: |
|
678 { |
|
679 break; |
|
680 } |
|
681 } |
|
682 } |
|
683 else |
|
684 { |
|
685 FTRACE(FPrint(_L("CFMRadioAlfVisualizer::HandleGestureL() call ongoing -> gestures ignored"))); |
|
686 } |
|
687 } |
|
688 // ---------------------------------------------------------------------------- |
|
689 // CFMRadioAlfVisualizer::OfferEventL |
|
690 // From CAlfControl, takes care of alfred event handling. |
|
691 // ---------------------------------------------------------------------------- |
|
692 // |
|
693 TBool CFMRadioAlfVisualizer::OfferEventL( const TAlfEvent& aEvent ) |
|
694 { |
|
695 if ( aEvent.IsKeyEvent() && AknLayoutUtils::PenEnabled() ) |
|
696 { |
|
697 const TKeyEvent& kEvent = aEvent.KeyEvent(); |
|
698 if ( kEvent.iScanCode == EStdKeyRightArrow || |
|
699 kEvent.iScanCode == EStdKeyLeftArrow || |
|
700 kEvent.iScanCode == EStdKeyUpArrow || |
|
701 kEvent.iScanCode == EStdKeyDownArrow ) |
|
702 { |
|
703 iKeyScanCode = kEvent.iScanCode; |
|
704 |
|
705 if ( aEvent.Code() == EEventKeyUp ) |
|
706 { |
|
707 iLongPressTimer->Cancel(); |
|
708 if ( !iLongKeyTriggered ) |
|
709 { |
|
710 TriggerCommandL(); |
|
711 } |
|
712 } |
|
713 else if ( aEvent.Code() == EEventKeyDown ) |
|
714 { |
|
715 iLongKeyTriggered = EFalse; |
|
716 // Start the long key press timer |
|
717 iLongPressTimer->Cancel(); |
|
718 iLongPressTimer->Start( KFMRadioRockerLongPressDelay, |
|
719 0, |
|
720 TCallBack( CFMRadioAlfVisualizer::StaticLongPressCallBack, this ) ); |
|
721 } |
|
722 return ETrue; |
|
723 } |
|
724 } |
|
725 if ( aEvent.IsPointerEvent() ) |
|
726 { |
|
727 CGestureControl::OfferEventL( aEvent ); |
|
728 } |
|
729 return EFalse; |
|
730 } |
|
731 |
|
732 // --------------------------------------------------------------------------- |
|
733 // Sets the display style in use. |
|
734 // --------------------------------------------------------------------------- |
|
735 // |
|
736 void CFMRadioAlfVisualizer::SetDisplayStyle( TFMRadioDisplayStyle aDisplayStyle ) |
|
737 { |
|
738 iDisplayStyle = aDisplayStyle; |
|
739 } |
|
740 |
|
741 // --------------------------------------------------------------------------- |
|
742 // Returns the display style. |
|
743 // --------------------------------------------------------------------------- |
|
744 // |
|
745 TFMRadioDisplayStyle CFMRadioAlfVisualizer::DisplayStyle() const |
|
746 { |
|
747 return iDisplayStyle; |
|
748 } |
|
749 |
|
750 // --------------------------------------------------------------------------- |
|
751 // CFMRadioAlfVisualizer::SetAbsoluteCornerAnchors |
|
752 // Sets absolute rect of the anchor by top left and bottom right points. |
|
753 // --------------------------------------------------------------------------- |
|
754 // |
|
755 void CFMRadioAlfVisualizer::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor, |
|
756 TInt aOrdinal, |
|
757 const TPoint& aTopLeftPosition, |
|
758 const TPoint& aBottomRightPosition ) |
|
759 { |
|
760 if ( aAnchor ) |
|
761 { |
|
762 // Set top/left anchor. |
|
763 aAnchor->Attach( aOrdinal, |
|
764 EAlfAnchorTypeTopLeft, |
|
765 TAlfXYMetric( TAlfMetric( aTopLeftPosition.iX ), TAlfMetric( aTopLeftPosition.iY ) ), |
|
766 EAlfAnchorAttachmentOriginTopLeft ); |
|
767 |
|
768 |
|
769 // Set bottom/right anchor. |
|
770 aAnchor->Attach( aOrdinal, |
|
771 EAlfAnchorTypeBottomRight, |
|
772 TAlfXYMetric( TAlfMetric( aBottomRightPosition.iX ), TAlfMetric( aBottomRightPosition.iY ) ), |
|
773 EAlfAnchorAttachmentOriginTopLeft ); |
|
774 } |
|
775 } |
|
776 |
|
777 // --------------------------------------------------------------------------- |
|
778 // CFMRadioAlfVisualizer::ScrollRightToLeftWithFadeIn |
|
779 // Sets and starts scrolling and fading animations to CAlfVisual. |
|
780 // --------------------------------------------------------------------------- |
|
781 // |
|
782 void CFMRadioAlfVisualizer::ScrollRightToLeftWithFadeIn( CAlfVisual& aVisual ) const |
|
783 { |
|
784 TInt visualWidthInDisplayCoord = aVisual.DisplayRect().Width(); |
|
785 |
|
786 TAlfTimedPoint targetPoint; |
|
787 targetPoint.iX.SetValueNow( visualWidthInDisplayCoord ); |
|
788 targetPoint.iX.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); |
|
789 aVisual.SetPos( targetPoint ); |
|
790 |
|
791 FadeIn( aVisual, KFMRadioStationInformationFadeDurationTime); |
|
792 } |
|
793 |
|
794 // --------------------------------------------------------------------------- |
|
795 // CFMRadioAlfVisualizer::ScrollLeftToRightWithFadeIn |
|
796 // Sets and starts scrolling and fading animations to CAlfVisual. |
|
797 // --------------------------------------------------------------------------- |
|
798 // |
|
799 void CFMRadioAlfVisualizer::ScrollLeftToRightWithFadeIn( CAlfVisual& aVisual ) const |
|
800 { |
|
801 TInt visualWidthInDisplayCoord = aVisual.DisplayRect().Width(); |
|
802 TAlfTimedPoint targetPoint; |
|
803 targetPoint.iX.SetValueNow( - visualWidthInDisplayCoord ); |
|
804 targetPoint.iX.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); |
|
805 aVisual.SetPos( targetPoint ); |
|
806 |
|
807 FadeIn( aVisual, KFMRadioStationInformationFadeDurationTime); |
|
808 } |
|
809 |
|
810 // --------------------------------------------------------------------------- |
|
811 // CFMRadioAlfVisualizer::ScrollInFromTop |
|
812 // Sets and starts scrolling and fading animations to CAlfVisual. |
|
813 // --------------------------------------------------------------------------- |
|
814 // |
|
815 void CFMRadioAlfVisualizer::ScrollInFromTop( CAlfVisual& aVisual ) const |
|
816 { |
|
817 TRect displayArea = Env().PrimaryDisplay().VisibleArea(); |
|
818 TAlfTimedPoint targetPoint; |
|
819 targetPoint.iY.SetValueNow( -displayArea.Height() ); |
|
820 targetPoint.iY.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); |
|
821 aVisual.SetPos( targetPoint ); |
|
822 |
|
823 FadeIn( aVisual, KFMRadioStationInformationFadeDurationTime); |
|
824 } |
|
825 |
|
826 // --------------------------------------------------------------------------- |
|
827 // CFMRadioAlfVisualizer::ScrollInFromBottom |
|
828 // Sets and starts scrolling and fading animations to CAlfVisual. |
|
829 // --------------------------------------------------------------------------- |
|
830 // |
|
831 void CFMRadioAlfVisualizer::ScrollInFromBottom( CAlfVisual& aVisual ) const |
|
832 { |
|
833 TRect displayArea = Env().PrimaryDisplay().VisibleArea(); |
|
834 TAlfTimedPoint targetPoint; |
|
835 targetPoint.iY.SetValueNow( displayArea.Height() ); |
|
836 targetPoint.iY.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); |
|
837 aVisual.SetPos( targetPoint ); |
|
838 |
|
839 FadeIn( aVisual, KFMRadioStationInformationFadeDurationTime); |
|
840 } |
|
841 |
|
842 // --------------------------------------------------------------------------- |
|
843 // CFMRadioAlfVisualizer::RevertVisual |
|
844 // Reverts the visual to the origin |
|
845 // --------------------------------------------------------------------------- |
|
846 // |
|
847 void CFMRadioAlfVisualizer::RevertVisual( CAlfVisual& aVisual ) |
|
848 { |
|
849 TAlfTimedPoint targetPoint; |
|
850 targetPoint.iX.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); |
|
851 targetPoint.iY.SetTarget( 0, KFMRadioStationInformationScrollDurationTime ); |
|
852 aVisual.SetPos( targetPoint ); |
|
853 TAlfTimedValue opacity; |
|
854 opacity.SetTarget( 1.0f, KFMRadioStationInformationFadeDurationTime ); |
|
855 aVisual.SetOpacity( opacity ); |
|
856 } |
|
857 |
|
858 // ---------------------------------------------------------------------------- |
|
859 // CFMRadioAlfVisualizer::ScrollToLeft |
|
860 // Sets and starts scrolling animation to CAlfVisual. |
|
861 // The visual object is scrolled from current position to |
|
862 // left side of the display |
|
863 // ---------------------------------------------------------------------------- |
|
864 // |
|
865 void CFMRadioAlfVisualizer::ScrollToLeft( CAlfVisual& aVisual, TInt aTime ) const |
|
866 { |
|
867 TInt visualWidth = aVisual.DisplayRect().Width(); |
|
868 TAlfTimedPoint timedPosition = aVisual.Pos(); |
|
869 TAlfRealPoint positionLeft( - ( visualWidth ), timedPosition.iY.ValueNow() ); |
|
870 aVisual.SetPos( positionLeft, aTime ); |
|
871 } |
|
872 |
|
873 // ---------------------------------------------------------------------------- |
|
874 // CFMRadioAlfVisualizer::ScrollToRight |
|
875 // Sets and starts scrolling animation to CAlfVisual. |
|
876 // The visual object is scrolled from current position to |
|
877 // right side of the display |
|
878 // ---------------------------------------------------------------------------- |
|
879 // |
|
880 void CFMRadioAlfVisualizer::ScrollToRight( CAlfVisual& aVisual, TInt aTime ) const |
|
881 { |
|
882 TRect displayArea = Env().PrimaryDisplay().VisibleArea(); |
|
883 TAlfTimedPoint timedPosition = aVisual.Pos(); |
|
884 TAlfRealPoint positionRight( displayArea.Width(), timedPosition.iY.ValueNow() ); |
|
885 |
|
886 aVisual.SetPos( positionRight, aTime ); |
|
887 } |
|
888 |
|
889 // ---------------------------------------------------------------------------- |
|
890 // CFMRadioAlfVisualizer::ScrollUp |
|
891 // Sets and starts scrolling animation to CAlfVisual. |
|
892 // The visual object is scrolled up |
|
893 // ---------------------------------------------------------------------------- |
|
894 // |
|
895 void CFMRadioAlfVisualizer::ScrollUp( CAlfVisual& aVisual, TInt aTime ) const |
|
896 { |
|
897 TInt visualHeight = aVisual.DisplayRect().Height(); |
|
898 TAlfTimedPoint timedPosition = aVisual.Pos(); |
|
899 TAlfRealPoint positionUp( timedPosition.iX.ValueNow(), -visualHeight ); |
|
900 aVisual.SetPos( positionUp, aTime ); |
|
901 } |
|
902 |
|
903 // ---------------------------------------------------------------------------- |
|
904 // CFMRadioAlfVisualizer::ScrollDown |
|
905 // Sets and starts scrolling animation to CAlfVisual. |
|
906 // The visual object is scrolled down |
|
907 // ---------------------------------------------------------------------------- |
|
908 // |
|
909 void CFMRadioAlfVisualizer::ScrollDown( CAlfVisual& aVisual, TInt aTime ) const |
|
910 { |
|
911 TRect displayArea = Env().PrimaryDisplay().VisibleArea(); |
|
912 TAlfTimedPoint timedPosition = aVisual.Pos(); |
|
913 TAlfRealPoint positionDown( timedPosition.iX.ValueNow(), displayArea.Height() ); |
|
914 aVisual.SetPos( positionDown, aTime ); |
|
915 } |
|
916 |
|
917 // --------------------------------------------------------------------------- |
|
918 // CFMRadioAlfVisualizer::FadeIn |
|
919 // Sets fading in animation to CAlfVisual. |
|
920 // --------------------------------------------------------------------------- |
|
921 // |
|
922 void CFMRadioAlfVisualizer::FadeIn( CAlfVisual& aVisual, TInt aTime, TReal aOpacity ) const |
|
923 { |
|
924 TAlfTimedValue opacity; |
|
925 opacity.SetValueNow( 0.0f ); // immediate change |
|
926 opacity.SetTarget( aOpacity, aTime ); // and smooth target |
|
927 aVisual.SetOpacity( opacity ); |
|
928 } |
|
929 |
|
930 // --------------------------------------------------------------------------- |
|
931 // CFMRadioAlfVisualizer::FadeOut |
|
932 // Sets fading out animation to CAlfVisual. |
|
933 // --------------------------------------------------------------------------- |
|
934 // |
|
935 void CFMRadioAlfVisualizer::FadeOut( CAlfVisual& aVisual, TInt aTime, TReal aOpacity ) const |
|
936 { |
|
937 TAlfTimedValue opacity; |
|
938 opacity.SetTarget( aOpacity, aTime ); |
|
939 aVisual.SetOpacity( opacity ); |
|
940 } |
|
941 |
|
942 // --------------------------------------------------------------------------- |
|
943 // CFMRadioAlfVisualizer::ChangeStationL |
|
944 // Changes station to next with scrolling and fading station's |
|
945 // information (name, frequency, etc.). |
|
946 // --------------------------------------------------------------------------- |
|
947 // |
|
948 void CFMRadioAlfVisualizer::ChangeStationL( TFMRadioStationChangeType aChangeType, |
|
949 const TDesC& aFirstLine, |
|
950 const TDesC* aSecondLine ) |
|
951 { |
|
952 const TDesC& secondLine = aSecondLine ? *aSecondLine : KNullDesC; |
|
953 TBool firstLineFade = iFirstLineVisualText->Text() != aFirstLine; |
|
954 TBool secondLineFade = iSecondLineVisualText->Text() != secondLine; |
|
955 |
|
956 if ( aChangeType != EFMRadioStationChangeNone || firstLineFade || secondLineFade ) |
|
957 { |
|
958 Env().CancelCommands( iFirstLineVisualText ); |
|
959 Env().CancelCommands( iSecondLineVisualText ); |
|
960 |
|
961 if ( secondLine.Length() ) |
|
962 { |
|
963 SetDisplayStyle( EFMRadioDisplayDoubleLine ); |
|
964 } |
|
965 else |
|
966 { |
|
967 SetDisplayStyle( EFMRadioDisplaySingleLine ); |
|
968 } |
|
969 |
|
970 FadeOut( *iTuningVisualText, 0 ); |
|
971 LoadTextVisualIdentity( iFirstLineVisualText ); |
|
972 LoadTextVisualIdentity( iSecondLineVisualText ); |
|
973 iFirstLineVisualText->SetTextL( aFirstLine ); |
|
974 iSecondLineVisualText->SetTextL( secondLine ); |
|
975 UpdateLayout(); |
|
976 |
|
977 // Set the horizontal animation |
|
978 switch ( aChangeType ) |
|
979 { |
|
980 case EFMRadioStationChangePrevious: |
|
981 { |
|
982 // Direction of the animation is left to right |
|
983 ShowVisual( EFirstLineTextVisual, 0 ); |
|
984 ShowVisual( ESecondLineTextVisual, 0 ); |
|
985 ScrollLeftToRightWithFadeIn( *iStationInformationAnchorLayout ); |
|
986 } |
|
987 break; |
|
988 case EFMRadioStationChangeNext: |
|
989 { |
|
990 // Direction of the animation is right to left |
|
991 ShowVisual( EFirstLineTextVisual, 0 ); |
|
992 ShowVisual( ESecondLineTextVisual, 0 ); |
|
993 ScrollRightToLeftWithFadeIn( *iStationInformationAnchorLayout ); |
|
994 } |
|
995 break; |
|
996 case EFMRadioStationChangeScanUp: |
|
997 { |
|
998 ShowVisual( EFirstLineTextVisual, 0 ); |
|
999 ShowVisual( ESecondLineTextVisual, 0 ); |
|
1000 ScrollInFromBottom( *iStationInformationAnchorLayout ); |
|
1001 } |
|
1002 break; |
|
1003 case EFMRadioStationChangeScanDown: |
|
1004 { |
|
1005 ShowVisual( EFirstLineTextVisual, 0 ); |
|
1006 ShowVisual( ESecondLineTextVisual, 0 ); |
|
1007 ScrollInFromTop( *iStationInformationAnchorLayout ); |
|
1008 } |
|
1009 break; |
|
1010 case EFMRadioStationChangeNone: |
|
1011 { |
|
1012 ShowVisual( EFirstLineTextVisual, firstLineFade ); |
|
1013 ShowVisual( ESecondLineTextVisual, secondLineFade ); |
|
1014 } |
|
1015 break; |
|
1016 default: |
|
1017 break; |
|
1018 } |
|
1019 } |
|
1020 } |
|
1021 |
|
1022 // --------------------------------------------------------------------------- |
|
1023 // CFMRadioAlfVisualizer::SetStaticInfoTextL |
|
1024 // Resets the station information and sets static text to the third line. |
|
1025 // --------------------------------------------------------------------------- |
|
1026 // |
|
1027 void CFMRadioAlfVisualizer::SetStaticInfoTextL( TFMRadioStationChangeType aChangeType, const TDesC& aInfoText ) |
|
1028 { |
|
1029 ScrollOutCurrentStationInformationL( aChangeType ); |
|
1030 SetVisualTextL( ETuningTextVisual, aInfoText ); |
|
1031 UpdateLayout(); |
|
1032 ShowVisual( ETuningTextVisual, ETrue ); |
|
1033 // Make the new station info visible |
|
1034 FadeIn( *iStationInformationAnchorLayout, 0 ); |
|
1035 } |
|
1036 |
|
1037 // ---------------------------------------------------------------------------- |
|
1038 // CFMRadioAlfVisualizer::Translate |
|
1039 // Translates the visual object with passed arguments |
|
1040 // ---------------------------------------------------------------------------- |
|
1041 // |
|
1042 void CFMRadioAlfVisualizer::Translate( CAlfTextVisual* aTextVisual, const TAlfTimedValue& aX, const TAlfTimedValue& aY ) |
|
1043 { |
|
1044 if( aTextVisual ) |
|
1045 { |
|
1046 TRAPD( err, aTextVisual->EnableTransformationL( ETrue ) ); |
|
1047 if( err == KErrNone ) |
|
1048 { |
|
1049 CAlfTransformation* visualTransformation = &( aTextVisual->Transformation() ); |
|
1050 TAlfTimedValue x(aX); |
|
1051 x.SetStyle( EAlfTimedValueStyleLinear ); |
|
1052 |
|
1053 TAlfTimedValue y(aY); |
|
1054 y.SetStyle( EAlfTimedValueStyleLinear ); |
|
1055 |
|
1056 visualTransformation->Translate( x, y ); |
|
1057 } |
|
1058 } |
|
1059 } |
|
1060 |
|
1061 // --------------------------------------------------------------------------- |
|
1062 // Triggers the command to view handling |
|
1063 // --------------------------------------------------------------------------- |
|
1064 // |
|
1065 void CFMRadioAlfVisualizer::TriggerCommandL() |
|
1066 { |
|
1067 TVwsViewId viewId( KNullUid, KNullUid ); |
|
1068 CAknViewAppUi* appUi = static_cast<CAknViewAppUi*>( CCoeEnv::Static()->AppUi() ); |
|
1069 TInt err = appUi->GetActiveViewId( viewId ); |
|
1070 RProcess process; |
|
1071 TSecureId id = process.SecureId(); |
|
1072 |
|
1073 if ( !err && viewId.iAppUid.iUid == id.iId ) |
|
1074 { |
|
1075 CAknView* view = appUi->View( viewId.iViewUid ); |
|
1076 if ( view ) |
|
1077 { |
|
1078 // command to be generated |
|
1079 TInt commandId = 0; |
|
1080 |
|
1081 switch ( iKeyScanCode ) |
|
1082 { |
|
1083 case EStdKeyLeftArrow: |
|
1084 { |
|
1085 if ( iLongKeyTriggered ) |
|
1086 { |
|
1087 commandId = EFMRadioRockerButtonKeyLeftLong; |
|
1088 break; |
|
1089 } |
|
1090 else |
|
1091 { |
|
1092 commandId = EFMRadioRockerButtonKeyLeft; |
|
1093 } |
|
1094 break; |
|
1095 } |
|
1096 case EStdKeyRightArrow: |
|
1097 { |
|
1098 if ( iLongKeyTriggered ) |
|
1099 { |
|
1100 commandId = EFMRadioRockerButtonKeyRightLong; |
|
1101 } |
|
1102 else |
|
1103 { |
|
1104 commandId = EFMRadioRockerButtonKeyRight; |
|
1105 } |
|
1106 break; |
|
1107 } |
|
1108 case EStdKeyUpArrow: |
|
1109 { |
|
1110 commandId = EFMRadioRockerButtonKeyUp; |
|
1111 break; |
|
1112 } |
|
1113 case EStdKeyDownArrow: |
|
1114 { |
|
1115 commandId = EFMRadioRockerButtonKeyDown; |
|
1116 break; |
|
1117 } |
|
1118 } |
|
1119 // send command to view |
|
1120 view->ProcessCommandL( commandId ); |
|
1121 } |
|
1122 } |
|
1123 } |
|
1124 |
|
1125 // --------------------------------------------------------------------------- |
|
1126 // Callback that is invoked when a long key press has occurred. |
|
1127 // --------------------------------------------------------------------------- |
|
1128 // |
|
1129 TInt CFMRadioAlfVisualizer::StaticLongPressCallBack( TAny* aSelf ) |
|
1130 { |
|
1131 CFMRadioAlfVisualizer* self = static_cast<CFMRadioAlfVisualizer*>( aSelf ); |
|
1132 if ( self ) |
|
1133 { |
|
1134 self->iLongPressTimer->Cancel(); |
|
1135 self->iLongKeyTriggered = ETrue; |
|
1136 |
|
1137 TRAP_IGNORE( self->TriggerCommandL() ) |
|
1138 } |
|
1139 return KErrNone; |
|
1140 } |
|
1141 |
|
1142 // ---------------------------------------------------------------------------- |
|
1143 // CFMRadioAlfVisualizer::LoadTextVisualIdentity |
|
1144 // Removes all transformations of the visual object such as the scaling and translating. |
|
1145 // ---------------------------------------------------------------------------- |
|
1146 // |
|
1147 void CFMRadioAlfVisualizer::LoadTextVisualIdentity( CAlfTextVisual* aTextVisual ) |
|
1148 { |
|
1149 if( aTextVisual ) |
|
1150 { |
|
1151 TRAPD( err, aTextVisual->EnableTransformationL( ETrue ) ); |
|
1152 if( err == KErrNone ) |
|
1153 { |
|
1154 CAlfTransformation* visualTransformation = &( aTextVisual->Transformation() ); |
|
1155 visualTransformation->LoadIdentity(); |
|
1156 } |
|
1157 } |
|
1158 } |
|
1159 |
|
1160 // ---------------------------------------------------------------------------- |
|
1161 // CFMRadioAlfVisualizer::StartTuningAnimation |
|
1162 // Starts tuning animation after delay |
|
1163 // ---------------------------------------------------------------------------- |
|
1164 // |
|
1165 void CFMRadioAlfVisualizer::StartTuningAnimation() |
|
1166 { |
|
1167 iBmpAnimation->StartBmpAnimation(); |
|
1168 } |
|
1169 |
|
1170 // ---------------------------------------------------------------------------- |
|
1171 // CFMRadioAlfVisualizer::StopTuningAnimation |
|
1172 // Stops tuning animation by fading it away |
|
1173 // ---------------------------------------------------------------------------- |
|
1174 // |
|
1175 void CFMRadioAlfVisualizer::StopTuningAnimation() |
|
1176 { |
|
1177 iBmpAnimation->StopBmpAnimation(); |
|
1178 } |
|
1179 |
|
1180 // End of File |
|
1181 |