1 /* |
|
2 * Copyright (c) 2010 Ixonos Plc. |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of the "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 * Ixonos Plc |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 /* |
|
21 * File: ExtProgressAnimationControl.cpp |
|
22 * Created: 17-10-2005 |
|
23 * Author: |
|
24 * |
|
25 */ |
|
26 |
|
27 #include <gdi.h> |
|
28 #include <aknbitmapanimation.h> |
|
29 #include <barsread.h> |
|
30 #include <bmpancli.h> |
|
31 #include <aknsbasicbackgroundcontrolcontext.h> |
|
32 #include <aknsdrawutils.h> |
|
33 #include <aknutils.h> |
|
34 #include <VideoEditorUiComponents.rsg> |
|
35 |
|
36 #include "ExtProgressAnimationControl.h" |
|
37 #include "videoeditorcommon.h" |
|
38 |
|
39 //const TInt KCropFastKeyTimerDelayInMicroseconds = 10000; |
|
40 //const TInt KDefaultFastKeyTimerIntervalInMicroseconds = 10000; |
|
41 |
|
42 // CONSTANTS |
|
43 //const TReal KIconHeightFrac = 0.25; |
|
44 //const TInt KStartOffsetX = 10; |
|
45 |
|
46 //============================================================================= |
|
47 CExtProgressAnimationControl * CExtProgressAnimationControl::NewL ( |
|
48 const TRect & aRect, |
|
49 const CCoeControl * aParent |
|
50 ) |
|
51 { |
|
52 CExtProgressAnimationControl * self = new (ELeave) CExtProgressAnimationControl; |
|
53 CleanupStack::PushL(self); |
|
54 self->ConstructL (aRect, aParent); |
|
55 CleanupStack::Pop( self ); |
|
56 return self; |
|
57 } |
|
58 |
|
59 //============================================================================= |
|
60 CExtProgressAnimationControl::~CExtProgressAnimationControl() |
|
61 { |
|
62 StopAnimation(); |
|
63 |
|
64 delete iAnimation; |
|
65 delete iBgContext; |
|
66 } |
|
67 |
|
68 //============================================================================= |
|
69 void CExtProgressAnimationControl::SetAnimationResourceId(const TInt &aResourceId) |
|
70 { |
|
71 switch (aResourceId) |
|
72 { |
|
73 case VideoEditor::EAnimationMerging: |
|
74 { |
|
75 iAnimationResourceId = R_VED_MERGING_NOTE_ANIMATION; |
|
76 break; |
|
77 } |
|
78 case VideoEditor::EAnimationChangeAudio: |
|
79 { |
|
80 iAnimationResourceId = R_VED_MERGING_AUDIO_NOTE_ANIMATION; |
|
81 break; |
|
82 } |
|
83 case VideoEditor::EAnimationAddText: |
|
84 { |
|
85 iAnimationResourceId = R_VED_ADDING_TEXT_NOTE_ANIMATION; |
|
86 break; |
|
87 } |
|
88 case VideoEditor::EAnimationCut: |
|
89 { |
|
90 iAnimationResourceId = R_VED_CUTTING_NOTE_ANIMATION; |
|
91 break; |
|
92 } |
|
93 default: |
|
94 { |
|
95 iAnimationResourceId = R_VED_MERGING_NOTE_ANIMATION; |
|
96 break; |
|
97 } |
|
98 } |
|
99 |
|
100 } |
|
101 |
|
102 //============================================================================= |
|
103 CExtProgressAnimationControl::CExtProgressAnimationControl() : iBorderWidth(2) |
|
104 { |
|
105 |
|
106 } |
|
107 |
|
108 //============================================================================= |
|
109 void CExtProgressAnimationControl::ConstructL ( |
|
110 const TRect & aRect, |
|
111 const CCoeControl * aParent |
|
112 ) |
|
113 { |
|
114 SetContainerWindowL( *aParent ); |
|
115 SetRect(aRect); |
|
116 |
|
117 // Activate control |
|
118 ActivateL(); |
|
119 } |
|
120 |
|
121 //============================================================================= |
|
122 void CExtProgressAnimationControl::SizeChanged() |
|
123 { |
|
124 TRect rect = Rect(); |
|
125 if ( iBgContext ) |
|
126 { |
|
127 iBgContext->SetRect( rect ); |
|
128 } |
|
129 } |
|
130 |
|
131 //============================================================================= |
|
132 void CExtProgressAnimationControl::Draw (const TRect& aRect) const |
|
133 { |
|
134 CWindowGc& gc = SystemGc(); |
|
135 |
|
136 // draw skin background |
|
137 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
138 MAknsControlContext* cc = AknsDrawUtils::ControlContext( this ); |
|
139 AknsDrawUtils::Background( skin, cc, this, SystemGc(), aRect ); |
|
140 } |
|
141 |
|
142 //============================================================================= |
|
143 TTypeUid::Ptr CExtProgressAnimationControl::MopSupplyObject( TTypeUid aId ) |
|
144 { |
|
145 if ( aId.iUid == MAknsControlContext::ETypeId && iBgContext ) |
|
146 { |
|
147 return MAknsControlContext::SupplyMopObject( aId, iBgContext ); |
|
148 } |
|
149 return CCoeControl::MopSupplyObject( aId ); |
|
150 } |
|
151 |
|
152 //============================================================================= |
|
153 void CExtProgressAnimationControl::HandleControlEventL( |
|
154 CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/) |
|
155 { |
|
156 } |
|
157 |
|
158 //============================================================================= |
|
159 void CExtProgressAnimationControl::StartAnimationL(TInt aFrameIntervalInMilliSeconds ) |
|
160 { |
|
161 |
|
162 if ( iAnimation ) |
|
163 { |
|
164 delete iAnimation; |
|
165 iAnimation = 0; |
|
166 } |
|
167 |
|
168 iAnimation = CAknBitmapAnimation::NewL(); |
|
169 |
|
170 TResourceReader reader; |
|
171 iCoeEnv->CreateResourceReaderLC( reader, iAnimationResourceId ); |
|
172 iAnimation->ConstructFromResourceL( reader ); |
|
173 TRect rect( Rect() ); |
|
174 rect.Move( iBorderWidth, iBorderWidth ); |
|
175 rect.Resize( -iBorderWidth*2, -iBorderWidth ); |
|
176 iAnimation->SetRect( rect ); |
|
177 iAnimation->SetContainerWindowL( *this ); |
|
178 iAnimationOn = ETrue; |
|
179 iAnimation->StartAnimationL(); |
|
180 CleanupStack::PopAndDestroy(); //reader |
|
181 CBitmapAnimClientData* animClientData = iAnimation->BitmapAnimData(); |
|
182 iAnimationSpeedInMilliSeconds = animClientData->FrameIntervalInMilliSeconds(); |
|
183 |
|
184 if ( aFrameIntervalInMilliSeconds > 0 ) |
|
185 { |
|
186 SetFrameIntervalL( aFrameIntervalInMilliSeconds ); |
|
187 } |
|
188 DrawDeferred(); |
|
189 } |
|
190 |
|
191 //============================================================================= |
|
192 void CExtProgressAnimationControl::StopAnimation() |
|
193 { |
|
194 if ( iAnimationOn ) |
|
195 { |
|
196 iAnimation->CancelAnimation(); |
|
197 } |
|
198 iAnimationOn = EFalse; |
|
199 DrawDeferred(); |
|
200 } |
|
201 |
|
202 //============================================================================= |
|
203 void CExtProgressAnimationControl::SetFrameIntervalL(TInt aFrameIntervalInMilliSeconds) |
|
204 { |
|
205 iAnimationSpeedInMilliSeconds+=aFrameIntervalInMilliSeconds; |
|
206 iAnimation->SetFrameIntervalL( iAnimationSpeedInMilliSeconds ); |
|
207 } |
|
208 |
|
209 // End of File |
|