|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include "AnimationGroup.h" |
|
17 |
|
18 #include "AnimationTls.h" |
|
19 #include "AnimationTicker.h" |
|
20 |
|
21 /** |
|
22 Two stage constructor. |
|
23 |
|
24 Creates an empty animation group. |
|
25 |
|
26 @return The new object |
|
27 */ |
|
28 EXPORT_C CAnimationGroup* CAnimationGroup::NewL() |
|
29 { |
|
30 CAnimationGroup * self = new (ELeave) CAnimationGroup; |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 /** Destructor.*/ |
|
38 EXPORT_C CAnimationGroup::~CAnimationGroup() |
|
39 { |
|
40 while(iFreezeCount > 0) |
|
41 CAnimationGroup::Unfreeze(); |
|
42 iAnimations.Reset(); |
|
43 if(iTls) |
|
44 { |
|
45 iTls->Close(); |
|
46 iTls = NULL; |
|
47 } |
|
48 } |
|
49 |
|
50 CAnimationGroup::CAnimationGroup() |
|
51 { |
|
52 } |
|
53 |
|
54 void CAnimationGroup::ConstructL() |
|
55 { |
|
56 iTls = CAnimationTls::NewL(); |
|
57 } |
|
58 |
|
59 /** |
|
60 Returns a reference to the array of animations being grouped. |
|
61 |
|
62 It is intended for animations to be added to and removed from this array directly. |
|
63 @return the array of animations currently held in the group. |
|
64 */ |
|
65 EXPORT_C const RPointerArray<CAnimation>& CAnimationGroup::Animations() const |
|
66 { |
|
67 return iAnimations; |
|
68 } |
|
69 |
|
70 /** |
|
71 Returns a reference to the array of animations being grouped. |
|
72 |
|
73 It is intended for animations to be added to and removed from this array directly. |
|
74 @return the array of animations currently held in the group. |
|
75 */ |
|
76 EXPORT_C RPointerArray<CAnimation>& CAnimationGroup::Animations() |
|
77 { |
|
78 return iAnimations; |
|
79 } |
|
80 |
|
81 /** Starts all of the animations. |
|
82 |
|
83 @param aConfig Specifies run time attributes of the animation */ |
|
84 void CAnimationGroup::Start(const TAnimationConfig& aConfig) |
|
85 { |
|
86 Freeze(); |
|
87 for (TInt ii = iAnimations.Count() - 1; ii >= 0; --ii) |
|
88 { |
|
89 iAnimations[ii]->Start(aConfig); |
|
90 } |
|
91 Unfreeze(); |
|
92 } |
|
93 |
|
94 /** Stops all of the animations.*/ |
|
95 void CAnimationGroup::Stop() |
|
96 { |
|
97 Freeze(); |
|
98 for (TInt ii = iAnimations.Count() - 1; ii >= 0; --ii) |
|
99 { |
|
100 iAnimations[ii]->Stop(); |
|
101 } |
|
102 Unfreeze(); |
|
103 } |
|
104 |
|
105 /** Pauses all of the animations.*/ |
|
106 void CAnimationGroup::Pause() |
|
107 { |
|
108 Freeze(); |
|
109 for (TInt ii = iAnimations.Count() - 1; ii >= 0; --ii) |
|
110 { |
|
111 iAnimations[ii]->Pause(); |
|
112 } |
|
113 Unfreeze(); |
|
114 } |
|
115 |
|
116 /** Resumes all of the animations.*/ |
|
117 void CAnimationGroup::Resume() |
|
118 { |
|
119 Freeze(); |
|
120 for (TInt ii = iAnimations.Count() - 1; ii >= 0; --ii) |
|
121 { |
|
122 iAnimations[ii]->Resume(); |
|
123 } |
|
124 Unfreeze(); |
|
125 } |
|
126 |
|
127 /** Hold all of the animations.*/ |
|
128 void CAnimationGroup::Hold() |
|
129 { |
|
130 Freeze(); |
|
131 for (TInt ii = iAnimations.Count() - 1; ii >= 0; --ii) |
|
132 { |
|
133 iAnimations[ii]->Hold(); |
|
134 } |
|
135 Unfreeze(); |
|
136 } |
|
137 |
|
138 /** Unhold all of the animations.*/ |
|
139 void CAnimationGroup::Unhold() |
|
140 { |
|
141 Freeze(); |
|
142 for (TInt ii = iAnimations.Count() - 1; ii >= 0; --ii) |
|
143 { |
|
144 iAnimations[ii]->Unhold(); |
|
145 } |
|
146 Unfreeze(); |
|
147 } |
|
148 |
|
149 /** |
|
150 Set the position of all the animations. |
|
151 |
|
152 Note that this will cause all the animations to be in the same place, which is |
|
153 unlikely to be a desired effect. It is implemented here for completeness. |
|
154 |
|
155 @param aPoint The new location of the top left corner of the animation, |
|
156 relative to the window in which it is to be drawn */ |
|
157 void CAnimationGroup::SetPosition(const TPoint& aPoint) |
|
158 { |
|
159 Freeze(); |
|
160 for (TInt ii = iAnimations.Count() - 1; ii >= 0; --ii) |
|
161 { |
|
162 iAnimations[ii]->SetPosition(aPoint); |
|
163 } |
|
164 Unfreeze(); |
|
165 } |
|
166 |
|
167 /** Freeze all of the animations.*/ |
|
168 void CAnimationGroup::Freeze() |
|
169 { |
|
170 for (TInt ii = iAnimations.Count() - 1; ii >= 0; --ii) |
|
171 { |
|
172 iAnimations[ii]->Freeze(); |
|
173 } |
|
174 ++iFreezeCount; |
|
175 } |
|
176 |
|
177 /** Unfreeze all of the animations.*/ |
|
178 void CAnimationGroup::Unfreeze() |
|
179 { |
|
180 for (TInt ii = iAnimations.Count() - 1; ii >= 0; --ii) |
|
181 { |
|
182 iAnimations[ii]->Unfreeze(); |
|
183 } |
|
184 --iFreezeCount; |
|
185 } |
|
186 |
|
187 /** Reserved for future use */ |
|
188 EXPORT_C void CAnimationGroup::CAnimationGroup_Reserved1() |
|
189 { |
|
190 } |
|
191 |
|
192 /** Reserved for future use */ |
|
193 EXPORT_C void CAnimationGroup::CAnimationGroup_Reserved2() |
|
194 { |
|
195 } |