|
1 /* |
|
2 * Copyright (c) 2006 - 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: Color tone UI feature implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <mvtengmedia.h> |
|
20 #include <cvtengmodel.h> |
|
21 #include <mvtengcamerapreferences.h> |
|
22 #include <cvtlogger.h> |
|
23 #include "cvtuicolortone.h" |
|
24 #include "tvtuifeatureids.h" |
|
25 #include <videotelui.rsg> |
|
26 #include "mvtuicomponentmanager.h" |
|
27 #include "cvtuifeaturemanager.h" |
|
28 #include "CVtUiAppUi.h" |
|
29 #include "tvtuilocalvariation.h" |
|
30 #include "cvtuifeaturemanager.h" |
|
31 #include "tvtuistates.h" |
|
32 #include "cvtuicommandmanager.h" |
|
33 |
|
34 // Implementation of TVtUiColorToneComponentState |
|
35 |
|
36 // --------------------------------------------------------------------------- |
|
37 // TVtUiColorToneComponentState::TVtUiColorToneComponentState |
|
38 // --------------------------------------------------------------------------- |
|
39 // |
|
40 TVtUiColorToneComponentState::TVtUiColorToneComponentState( |
|
41 MVtUiComponent& aComponent ) : |
|
42 TVtUiComponentState( aComponent, |
|
43 TVtUiBlockListBitField( |
|
44 MVtUiComponent::EComponentIdDialer | |
|
45 MVtUiComponent::EComponentIdToolbar | |
|
46 MVtUiComponent::EComponentIdNumberEntry ) ) |
|
47 { |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // CVtUiColorTone::NewL |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 CVtUiColorTone* CVtUiColorTone::NewL( CVtUiFeatureManager& |
|
55 aFeatureManager ) |
|
56 { |
|
57 __VTPRINTENTER( "UiColorTone.NewL" ) |
|
58 CVtUiColorTone* self = |
|
59 new ( ELeave ) CVtUiColorTone( aFeatureManager ); |
|
60 CleanupStack::PushL( self ); |
|
61 self->ConstructL(); |
|
62 CleanupStack::Pop(); |
|
63 __VTPRINTEXIT( "UiColorTone.NewL" ) |
|
64 return self; |
|
65 } |
|
66 |
|
67 // --------------------------------------------------------------------------- |
|
68 // CVtUiColorTone::~CVtUiColorTone |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 CVtUiColorTone::~CVtUiColorTone() |
|
72 { |
|
73 __VTPRINTENTER( "UiColorTone.~" ) |
|
74 // unregister layout change |
|
75 iFeatureManager.ComponentManager().ChangeLayoutChangeRegistration( |
|
76 *this, MVtUiComponentManager::EUnregister ); |
|
77 // unregister component |
|
78 iFeatureManager.ComponentManager().ChangeComponentRegistration( |
|
79 iComponentState, MVtUiComponentManager::EUnregister ); |
|
80 __VTPRINTEXIT( "UiColorTone.~" ) |
|
81 } |
|
82 |
|
83 // --------------------------------------------------------------------------- |
|
84 // CVtUiColorTone::StartL |
|
85 // --------------------------------------------------------------------------- |
|
86 // |
|
87 void CVtUiColorTone::StartL() |
|
88 { |
|
89 __VTPRINTENTER( "UiColorTone.StartL" ) |
|
90 if ( iFeatureState == MVtUiFeature::EReady ) |
|
91 { |
|
92 iFeatureManager.AppUi().EnableCommandActivatingAndCleanupPushL(); |
|
93 iFeatureManager.UiStates().SetIsFixedToolbarVisible( EFalse ); |
|
94 iFeatureManager.ComponentManager(). |
|
95 RequestActivationL ( MVtUiComponent::EComponentIdColorTone ); |
|
96 CleanupStack::Pop(); // EnableCommandActivatingAndCleanupPushL |
|
97 // set state |
|
98 iFeatureState = MVtUiFeature::EActive; |
|
99 } |
|
100 __VTPRINTEXIT( "UiColorTone.StartL" ) |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CVtUiColorTone::Stop |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CVtUiColorTone::Stop() |
|
108 { |
|
109 __VTPRINTENTER( "UiColorTone.Stop" ) |
|
110 iAsyncCallback->Cancel(); |
|
111 iAsyncCallback->Set( TCallBack( &DoStopL, this ) ); |
|
112 iAsyncCallback->CallBack(); |
|
113 __VTPRINTEXIT( "UiColorTone.Stop" ) |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CVtUiColorTone::InitFeatureL |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 void CVtUiColorTone::InitFeatureL() |
|
121 { |
|
122 __VTPRINTENTER( "UiColorTone.InitFeatureL" ) |
|
123 CVtUiPrefSettingListBase::InitFeatureL(); |
|
124 User::LeaveIfError( |
|
125 iFeatureManager.ComponentManager().ChangeComponentRegistration( |
|
126 iComponentState, MVtUiComponentManager::ERegister ) ); |
|
127 User::LeaveIfError( |
|
128 iFeatureManager.ComponentManager().ChangeLayoutChangeRegistration( |
|
129 *this, MVtUiComponentManager::ERegister ) ); |
|
130 iFeatureState = EReady; |
|
131 __VTPRINTEXIT( "UiColorTone.InitFeatureL" ) |
|
132 } |
|
133 |
|
134 // --------------------------------------------------------------------------- |
|
135 // CVtUiColorTone::ComponentId |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 MVtUiComponent::TComponentId CVtUiColorTone::ComponentId() const |
|
139 { |
|
140 __VTPRINTENTER( "UiColorTone.ComponentId" ) |
|
141 __VTPRINTEXIT( "UiColorTone.ComponentId" ) |
|
142 return MVtUiComponent::EComponentIdColorTone; |
|
143 } |
|
144 |
|
145 // --------------------------------------------------------------------------- |
|
146 // CVtUiColorTone::ComponentAsControl |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 CCoeControl* CVtUiColorTone::ComponentAsControl() |
|
150 { |
|
151 __VTPRINTENTER( "UiColorTone.ComponentAsControl" ) |
|
152 __VTPRINTEXIT( "UiColorTone.ComponentAsControl" ) |
|
153 return NULL; |
|
154 } |
|
155 |
|
156 // --------------------------------------------------------------------------- |
|
157 // CVtUiColorTone::DoActivateL |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 void CVtUiColorTone::DoActivateL() |
|
161 { |
|
162 __VTPRINTENTER( "UiColorTone.DoActivateL" ) |
|
163 // get supported color tone modes |
|
164 iCameraPref->GetSupportedColorTones( iSupportedModes ); |
|
165 __VTPRINT2( DEBUG_GEN, "UiColorTone.ConstructL=%d", iSupportedModes ) |
|
166 iFeatureManager.UiStates().SetColorToneModeOn( ETrue ); |
|
167 iAsyncCallback->Cancel(); |
|
168 iAsyncCallback->Set( TCallBack( &DoStartL, this ) ); |
|
169 iAsyncCallback->CallBack(); |
|
170 __VTPRINTEXIT( "UiColorTone.DoActivateL" ) |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------------------------- |
|
174 // CVtUiColorTone::DoDeactivateL |
|
175 // --------------------------------------------------------------------------- |
|
176 // |
|
177 void CVtUiColorTone::DoDeactivateL() |
|
178 { |
|
179 __VTPRINTENTER( "UiColorTone.DoDeactivateL" ) |
|
180 iFeatureManager.UiStates().SetColorToneModeOn( EFalse ); |
|
181 CVtUiPrefSettingListBase::StopSettingPageL(); |
|
182 __VTPRINTEXIT( "UiColorTone.DoDeactivateL" ) |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // CVtUiColorTone::HandleLayoutChangeL |
|
187 // --------------------------------------------------------------------------- |
|
188 // |
|
189 void CVtUiColorTone::HandleLayoutChangeL() |
|
190 { |
|
191 __VTPRINTENTER( "UiColorTone.HandleLayoutChangeL" ) |
|
192 if ( iFeatureState == MVtUiFeature::EActive ) |
|
193 { |
|
194 SizeChanged(); |
|
195 } |
|
196 __VTPRINTEXIT( "UiColorTone.HandleLayoutChangeL" ) |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CVtUiColorTone::CurrentSelection |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 TInt CVtUiColorTone::CurrentSelection() |
|
204 { |
|
205 __VTPRINTENTER( "UiColorTone.CurrentSelection" ) |
|
206 // ask from engine which item is currently active |
|
207 MVtEngCameraPreferences::TColorTone wb; |
|
208 if ( iCameraPref->GetColorTone( wb ) ) |
|
209 { |
|
210 __VTPRINTEXIT( "UiColorTone.CurrentSelectionERR" ) |
|
211 // if error occured return 0 i.e. first list item |
|
212 return 0; |
|
213 } |
|
214 __VTPRINTEXIT( "UiColorTone.CurrentSelection" ) |
|
215 return MapCTEnumToArrayIndex( wb ); |
|
216 } |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CVtUiColorTone::SetItemsL |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 void CVtUiColorTone::SetItemsL( CDesCArray& aArray ) |
|
223 { |
|
224 __VTPRINTENTER( "UiColorTone.SetItemsL<" ) |
|
225 __VTPRINT2( DEBUG_GEN, "UiColorTone.SetItemsL=%d", iSupportedModes ) |
|
226 // Normal mode allways supported |
|
227 ReadAndAppendItemL( aArray, R_VIDEOTELUI_QTN_INCAL_CT_NORMAL_OPTION ); |
|
228 iActiveItems.Append( MVtEngCameraPreferences::ENormal ); |
|
229 |
|
230 if( iSupportedModes & MVtEngCameraPreferences::ESepia ) |
|
231 { |
|
232 ReadAndAppendItemL( aArray, R_VIDEOTELUI_QTN_INCAL_SEPIA_OPTION ); |
|
233 iActiveItems.Append( MVtEngCameraPreferences::ESepia ); |
|
234 } |
|
235 if( iSupportedModes & MVtEngCameraPreferences::EGrayscale ) |
|
236 { |
|
237 ReadAndAppendItemL( aArray, R_VIDEOTELUI_QTN_INCAL_B_AND_W_OPTION ); |
|
238 iActiveItems.Append( MVtEngCameraPreferences::EGrayscale ); |
|
239 } |
|
240 if( iSupportedModes & MVtEngCameraPreferences::ENegative ) |
|
241 { |
|
242 ReadAndAppendItemL( aArray, R_VIDEOTELUI_QTN_INCAL_NEGATIVE_OPTION ); |
|
243 iActiveItems.Append( MVtEngCameraPreferences::ENegative ); |
|
244 } |
|
245 __VTPRINTEXIT( "UiColorTone.SetItemsL" ) |
|
246 } |
|
247 |
|
248 // --------------------------------------------------------------------------- |
|
249 // CVtUiColorTone::SettingPageResId |
|
250 // --------------------------------------------------------------------------- |
|
251 // |
|
252 TInt CVtUiColorTone::SettingPageResId() const |
|
253 { |
|
254 __VTPRINTENTER( "UiColorTone.SettingPageResId" ) |
|
255 __VTPRINTEXIT( "UiColorTone.SettingPageResId" ) |
|
256 return R_VIDEOTELUI_COLOR_TONE_SETTING_PAGE; |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // CVtUiColorTone::SettingPageItemChanged |
|
261 // --------------------------------------------------------------------------- |
|
262 // |
|
263 void CVtUiColorTone::SettingPageItemChangedL( TInt aIndex ) |
|
264 { |
|
265 __VTPRINTENTER( "CVtUiColorTone.SettingPageItemChangedL" ) |
|
266 __VTPRINT2( DEBUG_GEN, "CVtUiColorTone.index=%d", aIndex ) |
|
267 if ( iFeatureManager.UiStates().ExecState() == TVtUiStates::EExecStateResetting ) |
|
268 { |
|
269 __VTPRINTEXIT( "CVtUiColorTone.SettingPageItemChangedL" ) |
|
270 return; |
|
271 } |
|
272 // Map index to right color tone value |
|
273 MVtEngCameraPreferences::TColorTone ct = MapArrayIndexToCTEnum( aIndex ); |
|
274 |
|
275 // cast the parameter |
|
276 TPtrC8 params( reinterpret_cast< TUint8* >( &ct ), |
|
277 sizeof( MVtEngCameraPreferences::TColorTone ) ); |
|
278 |
|
279 // Adjust color tone |
|
280 MVtEngMedia::TCameraId currentCamId; |
|
281 iFeatureManager.AppUi().Model().Media().GetCurrentCameraId( currentCamId ); |
|
282 if( currentCamId == MVtEngMedia::ESecondaryCamera ) |
|
283 { |
|
284 iFeatureManager.AppUi().DoExecuteCmdL( KVtEngSetColorTone, ¶ms ); |
|
285 iPendingSettingChangeCmd = EFalse; |
|
286 } |
|
287 else |
|
288 iPendingSettingChangeCmd = ETrue; |
|
289 __VTPRINTEXIT( "CVtUiColorTone.SettingPageItemChangedL" ) |
|
290 } |
|
291 |
|
292 |
|
293 // --------------------------------------------------------------------------- |
|
294 // CVtUiColorTone::CVtUiColorTone |
|
295 // --------------------------------------------------------------------------- |
|
296 // |
|
297 CVtUiColorTone::CVtUiColorTone( CVtUiFeatureManager& aFeatureManager ) |
|
298 : CVtUiPrefSettingListBase( aFeatureManager, EVtUiFeatureIdColourTone ), |
|
299 iComponentState( *this ) |
|
300 { |
|
301 __VTPRINTENTER( "UiColorTone.UiColorTone" ) |
|
302 __VTPRINTEXIT( "UiColorTone.UiColorTone" ) |
|
303 } |
|
304 |
|
305 // --------------------------------------------------------------------------- |
|
306 // CVtUiColorTone::MapCTEnumToArrayIndex |
|
307 // --------------------------------------------------------------------------- |
|
308 // |
|
309 TInt CVtUiColorTone::MapCTEnumToArrayIndex( MVtEngCameraPreferences:: |
|
310 TColorTone& aColorTone ) const |
|
311 { |
|
312 __VTPRINTENTER( "CVtUiColorTone.MapCTEnumToArrayIndex" ) |
|
313 __VTPRINT2( DEBUG_GEN, "CVtUiColorTone.cpunt=%d", iActiveItems.Count() ) |
|
314 for ( TInt i = 0; i < iActiveItems.Count(); ++i ) |
|
315 { |
|
316 if ( iActiveItems [ i ] == aColorTone ) |
|
317 { |
|
318 __VTPRINT2( DEBUG_GEN, "CVtUiColorTone.index=%d", i ) |
|
319 __VTPRINTEXIT( "CVtUiColorTone.MapCTEnumToArrayIndex" ) |
|
320 return i; |
|
321 } |
|
322 } |
|
323 __VTPRINTEXIT( "CVtUiColorTone.MapCTEnumToArrayIndex" ) |
|
324 // not found |
|
325 return KErrNotFound; |
|
326 } |
|
327 // --------------------------------------------------------------------------- |
|
328 // CVtUiColorTone::MapArrayIndexToCTEnum |
|
329 // --------------------------------------------------------------------------- |
|
330 // |
|
331 MVtEngCameraPreferences::TColorTone CVtUiColorTone::MapArrayIndexToCTEnum( |
|
332 TInt aIndex) const |
|
333 { |
|
334 __VTPRINTENTER( "TColorTone.MapArrayIndexToCTEnum" ) |
|
335 __VTPRINT2( DEBUG_GEN, "TColorTone.index=%d", aIndex ) |
|
336 __VTPRINT2( DEBUG_GEN, "TColorTone.count=%d", iActiveItems.Count() ) |
|
337 const TInt count = iActiveItems.Count(); |
|
338 if ( count > 0 && aIndex < count && aIndex >= 0 ) |
|
339 { |
|
340 __VTPRINTEXIT( "TColorTone.MapArrayIndexToCTEnum" ) |
|
341 return static_cast< MVtEngCameraPreferences::TColorTone > |
|
342 ( iActiveItems[ aIndex ] ); |
|
343 } |
|
344 else // not valid index return first item in the list |
|
345 { |
|
346 __VTPRINTEXIT( "TColorTone.MapArrayIndexToCTEnum_ERROR_INDEX" ) |
|
347 return static_cast< MVtEngCameraPreferences::TColorTone > |
|
348 ( iActiveItems[ 0 ] ); |
|
349 } |
|
350 } |
|
351 |
|
352 // --------------------------------------------------------------------------- |
|
353 // CVtUiColorTone::DoStop |
|
354 // --------------------------------------------------------------------------- |
|
355 // |
|
356 TInt CVtUiColorTone::DoStopL( TAny* aAny ) |
|
357 { |
|
358 __VTPRINTENTER( "CVtUiColorTone.DoStopL" ) |
|
359 CVtUiColorTone* self = static_cast< CVtUiColorTone* >( aAny ); |
|
360 if ( self->iFeatureState == MVtUiFeature::EActive ) |
|
361 { |
|
362 self->iFeatureManager.ComponentManager(). |
|
363 DeActivateComponentL ( MVtUiComponent::EComponentIdColorTone ); |
|
364 // set state |
|
365 self->iFeatureState = MVtUiFeature::EReady; |
|
366 } |
|
367 __VTPRINTEXIT( "CVtUiColorTone.DoStopL" ) |
|
368 return KErrNone; |
|
369 } |
|
370 |
|
371 // --------------------------------------------------------------------------- |
|
372 // CVtUiColorTone::DoStart |
|
373 // --------------------------------------------------------------------------- |
|
374 // |
|
375 TInt CVtUiColorTone::DoStartL( TAny* aAny ) |
|
376 { |
|
377 __VTPRINTENTER( "CVtUiColorTone.DoStart" ) |
|
378 CVtUiColorTone* self = static_cast< CVtUiColorTone* >( aAny ); |
|
379 self->CVtUiPrefSettingListBase::StartSettingPageL(); |
|
380 self->iFeatureManager.UiStates().SetIsCommandActivating( EFalse ); |
|
381 __VTPRINTEXIT( "CVtUiColorTone.DoStart" ) |
|
382 return KErrNone; |
|
383 } |