20
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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 CFMRadioLogo
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
|
|
21 |
#include <AknUtils.h>
|
|
22 |
#include <AknsConstants.h>
|
|
23 |
#include <alf/alfenv.h>
|
|
24 |
#include <alf/alfimagevisual.h>
|
|
25 |
#include <alf/alfevent.h>
|
|
26 |
#include <alf/alfanchorlayout.h>
|
|
27 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
28 |
#include <data_caging_path_literals.hrh>
|
|
29 |
#include <fmradio.mbg>
|
|
30 |
|
|
31 |
#include "fmradiologo.h"
|
|
32 |
#include "fmradioalfrdsviewobserver.h"
|
|
33 |
#include "fmradiodefines.h"
|
|
34 |
#include "debug.h"
|
|
35 |
#include "fmradiologoobserver.h"
|
|
36 |
|
|
37 |
// CONSTANTS
|
|
38 |
|
|
39 |
const TInt KLogoFadeInDefaultDurationTime = 500;
|
|
40 |
const TInt KLogoFadeOutDefaultDurationTime = 500;
|
|
41 |
const TInt KLogoDisplayPeriod = 2000; // milliseconds = 2 sec
|
|
42 |
const TReal KDefaultOpacityInVisibleState = 1.0f;
|
|
43 |
const TReal KDefaultOpacityInHiddenState = 0.0f;
|
|
44 |
const TInt KLAFVarietyBackgroundImagePortrait = 0;
|
|
45 |
const TInt KLAFVarietyBackgroundImageLandscape = 1;
|
|
46 |
// bitmap file for the background of the display
|
|
47 |
_LIT8( KBitmapAnchorTag, "BitmapAnchorTag" );
|
|
48 |
|
|
49 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
50 |
|
|
51 |
// ---------------------------------------------------------------------------
|
|
52 |
// CFMRadioLogo::NewL
|
|
53 |
// Two-phase constructor of CFMRadioAlfLogo
|
|
54 |
// ---------------------------------------------------------------------------
|
|
55 |
//
|
|
56 |
CFMRadioLogo* CFMRadioLogo::NewL( CAlfEnv& aEnv )
|
|
57 |
{
|
|
58 |
CFMRadioLogo* self = new ( ELeave ) CFMRadioLogo();
|
|
59 |
CleanupStack::PushL( self );
|
|
60 |
self->ConstructL( aEnv );
|
|
61 |
CleanupStack::Pop( self );
|
|
62 |
return self;
|
|
63 |
}
|
|
64 |
|
|
65 |
// ----------------------------------------------------------------------------
|
|
66 |
// CFMRadioLogo::CFMRadioLogo
|
|
67 |
// Default constructor
|
|
68 |
// ----------------------------------------------------------------------------
|
|
69 |
//
|
|
70 |
CFMRadioLogo::CFMRadioLogo()
|
|
71 |
: iOpacityInVisibleState( KDefaultOpacityInVisibleState ),
|
|
72 |
iOpacityInHiddenState( KDefaultOpacityInHiddenState ),
|
|
73 |
iIsVisible( ETrue ) // visible by default
|
|
74 |
{
|
|
75 |
//No implementation needed
|
|
76 |
}
|
|
77 |
|
|
78 |
|
|
79 |
// ----------------------------------------------------------------------------
|
|
80 |
// CFMRadioLogo::SetObserver
|
|
81 |
// Sets observer
|
|
82 |
// ----------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
void CFMRadioLogo::SetObserver( MFMRadioLogoObserver* aObserver )
|
|
85 |
{
|
|
86 |
FTRACE( FPrint( _L( "CFMRadioLogo::SetObserver" ) ) );
|
|
87 |
TInt index = iObservers.FindInAddressOrder( aObserver );
|
|
88 |
if ( index == KErrNotFound )
|
|
89 |
{
|
|
90 |
iObservers.InsertInAddressOrder( aObserver );
|
|
91 |
}
|
|
92 |
}
|
|
93 |
|
|
94 |
// ----------------------------------------------------------------------------
|
|
95 |
// CFMRadioLogo::RemoveObserver
|
|
96 |
// Removes observer
|
|
97 |
// ----------------------------------------------------------------------------
|
|
98 |
//
|
|
99 |
void CFMRadioLogo::RemoveObserver( MFMRadioLogoObserver* aObserver )
|
|
100 |
{
|
|
101 |
FTRACE( FPrint( _L( "CFMRadioLogo::RemoveObserver" ) ) );
|
|
102 |
TInt index = iObservers.FindInAddressOrder( aObserver );
|
|
103 |
|
|
104 |
if ( index >= 0 )
|
|
105 |
{
|
|
106 |
iObservers.Remove( index );
|
|
107 |
}
|
|
108 |
}
|
|
109 |
|
|
110 |
// ----------------------------------------------------------------------------
|
|
111 |
// CFMRadioLogo::ConstructL
|
|
112 |
// Symbian 2nd phase constructor can leave.
|
|
113 |
// ----------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
void CFMRadioLogo::ConstructL( CAlfEnv& aEnv )
|
|
116 |
{
|
|
117 |
FTRACE( FPrint( _L( "CFMRadioLogo::ConstructL" ) ) );
|
|
118 |
CAlfControl::ConstructL( aEnv );
|
|
119 |
CreateImageVisualsL();
|
|
120 |
}
|
|
121 |
|
|
122 |
// ---------------------------------------------------------------------------
|
|
123 |
// ~CFMRadioLogo::~CFMRadioLogo
|
|
124 |
// Destructor
|
|
125 |
// ---------------------------------------------------------------------------
|
|
126 |
//
|
|
127 |
CFMRadioLogo::~CFMRadioLogo()
|
|
128 |
{
|
|
129 |
FTRACE( FPrint( _L( "CFMRadioLogo::Destructor" ) ) );
|
|
130 |
Env().CancelCustomCommands( this );
|
|
131 |
iObservers.Close();
|
|
132 |
delete iBackgroundBitmapFileName;
|
|
133 |
}
|
|
134 |
|
|
135 |
// ---------------------------------------------------------------------------
|
|
136 |
// CFMRadioLogo::OfferEventL
|
|
137 |
// From CAlfControl, takes care of alfred event handling.
|
|
138 |
// ---------------------------------------------------------------------------
|
|
139 |
//
|
|
140 |
TBool CFMRadioLogo::OfferEventL( const TAlfEvent& aEvent )
|
|
141 |
{
|
|
142 |
FTRACE( FPrint( _L( "CFMRadioLogo::OfferEventL" ) ) );
|
|
143 |
TBool eventHandled = EFalse;
|
|
144 |
|
|
145 |
if ( aEvent.IsCustomEvent() )
|
|
146 |
{
|
|
147 |
switch( aEvent.CustomParameter() )
|
|
148 |
{
|
|
149 |
case EFadeInCompleted:
|
|
150 |
{
|
|
151 |
eventHandled = ETrue;
|
|
152 |
Env().Send( TAlfCustomEventCommand( ELogoDisplayTimerCompleted, this ), KLogoDisplayPeriod );
|
|
153 |
break;
|
|
154 |
}
|
|
155 |
case ELogoDisplayTimerCompleted:
|
|
156 |
{
|
|
157 |
eventHandled = ETrue;
|
|
158 |
for ( TInt i = 0 ; i < iObservers.Count() ; i++ )
|
|
159 |
{
|
|
160 |
iObservers[i]->LogoDisplayTimeCompleted();
|
|
161 |
}
|
|
162 |
break;
|
|
163 |
}
|
|
164 |
default:
|
|
165 |
{
|
|
166 |
break;
|
|
167 |
}
|
|
168 |
}
|
|
169 |
}
|
|
170 |
return eventHandled;
|
|
171 |
}
|
|
172 |
|
|
173 |
// ---------------------------------------------------------------------------
|
|
174 |
// CFMRadioLogo::SetRect
|
|
175 |
// Sets the logo rectangle.
|
|
176 |
// ---------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
void CFMRadioLogo::SetRect( const TRect& aRect )
|
|
179 |
{
|
|
180 |
iRect = aRect;
|
|
181 |
if ( iLogoAnchor )
|
|
182 |
{
|
|
183 |
SetAbsoluteCornerAnchors( iLogoAnchor, 0, iRect.iTl, iRect.iBr );
|
|
184 |
iLogoAnchor->UpdateChildrenLayout();
|
|
185 |
}
|
|
186 |
}
|
|
187 |
|
|
188 |
// ---------------------------------------------------------------------------
|
|
189 |
// CFMRadioLogo::CreateImageVisualsL
|
|
190 |
// Creates visual for the logo
|
|
191 |
// ---------------------------------------------------------------------------
|
|
192 |
//
|
|
193 |
void CFMRadioLogo::CreateImageVisualsL()
|
|
194 |
{
|
|
195 |
// locate source mbm
|
|
196 |
CCoeEnv* coeEnv = CCoeEnv::Static();
|
|
197 |
TFindFile finder( coeEnv->FsSession() );
|
|
198 |
TInt err = finder.FindByDir( KFMRadioBmpFile, KDC_APP_BITMAP_DIR );
|
|
199 |
if ( err == KErrNone )
|
|
200 |
{
|
|
201 |
iBackgroundBitmapFileName = finder.File().AllocL();
|
|
202 |
}
|
|
203 |
|
|
204 |
iLogoAnchor = CAlfAnchorLayout::AddNewL( *this );
|
|
205 |
iLogoAnchor->SetTagL( KBitmapAnchorTag );
|
|
206 |
|
|
207 |
iImageVisual = CAlfImageVisual::AddNewL( *this, iLogoAnchor );
|
|
208 |
|
|
209 |
// read bitmap size from layout data
|
|
210 |
TRect temp;
|
|
211 |
TAknLayoutRect bitmapLayout;
|
|
212 |
bitmapLayout.LayoutRect(
|
|
213 |
temp,
|
|
214 |
AknLayoutScalable_Apps::area_fmrd2_visual_pane_g1( KLAFVarietyBackgroundImagePortrait ).LayoutLine() );
|
|
215 |
|
|
216 |
// image for portrait
|
|
217 |
iPortraitImage = TAlfImage( KAknsIIDQgnIndiRadioDefault,
|
|
218 |
bitmapLayout.Rect().Size(),
|
|
219 |
EAspectRatioPreserved,
|
|
220 |
iBackgroundBitmapFileName,
|
|
221 |
EMbmFmradioQgn_indi_radio_default,
|
|
222 |
EMbmFmradioQgn_indi_radio_default_mask );
|
|
223 |
|
|
224 |
// image for landscape
|
|
225 |
bitmapLayout.LayoutRect(
|
|
226 |
temp,
|
|
227 |
AknLayoutScalable_Apps::area_fmrd2_visual_pane_g1( KLAFVarietyBackgroundImageLandscape ).LayoutLine() );
|
|
228 |
|
|
229 |
iLandscapeImage = TAlfImage( KAknsIIDQgnIndiRadioDefault,
|
|
230 |
bitmapLayout.Rect().Size(),
|
|
231 |
EAspectRatioPreserved,
|
|
232 |
iBackgroundBitmapFileName,
|
|
233 |
EMbmFmradioQgn_indi_radio_default,
|
|
234 |
EMbmFmradioQgn_indi_radio_default_mask );
|
|
235 |
|
|
236 |
iImageVisual->SetImage( iPortraitImage );
|
|
237 |
iImageVisual->SetSecondaryImage( iLandscapeImage );
|
|
238 |
}
|
|
239 |
|
|
240 |
// ---------------------------------------------------------
|
|
241 |
// CFMRadioLogo::Show
|
|
242 |
// Fades in the logo with predefined opacity value.
|
|
243 |
// ---------------------------------------------------------
|
|
244 |
//
|
|
245 |
void CFMRadioLogo::Show()
|
|
246 |
{
|
|
247 |
// change status only, fade in and the event are allways triggered so don't
|
|
248 |
// check visibility here
|
|
249 |
iIsVisible = ETrue;
|
|
250 |
Env().CancelCustomCommands( this );
|
|
251 |
Fade( iImageVisual, KLogoFadeInDefaultDurationTime, iOpacityInVisibleState );
|
|
252 |
Env().Send( TAlfCustomEventCommand( EFadeInCompleted, this ), KLogoFadeInDefaultDurationTime );
|
|
253 |
}
|
|
254 |
|
|
255 |
// ---------------------------------------------------------
|
|
256 |
// CFMRadioLogo::Hide
|
|
257 |
// Fades out the logo with predefined opacity value.
|
|
258 |
// ---------------------------------------------------------
|
|
259 |
//
|
|
260 |
void CFMRadioLogo::Hide()
|
|
261 |
{
|
|
262 |
if ( iIsVisible )
|
|
263 |
{
|
|
264 |
iIsVisible = EFalse;
|
|
265 |
Fade( iImageVisual, KLogoFadeOutDefaultDurationTime, iOpacityInHiddenState );
|
|
266 |
}
|
|
267 |
}
|
|
268 |
|
|
269 |
// ---------------------------------------------------------------------------
|
|
270 |
// CFMRadioLogo::SetOpacityInVisibleState
|
|
271 |
// Sets the indicator opacity in visible state.
|
|
272 |
// ---------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
void CFMRadioLogo::SetOpacityInVisibleState( const TReal aOpacity )
|
|
275 |
{
|
|
276 |
iOpacityInVisibleState = aOpacity;
|
|
277 |
}
|
|
278 |
|
|
279 |
// ---------------------------------------------------------------------------
|
|
280 |
// CFMRadioLogo::SetOpacityInHiddenState
|
|
281 |
// Sets the logo opacity value in hidden state.
|
|
282 |
// ---------------------------------------------------------------------------
|
|
283 |
//
|
|
284 |
void CFMRadioLogo::SetOpacityInHiddenState( const TReal aOpacity )
|
|
285 |
{
|
|
286 |
iOpacityInHiddenState = aOpacity;
|
|
287 |
}
|
|
288 |
|
|
289 |
// ---------------------------------------------------------------------------
|
|
290 |
// CFMRadioLogo::SetAbsoluteCornerAnchors
|
|
291 |
// Sets absolute rect of the anchor by top left and bottom right points.
|
|
292 |
// ---------------------------------------------------------------------------
|
|
293 |
//
|
|
294 |
void CFMRadioLogo::SetAbsoluteCornerAnchors( CAlfAnchorLayout* aAnchor,
|
|
295 |
TInt aOrdinal,
|
|
296 |
const TPoint& aTopLeftPosition,
|
|
297 |
const TPoint& aBottomRightPosition )
|
|
298 |
{
|
|
299 |
if ( aAnchor )
|
|
300 |
{
|
|
301 |
// Set top/left anchor.
|
|
302 |
aAnchor->Attach( aOrdinal,
|
|
303 |
EAlfAnchorTypeTopLeft,
|
|
304 |
TAlfXYMetric( TAlfMetric( aTopLeftPosition.iX ), TAlfMetric( aTopLeftPosition.iY ) ),
|
|
305 |
EAlfAnchorAttachmentOriginTopLeft );
|
|
306 |
|
|
307 |
|
|
308 |
// Set bottom/right anchor.
|
|
309 |
aAnchor->Attach( aOrdinal,
|
|
310 |
EAlfAnchorTypeBottomRight,
|
|
311 |
TAlfXYMetric( TAlfMetric( aBottomRightPosition.iX ), TAlfMetric( aBottomRightPosition.iY ) ),
|
|
312 |
EAlfAnchorAttachmentOriginTopLeft );
|
|
313 |
}
|
|
314 |
}
|
|
315 |
|
|
316 |
// ---------------------------------------------------------------------------
|
|
317 |
// CFMRadioLogo::Fade
|
|
318 |
// Sets the fading animation to the CAlfVisual object.
|
|
319 |
// ---------------------------------------------------------------------------
|
|
320 |
//
|
|
321 |
void CFMRadioLogo::Fade( CAlfVisual* aVisual, TInt aFadingTime, TReal aOpacity )
|
|
322 |
{
|
|
323 |
TAlfTimedValue opacity;
|
|
324 |
opacity.SetTarget( aOpacity, aFadingTime );
|
|
325 |
aVisual->SetOpacity( opacity );
|
|
326 |
}
|
|
327 |
|
|
328 |
// ---------------------------------------------------------------------------
|
|
329 |
// CFMRadioLogo::SwitchToLandscapeImage
|
|
330 |
// Use secondary image for landscape and primary for portrait
|
|
331 |
// ---------------------------------------------------------------------------
|
|
332 |
//
|
|
333 |
void CFMRadioLogo::SwitchToLandscapeImage( TBool aShow )
|
|
334 |
{
|
|
335 |
if ( aShow )
|
|
336 |
{
|
|
337 |
iImageVisual->SetSecondaryAlpha( TAlfTimedValue( 1.0 ) );
|
|
338 |
}
|
|
339 |
else
|
|
340 |
{
|
|
341 |
iImageVisual->SetSecondaryAlpha( TAlfTimedValue( 0.0 ) );
|
|
342 |
}
|
|
343 |
}
|
|
344 |
|
|
345 |
// ---------------------------------------------------------------------------
|
|
346 |
// CFMRadioLogo::Deactivate
|
|
347 |
// from MFMRadioIdleControlInterface
|
|
348 |
// ---------------------------------------------------------------------------
|
|
349 |
//
|
|
350 |
void CFMRadioLogo::Deactivate()
|
|
351 |
{
|
|
352 |
}
|
|
353 |
|
|
354 |
// End of File
|