|
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 // set the layout full screen (slideshow is always run on landscape) |
|
192 // iImpl->iSizeLayout.SetValue( aScreenSize.iWidth, aScreenSize.iHeight, 0 ); |
|
193 } |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // PrepareViewL |
|
197 // ----------------------------------------------------------------------------- |
|
198 TSize CShwCrossFadeEffect::PrepareViewL( |
|
199 CAlfVisual* /*aVisual*/, TSize /*aImageSize*/ ) |
|
200 { |
|
201 TRACER("CShwCrossFadeEffect::PrepareViewL"); |
|
202 GLX_LOG_INFO( "CShwCrossFadeEffect::PrepareViewL" ); |
|
203 // visual list takes care of fitting the image and maintains aspect ratio |
|
204 // return the screen size as the thumbnail size |
|
205 return iImpl->iScreenSize; |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // EnterViewL. |
|
210 // ----------------------------------------------------------------------------- |
|
211 MGlxLayout* CShwCrossFadeEffect::EnterViewL( |
|
212 CAlfVisual* aVisual/**/, TInt /*aDuration*/, TInt aFadeInDuration ) |
|
213 { |
|
214 TRACER("CShwCrossFadeEffect::EnterViewL"); |
|
215 GLX_LOG_INFO1( |
|
216 "CShwCrossFadeEffect::EnterViewL( %d )", aFadeInDuration ); |
|
217 TAlfTimedValue initialValue(0.0,0); |
|
218 aVisual->SetOpacity(initialValue); |
|
219 TAlfTimedValue tranition(1.0,aFadeInDuration); |
|
220 tranition.SetStyle(EAlfTimedValueStyleLinear); |
|
221 aVisual->SetOpacity(tranition); |
|
222 // set value, 0% -> 100% |
|
223 //iImpl->iOpacityLayout.Set( KMinOpacity ); |
|
224 //iImpl->iOpacityLayout.Set( KMaxOpacity, aFadeInDuration ); |
|
225 return &iImpl->iOpacityLayout; |
|
226 } |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // ExitView. |
|
230 // ----------------------------------------------------------------------------- |
|
231 void CShwCrossFadeEffect::ExitView( CAlfVisual* /*aVisual*/ ) |
|
232 { |
|
233 TRACER("CShwCrossFadeEffect::ExitView"); |
|
234 GLX_LOG_INFO( "CShwCrossFadeEffect::ExitView" ); |
|
235 } |
|
236 |
|
237 // ----------------------------------------------------------------------------- |
|
238 // EnterTransitionL. |
|
239 // ----------------------------------------------------------------------------- |
|
240 MGlxLayout* CShwCrossFadeEffect::EnterTransitionL( |
|
241 CAlfVisual* /**/aVisual, TInt aDuration ) |
|
242 { |
|
243 TRACER("CShwCrossFadeEffect::EnterTransitionL"); |
|
244 GLX_LOG_INFO1( "CShwCrossFadeEffect::EnterTransitionL( %d )", aDuration ); |
|
245 |
|
246 // set value, drop from 100% to 0% |
|
247 //iImpl->iOpacityLayout.Set( KMaxOpacity ); |
|
248 //iImpl->iOpacityLayout.Set( KMinOpacity, aDuration ); |
|
249 TAlfTimedValue tranition(0.0,aDuration); |
|
250 tranition.SetStyle(EAlfTimedValueStyleLinear); |
|
251 aVisual->SetOpacity(tranition); |
|
252 return &iImpl->iOpacityLayout; |
|
253 } |
|
254 |
|
255 // ----------------------------------------------------------------------------- |
|
256 // ExitTransition. |
|
257 // ----------------------------------------------------------------------------- |
|
258 void CShwCrossFadeEffect::ExitTransition( CAlfVisual* /*aVisual*/ ) |
|
259 { |
|
260 TRACER("CShwCrossFadeEffect::ExitTransition"); |
|
261 GLX_LOG_INFO( "CShwCrossFadeEffect::ExitTransition" ); |
|
262 } |
|
263 |
|
264 // ----------------------------------------------------------------------------- |
|
265 // PauseL. |
|
266 // ----------------------------------------------------------------------------- |
|
267 void CShwCrossFadeEffect::PauseL() |
|
268 { |
|
269 TRACER("CShwCrossFadeEffect::PauseL"); |
|
270 GLX_LOG_INFO( "CShwCrossFadeEffect::PauseL()"); |
|
271 |
|
272 // pause the opacity, size does not change so no need to pause |
|
273 iImpl->iOpacityLayout.Pause(); |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // Resume. |
|
278 // ----------------------------------------------------------------------------- |
|
279 void CShwCrossFadeEffect::Resume() |
|
280 { |
|
281 TRACER("CShwCrossFadeEffect::Resume"); |
|
282 GLX_LOG_INFO( "CShwCrossFadeEffect::Resume()"); |
|
283 |
|
284 // resume the opacity layout, size does not change so no need to resume |
|
285 iImpl->iOpacityLayout.Resume(); |
|
286 } |
|
287 |
|
288 // ----------------------------------------------------------------------------- |
|
289 // EffectInfo. |
|
290 // ----------------------------------------------------------------------------- |
|
291 TShwEffectInfo CShwCrossFadeEffect::EffectInfo() |
|
292 { |
|
293 TRACER("CShwCrossFadeEffect::EffectInfo"); |
|
294 GLX_LOG_INFO( "CShwCrossFadeEffect::EffectInfo()"); |
|
295 return iImpl->iEffectInfo; |
|
296 } |