|
1 /* |
|
2 * Copyright (c) 2006 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: Alf system effects |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include <e32base.h> |
|
23 #include <bitdev.h> |
|
24 #include <implementationproxy.h> |
|
25 |
|
26 #include "alftfxplugincommon.hrh" |
|
27 #include "alfsystemeffects.h" |
|
28 #include "alf/alfsrveffectenv.h" |
|
29 #include <alflogger.h> |
|
30 |
|
31 #include "uiacceltk/HuiDisplay.h" |
|
32 #include "uiacceltk/HuiLayout.h" |
|
33 #include "uiacceltk/HuiControlGroup.h" |
|
34 #include "uiacceltk/HuiControl.h" |
|
35 #include "uiacceltk/HuiRoster.h" |
|
36 #include "uiacceltk/HuiCommand.h" |
|
37 #include "uiacceltk/HuiEnv.h" |
|
38 #include "uiacceltk/HuiTransformation.h" |
|
39 |
|
40 // Constants |
|
41 const TInt KAlfDefaultFocusGainedEffectDuration = 500; |
|
42 const TInt KAlfDefaultFocusLostEffectDuration = 500; |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 |
|
47 // ----------------------------------------------------------------------------- |
|
48 // CAlfSystemEffects::CAlfSystemEffects |
|
49 // C++ constuctor. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CAlfSystemEffects::CAlfSystemEffects( ) |
|
53 |
|
54 { |
|
55 //LOGTEXT(_L("CAlfSystemEffects::CAlfSystemEffects()")); |
|
56 } |
|
57 |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CAlfSystemEffects::NewExtensionL |
|
61 // Two-phased constructor. |
|
62 // ----------------------------------------------------------------------------- |
|
63 // |
|
64 MAlfTransEffectPlugin* CAlfSystemEffects::NewExtensionL() |
|
65 { |
|
66 __ALFFXLOGSTRING("CAlfSystemEffects::NewExtensionL >>"); |
|
67 //LOGTEXT(_L("CAlfSystemEffects::NewExtensionL()")); |
|
68 CAlfSystemEffects* self = new(ELeave) CAlfSystemEffects(); |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 CleanupStack::Pop( self ); |
|
72 __ALFFXLOGSTRING("CAlfSystemEffects::NewExtensionL <<"); |
|
73 return ( self ); |
|
74 } |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CAlfSystemEffects::ConstructL |
|
79 // Symbian 2nd phase constructor. |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CAlfSystemEffects::ConstructL() |
|
83 { |
|
84 //LOGTEXT(_L("CAlfSystemEffects::ConstructL()")); |
|
85 } |
|
86 |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // CAlfSystemEffects::~CAlfSystemEffects |
|
90 // C++ destructor. |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 CAlfSystemEffects::~CAlfSystemEffects() |
|
94 { |
|
95 __ALFFXLOGSTRING("CAlfSystemEffects::~CAlfSystemEffects"); |
|
96 //LOGTEXT(_L("CAlfSystemEffects::~CAlfSystemEffects()")); |
|
97 } |
|
98 |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CAlfSystemEffects::GetSupportedEffects |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 TInt CAlfSystemEffects::GetSupportedEffects( RArray<TInt>& aSupportedEffectIds ) |
|
105 { |
|
106 __ALFFXLOGSTRING("CAlfSystemEffects::GetSupportedEffects >>"); |
|
107 // Add effect ids which are supported by this plugin |
|
108 aSupportedEffectIds.Append( MAlfTransEffectPlugin::EContextFocusGained ); |
|
109 aSupportedEffectIds.Append( MAlfTransEffectPlugin::EContextFocusLost ); |
|
110 aSupportedEffectIds.Append( MAlfTransEffectPlugin::EContextEmbeddedStart ); |
|
111 aSupportedEffectIds.Append( MAlfTransEffectPlugin::EContextEmbeddedExit ); |
|
112 __ALFFXLOGSTRING("CAlfSystemEffects::GetSupportedEffects - return KErrnone<<"); |
|
113 return KErrNone; |
|
114 }; |
|
115 |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CAlfSystemEffects::StartPhase |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 TInt CAlfSystemEffects::StartPhase( TInt aPhaseId, TInt aEffectId, |
|
122 CAlfSrvEffectEnv& aEffectEnv, const TDesC8* aParams ) |
|
123 { |
|
124 __ALFFXLOGSTRING("CAlfSystemEffects::StartPhase >>"); |
|
125 TRAP_IGNORE( DoStartPhaseL( aPhaseId, aEffectId, aEffectEnv, aParams )); |
|
126 __ALFFXLOGSTRING("CAlfSystemEffects::StartPhase - return KErrNone <<"); |
|
127 return KErrNone; |
|
128 } |
|
129 |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CAlfSystemEffects::DoStartPhaseL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 TInt CAlfSystemEffects::DoStartPhaseL( TInt /*aPhaseId*/, TInt aEffectId, |
|
136 CAlfSrvEffectEnv& aEffectEnv, const TDesC8* /*aParams*/ ) |
|
137 { |
|
138 __ALFFXLOGSTRING1("CAlfSystemEffects::DoStartPhaseL - aEffectId: %d ", aEffectId ); |
|
139 |
|
140 // Start effect here! |
|
141 switch (aEffectId) |
|
142 { |
|
143 case MAlfTransEffectPlugin::EContextFocusGained: |
|
144 { |
|
145 ShowVisibleGroupsAndMakeNonTransparentL( aEffectEnv ); |
|
146 break; |
|
147 } |
|
148 |
|
149 case MAlfTransEffectPlugin::EContextFocusLost: |
|
150 { |
|
151 HideGroupsAndMakeTransparentL( aEffectEnv ); |
|
152 break; |
|
153 } |
|
154 |
|
155 case MAlfTransEffectPlugin::EContextEmbeddedStart: |
|
156 { |
|
157 // do a normal show |
|
158 ShowVisibleGroupsAndMakeNonTransparentL( aEffectEnv ); |
|
159 |
|
160 // in addition, do a expand effect for the visible groups |
|
161 TInt controlGroupCount = aEffectEnv.VisibleControlGroupCountL(); |
|
162 for ( TInt g = 0 ; g < controlGroupCount ; g++ ) |
|
163 { |
|
164 CHuiControlGroup* group = aEffectEnv.VisibleControlGroupL(g); |
|
165 if (group) |
|
166 { |
|
167 // Perhaps we should show controlgroup in other displays too...? |
|
168 CHuiDisplay* defaultDisplay = aEffectEnv.DisplayL(0); |
|
169 if (defaultDisplay) |
|
170 { |
|
171 CHuiLayout* hostContainer = group->Control(0).ContainerLayout( NULL ); |
|
172 |
|
173 // Cancel the previous 'disable transformation' commands. |
|
174 aEffectEnv.SharedEnv()->CancelCommands( hostContainer, EHuiOpDisableTransformation ); |
|
175 |
|
176 hostContainer->EnableTransformationL(); |
|
177 CHuiTransformation& xf = hostContainer->Transformation(); |
|
178 |
|
179 THuiTimedValue scale(0); |
|
180 scale.Set(1, KAlfDefaultFocusGainedEffectDuration); |
|
181 |
|
182 // Clear previously created transformation steps. |
|
183 xf.LoadIdentity(); |
|
184 |
|
185 xf.Scale(scale,scale); |
|
186 |
|
187 // Disable transformations after effect |
|
188 THuiVisualCommand disableTransformationCommand( *hostContainer, EHuiOpDisableTransformation ); |
|
189 aEffectEnv.SharedEnv()->Send( disableTransformationCommand, KAlfDefaultFocusGainedEffectDuration ); |
|
190 } |
|
191 } |
|
192 } |
|
193 break; |
|
194 } |
|
195 case MAlfTransEffectPlugin::EContextEmbeddedExit: |
|
196 { |
|
197 // do normal hide |
|
198 HideGroupsAndMakeTransparentL( aEffectEnv ); |
|
199 |
|
200 // in addition, do a shrink effect for the visible groups |
|
201 TInt controlGroupCount = aEffectEnv.VisibleControlGroupCountL(); |
|
202 for ( TInt g = 0 ; g < controlGroupCount ; g++ ) |
|
203 { |
|
204 CHuiControlGroup* group = aEffectEnv.VisibleControlGroupL(g); |
|
205 if (group) |
|
206 { |
|
207 // Perhaps we should show controlgroup in other displays too...? |
|
208 CHuiDisplay* defaultDisplay = aEffectEnv.DisplayL(0); |
|
209 if (defaultDisplay) |
|
210 { |
|
211 // Do a little pop out effect |
|
212 CHuiLayout* hostContainer = group->Control(0).ContainerLayout( NULL ); |
|
213 |
|
214 // Cancel the previous 'disable transformation' commands. |
|
215 aEffectEnv.SharedEnv()->CancelCommands( hostContainer, EHuiOpDisableTransformation ); |
|
216 |
|
217 hostContainer->EnableTransformationL(); |
|
218 CHuiTransformation& xf = hostContainer->Transformation(); |
|
219 |
|
220 THuiTimedValue scale(1); |
|
221 scale.Set(0, KAlfDefaultFocusLostEffectDuration); |
|
222 |
|
223 // Clear previously created transformation steps. |
|
224 xf.LoadIdentity(); |
|
225 |
|
226 xf.Scale(scale,scale); |
|
227 |
|
228 // Disable transformations after effect |
|
229 THuiVisualCommand disableTransformationCommand( *hostContainer, EHuiOpDisableTransformation ); |
|
230 aEffectEnv.SharedEnv()->Send( disableTransformationCommand, KAlfDefaultFocusLostEffectDuration ); |
|
231 } |
|
232 } |
|
233 } |
|
234 break; |
|
235 } |
|
236 default: |
|
237 { |
|
238 |
|
239 break; |
|
240 } |
|
241 } |
|
242 __ALFFXLOGSTRING("CAlfSystemEffects::DoStartPhaseL - return KErrNone <<"); |
|
243 return KErrNone; |
|
244 }; |
|
245 |
|
246 void CAlfSystemEffects::ShowVisibleGroupsAndMakeNonTransparentL(CAlfSrvEffectEnv& aEffectEnv) |
|
247 { |
|
248 __ALFFXLOGSTRING("CAlfSystemEffects::ShowVisibleGroupsAndMakeNonTransparentL >>"); |
|
249 // Set opacity of every control group to 1, even if it is not shown because |
|
250 // application may want to show it later and it cannot control the |
|
251 // opacity. |
|
252 TInt controlGroupCount = aEffectEnv.ControlGroupCountL(); |
|
253 for ( TInt g = 0 ; g < controlGroupCount ; g++ ) |
|
254 { |
|
255 CHuiControlGroup* group = aEffectEnv.ControlGroupL(g); |
|
256 if (group) |
|
257 { |
|
258 // Perhaps we should show controlgroup in other displays too...? |
|
259 CHuiDisplay* defaultDisplay = aEffectEnv.DisplayL(0); |
|
260 if (defaultDisplay) |
|
261 { |
|
262 // Set the root visual opacity to 1 which affects all the visuals in the group |
|
263 CHuiLayout* hostContainer = group->Control(0).ContainerLayout( NULL ); |
|
264 hostContainer->iOpacity.Set(1.f, KAlfDefaultFocusGainedEffectDuration); |
|
265 |
|
266 // Disable also previous transformations. |
|
267 hostContainer->EnableTransformationL(EFalse); |
|
268 } |
|
269 } |
|
270 } |
|
271 |
|
272 // Check how many control groups are shown (set visible by the application) |
|
273 |
|
274 // todo: the visible control group should be shown in the same order as they were |
|
275 // set into the roster originally. |
|
276 TInt visibleControlGroupCount = aEffectEnv.VisibleControlGroupCountL(); |
|
277 for ( TInt g = 0 ; g < visibleControlGroupCount ; g++ ) |
|
278 { |
|
279 CHuiControlGroup* group = aEffectEnv.VisibleControlGroupL(g); |
|
280 if (group) |
|
281 { |
|
282 CHuiDisplay* defaultDisplay = aEffectEnv.DisplayL(0); |
|
283 if (defaultDisplay) |
|
284 { |
|
285 // Cancel the previous hide commands. |
|
286 aEffectEnv.SharedEnv()->CancelCommands( group, EHuiOpHide ); |
|
287 |
|
288 // Show control group ! |
|
289 defaultDisplay->Roster().ShowL(*group); |
|
290 group->SetAcceptInput(EFalse); |
|
291 } |
|
292 } |
|
293 } |
|
294 __ALFFXLOGSTRING("CAlfSystemEffects::ShowVisibleGroupsAndMakeNonTransparentL <<"); |
|
295 } |
|
296 |
|
297 void CAlfSystemEffects::HideGroupsAndMakeTransparentL(CAlfSrvEffectEnv& aEffectEnv) |
|
298 { |
|
299 __ALFFXLOGSTRING("CAlfSystemEffects::HideGroupsAndMakeTransparentL >>"); |
|
300 TInt controlGroupCount = aEffectEnv.ControlGroupCountL(); |
|
301 for ( TInt g = 0 ; g < controlGroupCount ; g++ ) |
|
302 { |
|
303 CHuiControlGroup* group = aEffectEnv.ControlGroupL(g); |
|
304 if (group) |
|
305 { |
|
306 // Perhaps we should show controlgroup in other displays too...? |
|
307 CHuiDisplay* defaultDisplay = aEffectEnv.DisplayL(0); |
|
308 if (defaultDisplay) |
|
309 { |
|
310 // Set the root visual opacity to 0 which affects all the visuals in the group |
|
311 CHuiLayout* hostContainer = group->Control(0).ContainerLayout( NULL ); |
|
312 hostContainer->iOpacity.Set(0.f, KAlfDefaultFocusGainedEffectDuration); |
|
313 |
|
314 if (defaultDisplay->DisplayType() != CHuiDisplay::EDisplayOffScreenBuffer) |
|
315 { |
|
316 // Hide the group so that it does not use resources when we dont have focus |
|
317 THuiGroupCommand command( *group, EHuiOpHide, defaultDisplay ); |
|
318 aEffectEnv.SharedEnv()->Send(command, KAlfDefaultFocusLostEffectDuration); |
|
319 } |
|
320 } |
|
321 } |
|
322 } |
|
323 __ALFFXLOGSTRING("CAlfSystemEffects::HideGroupsAndMakeTransparentL <<"); |
|
324 } |
|
325 |
|
326 // End of File |