|
1 /* |
|
2 * Copyright (c) 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: Effect manager. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "xneffectmanager.h" |
|
21 #include "xnplugindata.h" |
|
22 #include "xnviewdata.h" |
|
23 #include "xnnode.h" |
|
24 #include "xndomnode.h" |
|
25 #include "xncontroladapter.h" |
|
26 |
|
27 // SYSTEM INCLUDE FILES |
|
28 #include <eikapp.h> |
|
29 #include <aknappui.h> |
|
30 #include <gfxtranseffect/gfxtranseffect.h> // For transition effects |
|
31 #include <akntranseffect.h> // For transition effects |
|
32 |
|
33 // CONSTANTS |
|
34 const TInt KEffectTypeFullscreen = 1; |
|
35 const TInt KEffectTypeControl = 2; |
|
36 |
|
37 const TInt KWaitForLayout = 1; |
|
38 const TInt KEffectStarted = 2; |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // C++ default constructor. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CXnEffectManager::CXnEffectManager() |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // Symbian 2nd phase constructor. |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CXnEffectManager::ConstructL() |
|
55 { |
|
56 } |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // Two-phased constructor. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 CXnEffectManager* CXnEffectManager::NewL() |
|
63 { |
|
64 CXnEffectManager* self = new (ELeave) CXnEffectManager(); |
|
65 CleanupStack::PushL( self ); |
|
66 self->ConstructL(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // Destructor. |
|
73 // ----------------------------------------------------------------------------- |
|
74 // |
|
75 CXnEffectManager::~CXnEffectManager() |
|
76 { |
|
77 GfxTransEffect::AbortFullScreen(); |
|
78 iEffects.ResetAndDestroy(); |
|
79 } |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CXnEffectManager::BeginControlEffectL |
|
83 // ----------------------------------------------------------------------------- |
|
84 // |
|
85 void CXnEffectManager::BeginControlEffectL( TInt /*aId*/, CXnPluginData& /*aPlugin*/ ) |
|
86 { |
|
87 /* |
|
88 TXnEffect* effect = new (ELeave) TXnEffect; |
|
89 CleanupStack::PushL( effect ); |
|
90 effect->iId = aId; |
|
91 effect->iType = KEffectTypeControl; |
|
92 effect->iNode = aPlugin.Node()->LayoutNode(); |
|
93 iEffects.AppendL( effect ); |
|
94 CleanupStack::Pop( effect ); |
|
95 |
|
96 if ( effect->iNode && !effect->iNode->IsLaidOut() ) |
|
97 { |
|
98 effect->iState = KWaitForLayout; |
|
99 } |
|
100 else |
|
101 { |
|
102 DoBeginControlEffect( *effect ); |
|
103 } |
|
104 */ |
|
105 } |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // CXnEffectManager::BeginControlEffectL |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CXnEffectManager::BeginControlEffectL( TInt aId, |
|
112 RPointerArray<CXnPluginData>& aPlugins ) |
|
113 { |
|
114 TInt count = aPlugins.Count(); |
|
115 for ( TInt i = 0; i < count; i++ ) |
|
116 { |
|
117 BeginControlEffectL( aId, *aPlugins[i] ); |
|
118 } |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // CXnEffectManager::BeginFullscreenEffectL |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void CXnEffectManager::BeginFullscreenEffectL( TInt aId, CXnViewData& aView ) |
|
126 { |
|
127 // Only one fullscreen effect at time |
|
128 if ( EffectCount( KEffectTypeFullscreen ) != 0 ) |
|
129 { |
|
130 return; |
|
131 } |
|
132 |
|
133 TXnEffect* effect = new (ELeave) TXnEffect; |
|
134 CleanupStack::PushL( effect ); |
|
135 effect->iId = aId; |
|
136 effect->iType = KEffectTypeFullscreen; |
|
137 effect->iNode = aView.ViewNode(); |
|
138 iEffects.AppendL( effect ); |
|
139 CleanupStack::Pop( effect ); |
|
140 |
|
141 if ( !aView.ViewNode()->IsLaidOut() ) |
|
142 { |
|
143 effect->iState = KWaitForLayout; |
|
144 } |
|
145 else |
|
146 { |
|
147 DoBeginFullscreenEffect( *effect ); |
|
148 } |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CXnEffectManager::UiRendered |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 void CXnEffectManager::UiRendered() |
|
156 { |
|
157 for ( TInt i = 0; i < iEffects.Count(); ) |
|
158 { |
|
159 TInt count = iEffects.Count(); // for debugging |
|
160 TXnEffect* effect = iEffects[i]; |
|
161 if ( effect && effect->iState == KEffectStarted ) |
|
162 { |
|
163 if ( effect->iType == KEffectTypeFullscreen ) |
|
164 { |
|
165 GfxTransEffect::EndFullScreen(); |
|
166 } |
|
167 else if ( effect->iType == KEffectTypeControl ) |
|
168 { |
|
169 GfxTransEffect::End( effect->iNode->Control() ); |
|
170 } |
|
171 RemoveEffect( effect ); |
|
172 } |
|
173 else |
|
174 { |
|
175 i++; |
|
176 } |
|
177 } |
|
178 } |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CXnEffectManager::UiLayouted |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 void CXnEffectManager::UiLayouted() |
|
185 { |
|
186 TInt count = iEffects.Count(); |
|
187 for ( TInt i = 0; i < count; i++ ) |
|
188 { |
|
189 TXnEffect* effect = iEffects[i]; |
|
190 if ( effect && effect->iNode && |
|
191 effect->iState == KWaitForLayout && |
|
192 effect->iNode->IsLaidOut()) |
|
193 { |
|
194 if ( effect->iType == KEffectTypeFullscreen ) |
|
195 { |
|
196 DoBeginFullscreenEffect( *effect ); |
|
197 } |
|
198 else if ( effect->iType == KEffectTypeControl ) |
|
199 { |
|
200 DoBeginControlEffect( *effect ); |
|
201 } |
|
202 } |
|
203 } |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CXnEffectManager::DoBeginFullscreenEffect |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 void CXnEffectManager::DoBeginFullscreenEffect( TXnEffect& aEffect ) |
|
211 { |
|
212 CCoeEnv* coe( CCoeEnv::Static() ); |
|
213 |
|
214 if ( coe->WsSession().GetFocusWindowGroup() != |
|
215 coe->RootWin().Identifier() ) |
|
216 { |
|
217 // Window group is not focused |
|
218 RemoveEffect( &aEffect ); |
|
219 return; |
|
220 } |
|
221 |
|
222 const TInt flags( AknTransEffect::TParameter::EActivateExplicitCancel ); |
|
223 const TUid targetAppUid( iAvkonAppUi->Application()->AppDllUid() ); |
|
224 |
|
225 // Set effect begin point |
|
226 GfxTransEffect::BeginFullScreen( aEffect.iId , iAvkonAppUi->ClientRect(), |
|
227 AknTransEffect::EParameterType, AknTransEffect::GfxTransParam( |
|
228 targetAppUid, flags ) ); |
|
229 |
|
230 aEffect.iState = KEffectStarted; |
|
231 } |
|
232 |
|
233 // ----------------------------------------------------------------------------- |
|
234 // CXnEffectManager::DoBeginControlEffect |
|
235 // ----------------------------------------------------------------------------- |
|
236 // |
|
237 void CXnEffectManager::DoBeginControlEffect( TXnEffect& aEffect ) |
|
238 { |
|
239 CCoeEnv* coe( CCoeEnv::Static() ); |
|
240 |
|
241 if ( coe->WsSession().GetFocusWindowGroup() != |
|
242 coe->RootWin().Identifier() ) |
|
243 { |
|
244 // Window group is not focused |
|
245 RemoveEffect( &aEffect ); |
|
246 return; |
|
247 } |
|
248 |
|
249 // Set effect begin point |
|
250 if ( aEffect.iNode ) |
|
251 { |
|
252 GfxTransEffect::Begin( aEffect.iNode->Control() , aEffect.iId ); |
|
253 aEffect.iState = KEffectStarted; |
|
254 } |
|
255 else |
|
256 { |
|
257 RemoveEffect( &aEffect ); |
|
258 } |
|
259 } |
|
260 |
|
261 // ----------------------------------------------------------------------------- |
|
262 // CXnEffectManager::RemoveEffect |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void CXnEffectManager::RemoveEffect( TXnEffect* aEffect ) |
|
266 { |
|
267 TInt index = iEffects.Find( aEffect ); |
|
268 if ( index != KErrNotFound ) |
|
269 { |
|
270 TXnEffect* temp = iEffects[index]; |
|
271 iEffects.Remove( index ); |
|
272 delete temp; |
|
273 } |
|
274 } |
|
275 |
|
276 // ----------------------------------------------------------------------------- |
|
277 // CXnEffectManager::EffectCount |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 TInt CXnEffectManager::EffectCount( TInt aType ) |
|
281 { |
|
282 TInt effectCount = 0; |
|
283 TInt count = iEffects.Count(); |
|
284 for ( TInt i = 0; i < count; i++ ) |
|
285 { |
|
286 if ( iEffects[i]->iType == aType ) |
|
287 { |
|
288 effectCount++; |
|
289 } |
|
290 } |
|
291 return effectCount; |
|
292 } |
|
293 |
|
294 // End of File |