1 /* |
|
2 * Copyright (c) 2007-2010 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: Implements container for the user scene setup list.* |
|
15 */ |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CamUserSceneSetupContainer.h" |
|
20 #include "CamUserSceneSetupItemArray.h" |
|
21 #include "CamAppController.h" |
|
22 #include "CamSettings.hrh" |
|
23 #include "Cam.hrh" |
|
24 #include "CamPanic.h" |
|
25 #include <aknlists.h> |
|
26 #include <AknIconArray.h> |
|
27 #include <barsread.h> |
|
28 #include <aknview.h> |
|
29 #include "CameraUiConfigManager.h" |
|
30 |
|
31 #include "CamUtility.h" |
|
32 |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 |
|
36 // --------------------------------------------------------- |
|
37 // CCamUserSceneSetupContainer::NewLC |
|
38 // Symbian two-phased constructor. |
|
39 // --------------------------------------------------------- |
|
40 // |
|
41 CCamUserSceneSetupContainer* CCamUserSceneSetupContainer::NewLC |
|
42 ( const TRect& aRect, TInt aResourceId, |
|
43 CCamAppController& aController, |
|
44 CAknView& aView ) |
|
45 { |
|
46 CCamUserSceneSetupContainer* self = |
|
47 new ( ELeave ) CCamUserSceneSetupContainer( aController, |
|
48 aView ); |
|
49 CleanupStack::PushL( self ); |
|
50 self->ConstructL( aRect, aResourceId ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------- |
|
55 // CCamUserSceneSetupContainer::NewL |
|
56 // Symbian two-phased constructor. |
|
57 // --------------------------------------------------------- |
|
58 // |
|
59 CCamUserSceneSetupContainer* CCamUserSceneSetupContainer::NewL |
|
60 ( const TRect& aRect, TInt aResourceId, |
|
61 CCamAppController& aController, |
|
62 CAknView& aView ) |
|
63 { |
|
64 CCamUserSceneSetupContainer* self = |
|
65 CCamUserSceneSetupContainer::NewLC |
|
66 ( aRect, aResourceId, aController, |
|
67 aView ); |
|
68 CleanupStack::Pop( self ); |
|
69 return self; |
|
70 } |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CCamUserSceneSetupContainer::~CCamUserSceneSetupContainer |
|
74 // Destructor |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 CCamUserSceneSetupContainer::~CCamUserSceneSetupContainer() |
|
78 { |
|
79 PRINT( _L("Camera => ~CCamUserSceneSetupContainer" )) |
|
80 delete iUserSceneSetupList; |
|
81 delete iUserSceneSetupItemArray; |
|
82 PRINT( _L("Camera <= ~CCamUserSceneSetupContainer" )) |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------- |
|
86 // CCamUserSceneSetupContainer::HandleChangeInItemArrayOrVisibilityL |
|
87 // Handles a change in the item list visibility. |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 void CCamUserSceneSetupContainer::UpdateDisplayL() |
|
91 { |
|
92 ListBox()->DrawNow(); |
|
93 } |
|
94 |
|
95 // --------------------------------------------------------- |
|
96 // CCamUserSceneSetupContainer::TitlePaneTextResourceId |
|
97 // Returns the resource Id of the title for this container. |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 TInt CCamUserSceneSetupContainer::TitlePaneTextResourceId() |
|
101 { |
|
102 return iTitleResourceId; |
|
103 } |
|
104 |
|
105 // --------------------------------------------------------- |
|
106 // CCamUserSceneSetupContainer::UpdateListItems |
|
107 // Updates the list items with the settings model values. |
|
108 // --------------------------------------------------------- |
|
109 // |
|
110 void CCamUserSceneSetupContainer::UpdateListItems( void ) |
|
111 { |
|
112 TInt listItemCount = iUserSceneSetupItemArray->Count(); |
|
113 TInt i; |
|
114 for ( i = 0; i < listItemCount; ++i ) |
|
115 { |
|
116 UpdateListItem( i ); |
|
117 } |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------- |
|
121 // CCamUserSceneSetupContainer::UpdateCurrentListItem |
|
122 // Updates the current list item with it's associated |
|
123 // settings model value. |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 void CCamUserSceneSetupContainer::UpdateCurrentListItem() |
|
127 { |
|
128 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
129 if ( cba ) |
|
130 { |
|
131 CEikCba* eikCba = static_cast<CEikCba*>( cba->ButtonGroup() ); |
|
132 if( eikCba ) |
|
133 { |
|
134 // Hide LSK for single clickable settings |
|
135 eikCba->EnableItemSpecificSoftkey( ETrue ); |
|
136 } |
|
137 } |
|
138 TInt selectedItemIndex = iUserSceneSetupList->CurrentItemIndex(); |
|
139 UpdateListItem( selectedItemIndex ); |
|
140 } |
|
141 |
|
142 // --------------------------------------------------------- |
|
143 // CCamUserSceneSetupContainer::HandleListBoxEventL |
|
144 // Handles a list box event. |
|
145 // --------------------------------------------------------- |
|
146 // |
|
147 void CCamUserSceneSetupContainer::HandleListBoxEventL |
|
148 ( CEikListBox* /*aListBox*/, TListBoxEvent aEventType ) |
|
149 { |
|
150 switch( aEventType ) |
|
151 { |
|
152 case EEventEnterKeyPressed: // fallthrough |
|
153 case EEventItemDoubleClicked: |
|
154 case EEventItemSingleClicked: |
|
155 { |
|
156 HandleSelectionL(); |
|
157 } |
|
158 break; |
|
159 |
|
160 default: |
|
161 break; |
|
162 } |
|
163 } |
|
164 |
|
165 // --------------------------------------------------------- |
|
166 // CCamUserSceneSetupContainer::HandleSelectionL |
|
167 // Handles the user selection of a list item. |
|
168 // --------------------------------------------------------- |
|
169 // |
|
170 void CCamUserSceneSetupContainer::HandleSelectionL( void ) |
|
171 { |
|
172 TInt CommandId = CommandIdForActivatingCurrentItemControl(); |
|
173 CEikButtonGroupContainer* cba = CEikButtonGroupContainer::Current(); |
|
174 if ( cba && CommandId != ECamCmdCaptureSetupFlashUser ) |
|
175 { |
|
176 CEikCba* eikCba = static_cast<CEikCba*>( cba->ButtonGroup() ); |
|
177 if( eikCba ) |
|
178 { |
|
179 // Make LSK visible for the sliders. |
|
180 // Sliders, like exposure compensation, are not listboxes, |
|
181 // thus single click cannot be disabled for those. |
|
182 // All setting items, except flash, are double clickable and |
|
183 // they have a visible LSK |
|
184 eikCba->EnableItemSpecificSoftkey( EFalse ); |
|
185 } |
|
186 } |
|
187 iView.HandleCommandL( CommandId ); |
|
188 } |
|
189 |
|
190 |
|
191 |
|
192 // --------------------------------------------------------- |
|
193 // CCamUserSceneSetupContainer::CCamUserSceneSetupContainer |
|
194 // C++ constructor |
|
195 // --------------------------------------------------------- |
|
196 // |
|
197 CCamUserSceneSetupContainer::CCamUserSceneSetupContainer |
|
198 ( CCamAppController& aController, |
|
199 CAknView& aView ) |
|
200 : CCamContainerBase( aController, aView ) |
|
201 { |
|
202 |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------- |
|
206 // CCamUserSceneSetupContainer::ConstructL |
|
207 // 2nd phase constructor |
|
208 // --------------------------------------------------------- |
|
209 // |
|
210 void CCamUserSceneSetupContainer::ConstructL |
|
211 ( const TRect& aRect, TInt aResourceId ) |
|
212 { |
|
213 const TInt KSettingItemArrayGranularity = 5; |
|
214 |
|
215 CCamContainerBase::BaseConstructL( aRect ); |
|
216 |
|
217 //CreateWindowL(); |
|
218 |
|
219 // Create the listbox in the right style |
|
220 iUserSceneSetupList = new ( ELeave ) CAknSettingStyleListBox; |
|
221 iUserSceneSetupList->ConstructL( this, CEikListBox::ELeftDownInViewRect ); |
|
222 |
|
223 TPoint pos = iEikonEnv->EikAppUi()->ClientRect().iTl; |
|
224 TSize size = iUserSceneSetupList->MinimumSize(); |
|
225 SetExtent( pos, size ); |
|
226 |
|
227 |
|
228 // Setup the scroll bar |
|
229 iUserSceneSetupList->CreateScrollBarFrameL( ETrue ); |
|
230 iUserSceneSetupList->ScrollBarFrame()-> |
|
231 SetScrollBarVisibilityL( CEikScrollBarFrame::EOn, |
|
232 CEikScrollBarFrame::EAuto ); |
|
233 |
|
234 iTitleResourceId = aResourceId; |
|
235 |
|
236 |
|
237 // get array of supported resources from psi |
|
238 RArray<TInt> userSceneResourceIds; |
|
239 CleanupClosePushL( userSceneResourceIds ); |
|
240 |
|
241 User::LeaveIfError( CamUtility::GetPsiIntArrayL( ECamPsiUserSceneResourceIds, userSceneResourceIds ) ); |
|
242 |
|
243 // ...get the number of items in this user scene setup list. |
|
244 TInt itemCount = userSceneResourceIds.Count(); |
|
245 iUserSceneSetupItemArray = new ( ELeave ) |
|
246 CCamUserSceneSetupItemArray( itemCount ); |
|
247 iUserSceneSetupItemArray->ConstructL(); |
|
248 |
|
249 // Make the icon array |
|
250 CArrayPtrFlat<CGulIcon>* iconArray = new ( ELeave ) |
|
251 CAknIconArray( KSettingItemArrayGranularity ); |
|
252 CleanupStack::PushL( iconArray ); |
|
253 |
|
254 // Create all the user scene setup list items defined in the resource. |
|
255 TInt i; |
|
256 for ( i=0; i < itemCount; ++i ) |
|
257 { |
|
258 CCamUserSceneSetupListItem* listItem = |
|
259 CCamUserSceneSetupListItem::NewL( userSceneResourceIds[i] ); |
|
260 CleanupStack::PushL( listItem ); |
|
261 // Ownership is transferred |
|
262 iUserSceneSetupItemArray->AppendL( listItem ); |
|
263 CleanupStack::Pop( listItem ); |
|
264 } |
|
265 |
|
266 |
|
267 // Update the display |
|
268 UpdateDisplayL(); |
|
269 |
|
270 // Looks like we have no choice but to give ownership |
|
271 // of this to the listbox. |
|
272 // There is no flag as there is for the item data |
|
273 ListBox()->ItemDrawer()->FormattedCellData()->SetIconArrayL( iconArray ); |
|
274 |
|
275 // iconArray now has ownership transferred |
|
276 CleanupStack::Pop( iconArray ); |
|
277 |
|
278 CleanupStack::PopAndDestroy( &userSceneResourceIds ); |
|
279 |
|
280 CTextListBoxModel* model= iUserSceneSetupList->Model(); |
|
281 model->SetItemTextArray( iUserSceneSetupItemArray ); |
|
282 // Ownership retained by SettingItemList |
|
283 model->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
284 |
|
285 TAknLayoutRect layoutRect; |
|
286 layoutRect.LayoutRect( TRect( |
|
287 TPoint( 0, 0 ), iAvkonAppUi->ClientRect().Size() ), |
|
288 AKN_LAYOUT_WINDOW_list_gen_pane( 0 ) ); |
|
289 iUserSceneSetupList->SetRect( layoutRect.Rect() ); |
|
290 |
|
291 ListBox()->SetCurrentItemIndex( 0 ); |
|
292 ListBox()->SetListBoxObserver( this ); |
|
293 ListBox()->UpdateScrollBarsL(); |
|
294 |
|
295 SetRect( aRect ); |
|
296 ActivateL(); |
|
297 |
|
298 UpdateListItems(); |
|
299 } |
|
300 |
|
301 |
|
302 |
|
303 // --------------------------------------------------------- |
|
304 // CCamUserSceneSetupContainer::UpdateListItem |
|
305 // Updates a list item with its corresponding settings model value. |
|
306 // --------------------------------------------------------- |
|
307 // |
|
308 void CCamUserSceneSetupContainer::UpdateListItem( TInt aIndex ) |
|
309 { |
|
310 // Get the current value for this list item from the settings model. |
|
311 // ...get settings model id for list item. |
|
312 TInt settingsModelId = |
|
313 iUserSceneSetupItemArray->At( aIndex )->SettingsModelTypeId(); |
|
314 if ( settingsModelId != ECamSettingItemUserSceneReset ) |
|
315 { |
|
316 // ...use id to get current value. |
|
317 TInt currentVal = iController.IntegerSettingValue( settingsModelId ); |
|
318 |
|
319 // Update list item with the current value. |
|
320 iUserSceneSetupItemArray->At( aIndex )->SetCurrentValue( currentVal ); |
|
321 } |
|
322 } |
|
323 |
|
324 |
|
325 // ---------------------------------------------------- |
|
326 // CCamUserSceneSetupContainer::CommandIdForActivatingCurrentItemControl |
|
327 // Returns the command id for activating the current list item control. |
|
328 // ---------------------------------------------------- |
|
329 // |
|
330 TInt CCamUserSceneSetupContainer::CommandIdForActivatingCurrentItemControl() |
|
331 { |
|
332 // Get the settings model type id for the selected item. |
|
333 // ...get settings model id for list item. |
|
334 TInt currentIndex = iUserSceneSetupList->CurrentItemIndex(); |
|
335 |
|
336 // ...get settings model id for list item. |
|
337 TInt settingsModelId = |
|
338 iUserSceneSetupItemArray->At( currentIndex )-> |
|
339 SettingsModelTypeId(); |
|
340 // Convert settings model id to command id that activates the |
|
341 // control for the selected item. |
|
342 TInt commandId = -1; |
|
343 switch ( settingsModelId ) |
|
344 { |
|
345 case ECamSettingItemUserSceneBasedOnScene: |
|
346 { |
|
347 commandId = ECamCmdCaptureSetupSceneUser; |
|
348 } |
|
349 break; |
|
350 case ECamSettingItemUserSceneWhitebalance: |
|
351 { |
|
352 commandId = ECamCmdCaptureSetupWhiteBalanceUser; |
|
353 } |
|
354 break; |
|
355 case ECamSettingItemUserSceneExposure: |
|
356 { |
|
357 commandId = ECamCmdCaptureSetupExposureUser; |
|
358 } |
|
359 break; |
|
360 case ECamSettingItemUserSceneColourFilter: |
|
361 { |
|
362 commandId = ECamCmdCaptureSetupColourFilterUser; |
|
363 } |
|
364 break; |
|
365 case ECamSettingItemUserSceneFlash: |
|
366 { |
|
367 commandId = ECamCmdCaptureSetupFlashUser; |
|
368 } |
|
369 break; |
|
370 case ECamSettingItemUserSceneReset: |
|
371 { |
|
372 commandId = ECamCmdUserSceneReset; |
|
373 } |
|
374 break; |
|
375 case ECamSettingItemUserSceneBrightness: |
|
376 { |
|
377 commandId = ECamCmdCaptureSetupBrightnessUser; |
|
378 } |
|
379 break; |
|
380 case ECamSettingItemUserSceneContrast: |
|
381 { |
|
382 commandId = ECamCmdCaptureSetupContrastUser; |
|
383 } |
|
384 break; |
|
385 |
|
386 case ECamSettingItemUserSceneImageSharpness: |
|
387 { |
|
388 commandId = ECamCmdCaptureSetupImageSharpnessUser; |
|
389 } |
|
390 break; |
|
391 |
|
392 case ECamSettingItemUserSceneLightSensitivity: |
|
393 { |
|
394 commandId = ECamCmdCaptureSetupLightSensitivityUser; |
|
395 } |
|
396 break; |
|
397 case ECamSettingItemUserSceneDefault: |
|
398 { |
|
399 commandId = ECamCmdSetUserDefault; |
|
400 } |
|
401 break; |
|
402 default: |
|
403 { |
|
404 CamPanic( ECamPanicCaptureSetupMenuUnknownItem ); |
|
405 } |
|
406 } |
|
407 return commandId; |
|
408 } |
|
409 |
|
410 |
|
411 |
|
412 // --------------------------------------------------------- |
|
413 // CCamUserSceneSetupContainer::CountComponentControls |
|
414 // --------------------------------------------------------- |
|
415 // |
|
416 TInt CCamUserSceneSetupContainer::CountComponentControls() const |
|
417 { |
|
418 return CCamContainerBase::CountComponentControls() + 1; |
|
419 } |
|
420 |
|
421 // --------------------------------------------------------- |
|
422 // CCamUserSceneSetupContainer::ComponentControl |
|
423 // --------------------------------------------------------- |
|
424 // |
|
425 CCoeControl* CCamUserSceneSetupContainer::ComponentControl |
|
426 ( TInt aIndex ) const |
|
427 { |
|
428 CCoeControl* control = CCamContainerBase::ComponentControl( aIndex ); |
|
429 if( control ) |
|
430 return control; |
|
431 switch( aIndex ) |
|
432 { |
|
433 case 1: |
|
434 { |
|
435 control = iUserSceneSetupList; |
|
436 } |
|
437 break; |
|
438 default: |
|
439 break; |
|
440 } |
|
441 |
|
442 return control; |
|
443 } |
|
444 |
|
445 // --------------------------------------------------------------------------- |
|
446 // CCamUserSceneSetupContainer::OfferKeyEventL |
|
447 // Key event handling |
|
448 // --------------------------------------------------------------------------- |
|
449 // |
|
450 TKeyResponse CCamUserSceneSetupContainer::OfferKeyEventL( |
|
451 const TKeyEvent& aKeyEvent, |
|
452 TEventCode aType ) |
|
453 { |
|
454 if ( aType == EEventKey && |
|
455 ( aKeyEvent.iScanCode == EStdKeyEnter || |
|
456 aKeyEvent.iScanCode == EStdKeyNkpEnter ) ) |
|
457 { |
|
458 HandleSelectionL(); |
|
459 return EKeyWasConsumed; |
|
460 } |
|
461 else if ( aKeyEvent.iScanCode == EStdKeyUpArrow || |
|
462 aKeyEvent.iScanCode == EStdKeyDownArrow ) |
|
463 { |
|
464 return iUserSceneSetupList->OfferKeyEventL( aKeyEvent, aType ); |
|
465 } |
|
466 else |
|
467 { |
|
468 return EKeyWasNotConsumed; |
|
469 } |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------------------------- |
|
473 // CCamUserSceneSetupContainer::ListBox |
|
474 // Returns a pointer to the list box |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 CEikFormattedCellListBox* CCamUserSceneSetupContainer::ListBox() |
|
478 { |
|
479 return ( iUserSceneSetupList ); |
|
480 } |
|
481 |
|
482 // --------------------------------------------------------------------------- |
|
483 // CCamUserSceneSetupContainer::IsUserSceneResetHighlighted |
|
484 // Returns wheather user scene restore is highlighted |
|
485 // --------------------------------------------------------------------------- |
|
486 // |
|
487 TBool CCamUserSceneSetupContainer::IsUserSceneResetHighlighted() |
|
488 { |
|
489 TInt currentIndex = iUserSceneSetupList->CurrentItemIndex(); |
|
490 // ...get settings model id for list item. |
|
491 TInt settingsModelId = |
|
492 iUserSceneSetupItemArray->At( currentIndex )->SettingsModelTypeId(); |
|
493 if ( settingsModelId == ECamSettingItemUserSceneReset ) |
|
494 { |
|
495 return ETrue; |
|
496 } |
|
497 else |
|
498 { |
|
499 return EFalse; |
|
500 } |
|
501 } |
|
502 |
|
503 // End of File |
|