|
1 /* |
|
2 * Copyright (c) 2008-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: View-transition animations |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 /** |
|
22 * @internal reviewed 12/07/2007 by Michael Yip |
|
23 */ |
|
24 |
|
25 #include "glxanimationview.h" |
|
26 |
|
27 #include <alf/alfcontrol.h> |
|
28 #include <alf/alfcontrolgroup.h> |
|
29 #include <alf/alftransformation.h> |
|
30 |
|
31 |
|
32 const TReal KGlxViewSwitchBackgroundScalingFactor = 0.2; |
|
33 const TReal KGlxViewSwitchForegroundScalingFactor = 0.3; |
|
34 |
|
35 |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // NewL |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CGlxAnimationView* CGlxAnimationView::NewL( |
|
42 TGlxViewswitchAnimation aAnimType, |
|
43 TGlxNavigationDirection aDirection, |
|
44 const RPointerArray<CAlfControlGroup>& aControlGroups) |
|
45 { |
|
46 CGlxAnimationView* self = new (ELeave) CGlxAnimationView(aAnimType, aDirection); |
|
47 CleanupStack::PushL(self); |
|
48 self->ConstructL(aControlGroups); |
|
49 CleanupStack::Pop(self); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // Constructor |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CGlxAnimationView::CGlxAnimationView( |
|
58 TGlxViewswitchAnimation aAnimType, |
|
59 TGlxNavigationDirection aDirection) |
|
60 : iAnimType(aAnimType), |
|
61 iDirection(aDirection) |
|
62 { |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // ConstructL |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CGlxAnimationView::ConstructL(const RPointerArray<CAlfControlGroup>& aControlGroups) |
|
70 { |
|
71 TInt count = aControlGroups.Count(); |
|
72 |
|
73 for (TInt index = 0; index < count; index++) |
|
74 { |
|
75 iControlGroups.AppendL(aControlGroups[index]); |
|
76 } |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // Destructor |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CGlxAnimationView::~CGlxAnimationView() |
|
84 { |
|
85 iControlGroups.Close(); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // StartTimedAnimationL |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 void CGlxAnimationView::StartTimedAnimationL( TInt aTime ) |
|
93 { |
|
94 // Set up timed values |
|
95 TAlfTimedValue scale( 1.0 ); |
|
96 TAlfTimedValue opacity( 1.0 ); |
|
97 |
|
98 // Set the scaling effect |
|
99 if ( EGlxNavigationForwards == iDirection ) |
|
100 { |
|
101 if( EGlxViewAnimationEntry == iAnimType ) |
|
102 { |
|
103 scale.SetValueNow( 1 - KGlxViewSwitchBackgroundScalingFactor ); |
|
104 scale.SetTarget( 1, aTime ); // and target |
|
105 } |
|
106 else if ( EGlxViewAnimationExit == iAnimType ) |
|
107 { |
|
108 scale.SetValueNow( 1 ); |
|
109 scale.SetTarget( 1 + KGlxViewSwitchForegroundScalingFactor, aTime ); // and target |
|
110 } |
|
111 } |
|
112 else if ( EGlxNavigationBackwards == iDirection ) |
|
113 { |
|
114 if( EGlxViewAnimationEntry == iAnimType ) |
|
115 { |
|
116 scale.SetValueNow( 1 + KGlxViewSwitchForegroundScalingFactor ); |
|
117 scale.SetTarget( 1, aTime ); // and target |
|
118 } |
|
119 else if ( EGlxViewAnimationExit == iAnimType ) |
|
120 { |
|
121 scale.SetValueNow( 1 ); |
|
122 scale.SetTarget( 1 - KGlxViewSwitchBackgroundScalingFactor, aTime ); // and target |
|
123 } |
|
124 } |
|
125 |
|
126 // Set the opacity effect |
|
127 if( EGlxViewAnimationEntry == iAnimType ) |
|
128 { |
|
129 opacity.SetValueNow( 0 ); |
|
130 opacity.SetTarget(1.0, aTime ); |
|
131 } |
|
132 else if ( EGlxViewAnimationExit == iAnimType ) |
|
133 { |
|
134 opacity.SetValueNow( 1.0 ); |
|
135 opacity.SetTarget(0.0, aTime ); |
|
136 } |
|
137 opacity.SetStyle(EAlfTimedValueStyleLinear); |
|
138 |
|
139 // Find out the screen size |
|
140 CGlxUiUtility* uiUtility = CGlxUiUtility::UtilityL(); |
|
141 CleanupClosePushL( *uiUtility ); |
|
142 //TSize dispSize = uiUtility->ScreenFurniture().CentralScreenRect().Size();// tobe implemented by sf |
|
143 CleanupStack::PopAndDestroy( uiUtility ); |
|
144 |
|
145 // Animate each of the control groups |
|
146 TInt cgCount = iControlGroups.Count(); |
|
147 for ( TInt cg = 0; cg < cgCount; cg++ ) |
|
148 { |
|
149 // If exiting, disable input events |
|
150 if ( EGlxViewAnimationExit == iAnimType ) |
|
151 { |
|
152 iControlGroups[cg]->SetAcceptInput( EFalse ); |
|
153 } |
|
154 |
|
155 // Set up control group transformations |
|
156 iControlGroups[cg]->EnableTransformationL(); |
|
157 CAlfTransformation& trans = iControlGroups[cg]->Transformation(); |
|
158 |
|
159 //trans.Translate(dispSize.iWidth/2, dispSize.iHeight/2);//tobe implemented by sf |
|
160 trans.Scale( scale, scale ); |
|
161 // trans.Translate(-dispSize.iWidth/2, -dispSize.iHeight/2);//tobe implemented by sf |
|
162 |
|
163 // Set opacity of all toplevel visuals in all controls in this group |
|
164 TInt controlCount = iControlGroups[cg]->Count(); |
|
165 for(TInt i = 0; i < controlCount; i++ ) |
|
166 { |
|
167 CAlfControl& control = iControlGroups[cg]->Control(i); |
|
168 for(TInt j = 0; j < control.VisualCount(); j++) |
|
169 { |
|
170 if ( control.Visual(j).Layout() ) |
|
171 { |
|
172 control.Visual(j).SetOpacity( opacity ); |
|
173 } |
|
174 } |
|
175 } |
|
176 } |
|
177 } |
|
178 |
|
179 |