60
|
1 |
/*
|
|
2 |
* Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
* All rights reserved.
|
|
4 |
* This component and the accompanying materials are made available
|
|
5 |
* under the terms of "Eclipse Public License v1.0"
|
|
6 |
* which accompanies this distribution, and is available
|
|
7 |
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
8 |
*
|
|
9 |
* Initial Contributors:
|
|
10 |
* Nokia Corporation - initial contribution.
|
|
11 |
*
|
|
12 |
* Contributors:
|
|
13 |
*
|
|
14 |
* Description: Header file for crossfade effect
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// Include Files
|
|
22 |
#include "shwcrossfadeeffect.h"
|
|
23 |
|
|
24 |
#include <glxsetvaluelayout.h>
|
|
25 |
#include <glxlog.h>
|
|
26 |
#include <glxtracer.h>
|
|
27 |
|
|
28 |
#include "shwcrossfadelayout.h"
|
|
29 |
#include "shwresourceutility.h"
|
|
30 |
#include "shwconstants.h"
|
|
31 |
|
|
32 |
using namespace NShwSlideshow;
|
|
33 |
|
|
34 |
/**
|
|
35 |
* CShwCrossFadeEffectImpl
|
|
36 |
* Crossfade dependencies
|
|
37 |
* This class makes our clients indepandant of the effect implementation
|
|
38 |
* This gives greater flexibitily in testing as the test suites can just
|
|
39 |
* re-implement all the methods in the real class interface without the
|
|
40 |
* need to stub all our dependencies.
|
|
41 |
* If for example TShwCrossFadeLayout was a direct member of
|
|
42 |
* CShwCrossFadeEffect class, all the clients would need to have access
|
|
43 |
* to TShwCrossFadeLayout constructor and destructor and the test suite
|
|
44 |
* would need to either create a stub implementation for it or include
|
|
45 |
* the real class in the test (and all its dependencies).
|
|
46 |
*
|
|
47 |
* There is however no point of duplicating the whole CShwCrossFadeEffect
|
|
48 |
* interface as it would mean double maintenance
|
|
49 |
* so we use the iImpl pointer when referencing the class members
|
|
50 |
*/
|
|
51 |
NONSHARABLE_CLASS( CShwCrossFadeEffect::CShwCrossFadeEffectImpl )
|
|
52 |
: public CBase
|
|
53 |
{
|
|
54 |
public:
|
|
55 |
|
|
56 |
/**
|
|
57 |
* Constructor
|
|
58 |
*/
|
|
59 |
CShwCrossFadeEffectImpl();
|
|
60 |
|
|
61 |
/**
|
|
62 |
* Destructor
|
|
63 |
*/
|
|
64 |
~CShwCrossFadeEffectImpl();
|
|
65 |
|
|
66 |
public:
|
|
67 |
|
|
68 |
/// Own: the size of the screen
|
|
69 |
TSize iScreenSize;
|
|
70 |
|
|
71 |
/// Own: the layout objects
|
|
72 |
TGlxSetValueLayout iSizeLayout;
|
|
73 |
TShwCrossFadeLayout iOpacityLayout;
|
|
74 |
|
|
75 |
/// Own: the effect info.
|
|
76 |
TShwEffectInfo iEffectInfo;
|
|
77 |
|
|
78 |
/// Own: the effect's name
|
|
79 |
HBufC* iEffectName;
|
|
80 |
|
|
81 |
};
|
|
82 |
|
|
83 |
// -----------------------------------------------------------------------------
|
|
84 |
// C++ Constructor. Save a few bits of rom with inlining
|
|
85 |
// -----------------------------------------------------------------------------
|
|
86 |
inline CShwCrossFadeEffect::CShwCrossFadeEffectImpl::CShwCrossFadeEffectImpl()
|
|
87 |
// : iSizeLayout( TGlxLayoutInfo::ESize )
|
|
88 |
{
|
|
89 |
TRACER("CShwCrossFadeEffect::CShwCrossFadeEffectImpl::CShwCrossFadeEffectImpl()");
|
|
90 |
GLX_LOG_INFO("CShwCrossFadeEffect::CShwCrossFadeEffectImpl::CShwCrossFadeEffectImpl()");
|
|
91 |
// set layout chains, opacity -> size
|
|
92 |
iOpacityLayout.SetNext( &iSizeLayout );
|
|
93 |
iSizeLayout.SetNext( NULL );
|
|
94 |
|
|
95 |
// define initial values
|
|
96 |
iOpacityLayout.Set( KMinOpacity ); // initial value 0%
|
|
97 |
}
|
|
98 |
|
|
99 |
// -----------------------------------------------------------------------------
|
|
100 |
// Destructor. Save a few bits of rom with inlining
|
|
101 |
// -----------------------------------------------------------------------------
|
|
102 |
inline CShwCrossFadeEffect::CShwCrossFadeEffectImpl::~CShwCrossFadeEffectImpl()
|
|
103 |
{
|
|
104 |
TRACER("CShwCrossFadeEffect::CShwCrossFadeEffectImpl::~CShwCrossFadeEffectImpl()");
|
|
105 |
GLX_LOG_INFO("CShwCrossFadeEffect::CShwCrossFadeEffectImpl::~CShwCrossFadeEffectImpl()");
|
|
106 |
delete iEffectName;
|
|
107 |
}
|
|
108 |
|
|
109 |
// -----------------------------------------------------------------------------
|
|
110 |
// C++ Constructor. Save a few bits of rom with inlining
|
|
111 |
// -----------------------------------------------------------------------------
|
|
112 |
inline CShwCrossFadeEffect::CShwCrossFadeEffect()
|
|
113 |
{
|
|
114 |
}
|
|
115 |
|
|
116 |
// -----------------------------------------------------------------------------
|
|
117 |
// NewLC. Static construction
|
|
118 |
// -----------------------------------------------------------------------------
|
|
119 |
CShwCrossFadeEffect* CShwCrossFadeEffect::NewLC()
|
|
120 |
{
|
|
121 |
TRACER("CShwCrossFadeEffect::NewLC");
|
|
122 |
GLX_LOG_INFO("CShwCrossFadeEffect::NewLC");
|
|
123 |
CShwCrossFadeEffect* self = new (ELeave) CShwCrossFadeEffect;
|
|
124 |
CleanupStack::PushL( self );
|
|
125 |
|
|
126 |
// create implementation
|
|
127 |
self->iImpl = new( ELeave ) CShwCrossFadeEffectImpl;
|
|
128 |
|
|
129 |
// Note that only one name is defined for the cross fade so can only
|
|
130 |
// distinguish between normal and zoom effects via the uid
|
|
131 |
self->iImpl->iEffectName =
|
|
132 |
ShwResourceUtility::LocalisedNameL( R_SHW_EFFECT_CROSS_FADE );
|
|
133 |
if( !self->iImpl->iEffectName )
|
|
134 |
{
|
|
135 |
// Have to use a non-localised version
|
|
136 |
self->iImpl->iEffectInfo.iName = KEffectNameCrossFade;
|
|
137 |
}
|
|
138 |
else
|
|
139 |
{
|
|
140 |
// set the localised version
|
|
141 |
self->iImpl->iEffectInfo.iName = *self->iImpl->iEffectName;
|
|
142 |
}
|
|
143 |
|
|
144 |
// info - uid
|
|
145 |
self->iImpl->iEffectInfo.iId.iPluginUid = KDefaultEffectPluginUid;
|
|
146 |
self->iImpl->iEffectInfo.iId.iIndex = KEffectUidXFadeNormal;
|
|
147 |
|
|
148 |
return self;
|
|
149 |
}
|
|
150 |
|
|
151 |
// -----------------------------------------------------------------------------
|
|
152 |
// Destructor.
|
|
153 |
// -----------------------------------------------------------------------------
|
|
154 |
CShwCrossFadeEffect::~CShwCrossFadeEffect()
|
|
155 |
{
|
|
156 |
TRACER("CShwCrossFadeEffect::~CShwCrossFadeEffect");
|
|
157 |
GLX_LOG_INFO("CShwCrossFadeEffect::~CShwCrossFadeEffect");
|
|
158 |
delete iImpl;
|
|
159 |
}
|
|
160 |
|
|
161 |
// -----------------------------------------------------------------------------
|
|
162 |
// CloneLC
|
|
163 |
// -----------------------------------------------------------------------------
|
|
164 |
MShwEffect* CShwCrossFadeEffect::CloneLC()
|
|
165 |
{
|
|
166 |
TRACER("CShwCrossFadeEffect::CloneLC");
|
|
167 |
GLX_LOG_INFO( "CShwCrossFadeEffect::CloneLC" );
|
|
168 |
// create a copy of the effect
|
|
169 |
CShwCrossFadeEffect* copy = CShwCrossFadeEffect::NewLC();
|
|
170 |
// transfer the member variables, only size has relevant value
|
|
171 |
/*copy->iImpl->iSizeLayout.SetValue(
|
|
172 |
iImpl->iSizeLayout.TimedPoint().iX.Now(),
|
|
173 |
iImpl->iSizeLayout.TimedPoint().iY.Now(),
|
|
174 |
0 );*/
|
|
175 |
// copy the screen size
|
|
176 |
copy->iImpl->iScreenSize = iImpl->iScreenSize;
|
|
177 |
return copy;
|
|
178 |
}
|
|
179 |
|
|
180 |
// -----------------------------------------------------------------------------
|
|
181 |
// InitializeL
|
|
182 |
// -----------------------------------------------------------------------------
|
|
183 |
void CShwCrossFadeEffect::InitializeL(
|
|
184 |
CAlfEnv* /*aHuiEnv*/, MGlxVisualList* /*aVisualList*/,
|
|
185 |
MGlxMediaList* /*aMediaList*/, TSize aScreenSize )
|
|
186 |
{
|
|
187 |
TRACER("CShwCrossFadeEffect::InitializeL");
|
|
188 |
GLX_LOG_INFO( "CShwCrossFadeEffect::InitializeL" );
|
|
189 |
// set the screen size
|
|
190 |
iImpl->iScreenSize = aScreenSize;
|
|
191 |
}
|
|
192 |
|
|
193 |
// -----------------------------------------------------------------------------
|
|
194 |
// PrepareViewL
|
|
195 |
// -----------------------------------------------------------------------------
|
|
196 |
TSize CShwCrossFadeEffect::PrepareViewL(
|
|
197 |
CAlfVisual* /*aVisual*/, TSize /*aImageSize*/ )
|
|
198 |
{
|
|
199 |
TRACER("CShwCrossFadeEffect::PrepareViewL");
|
|
200 |
GLX_LOG_INFO( "CShwCrossFadeEffect::PrepareViewL" );
|
|
201 |
// visual list takes care of fitting the image and maintains aspect ratio
|
|
202 |
// return the screen size as the thumbnail size
|
|
203 |
return iImpl->iScreenSize;
|
|
204 |
}
|
|
205 |
|
|
206 |
// -----------------------------------------------------------------------------
|
|
207 |
// EnterViewL.
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
MGlxLayout* CShwCrossFadeEffect::EnterViewL(
|
|
210 |
CAlfVisual* aVisual/**/, TInt /*aDuration*/, TInt aFadeInDuration )
|
|
211 |
{
|
|
212 |
TRACER("CShwCrossFadeEffect::EnterViewL");
|
|
213 |
GLX_LOG_INFO1(
|
|
214 |
"CShwCrossFadeEffect::EnterViewL( %d )", aFadeInDuration );
|
|
215 |
TAlfTimedValue initialValue(0.0,0);
|
|
216 |
aVisual->SetOpacity(initialValue);
|
|
217 |
TAlfTimedValue tranition(1.0,aFadeInDuration);
|
|
218 |
tranition.SetStyle(EAlfTimedValueStyleLinear);
|
|
219 |
aVisual->SetOpacity(tranition);
|
|
220 |
return &iImpl->iOpacityLayout;
|
|
221 |
}
|
|
222 |
|
|
223 |
// -----------------------------------------------------------------------------
|
|
224 |
// ExitView.
|
|
225 |
// -----------------------------------------------------------------------------
|
|
226 |
void CShwCrossFadeEffect::ExitView( CAlfVisual* /*aVisual*/ )
|
|
227 |
{
|
|
228 |
TRACER("CShwCrossFadeEffect::ExitView");
|
|
229 |
GLX_LOG_INFO( "CShwCrossFadeEffect::ExitView" );
|
|
230 |
}
|
|
231 |
|
|
232 |
// -----------------------------------------------------------------------------
|
|
233 |
// EnterTransitionL.
|
|
234 |
// -----------------------------------------------------------------------------
|
|
235 |
MGlxLayout* CShwCrossFadeEffect::EnterTransitionL(
|
|
236 |
CAlfVisual* /**/aVisual, TInt aDuration )
|
|
237 |
{
|
|
238 |
TRACER("CShwCrossFadeEffect::EnterTransitionL");
|
|
239 |
GLX_LOG_INFO1( "CShwCrossFadeEffect::EnterTransitionL( %d )", aDuration );
|
|
240 |
|
|
241 |
TAlfTimedValue tranition(0.0,aDuration);
|
|
242 |
tranition.SetStyle(EAlfTimedValueStyleLinear);
|
|
243 |
aVisual->SetOpacity(tranition);
|
|
244 |
return &iImpl->iOpacityLayout;
|
|
245 |
}
|
|
246 |
|
|
247 |
// -----------------------------------------------------------------------------
|
|
248 |
// ExitTransition.
|
|
249 |
// -----------------------------------------------------------------------------
|
|
250 |
void CShwCrossFadeEffect::ExitTransition( CAlfVisual* /*aVisual*/ )
|
|
251 |
{
|
|
252 |
TRACER("CShwCrossFadeEffect::ExitTransition");
|
|
253 |
GLX_LOG_INFO( "CShwCrossFadeEffect::ExitTransition" );
|
|
254 |
}
|
|
255 |
|
|
256 |
// -----------------------------------------------------------------------------
|
|
257 |
// PauseL.
|
|
258 |
// -----------------------------------------------------------------------------
|
|
259 |
void CShwCrossFadeEffect::PauseL()
|
|
260 |
{
|
|
261 |
TRACER("CShwCrossFadeEffect::PauseL");
|
|
262 |
GLX_LOG_INFO( "CShwCrossFadeEffect::PauseL()");
|
|
263 |
|
|
264 |
// pause the opacity, size does not change so no need to pause
|
|
265 |
iImpl->iOpacityLayout.Pause();
|
|
266 |
}
|
|
267 |
|
|
268 |
// -----------------------------------------------------------------------------
|
|
269 |
// Resume.
|
|
270 |
// -----------------------------------------------------------------------------
|
|
271 |
void CShwCrossFadeEffect::Resume()
|
|
272 |
{
|
|
273 |
TRACER("CShwCrossFadeEffect::Resume");
|
|
274 |
GLX_LOG_INFO( "CShwCrossFadeEffect::Resume()");
|
|
275 |
|
|
276 |
// resume the opacity layout, size does not change so no need to resume
|
|
277 |
iImpl->iOpacityLayout.Resume();
|
|
278 |
}
|
|
279 |
|
|
280 |
// -----------------------------------------------------------------------------
|
|
281 |
// EffectInfo.
|
|
282 |
// -----------------------------------------------------------------------------
|
|
283 |
TShwEffectInfo CShwCrossFadeEffect::EffectInfo()
|
|
284 |
{
|
|
285 |
TRACER("CShwCrossFadeEffect::EffectInfo");
|
|
286 |
GLX_LOG_INFO( "CShwCrossFadeEffect::EffectInfo()");
|
|
287 |
return iImpl->iEffectInfo;
|
|
288 |
}
|