1 /* |
|
2 * Copyright (c) 2007 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: Implementation of the mode setup pane handler class. |
|
15 * |
|
16 * Copyright © 2007 Nokia. All rights reserved. |
|
17 * This material, including documentation and any related computer |
|
18 * programs, is protected by copyright controlled by Nokia. All |
|
19 * rights are reserved. Copying, including reproducing, storing, |
|
20 * adapting or translating, any or all of this material requires the |
|
21 * prior written consent of Nokia. This material also contains |
|
22 * confidential information which may not be disclosed to others |
|
23 * without the prior written consent of Nokia. |
|
24 |
|
25 * |
|
26 * |
|
27 */ |
|
28 |
|
29 |
|
30 #include <coemain.h> |
|
31 #include <barsRead.h> |
|
32 #include <stringloader.h> |
|
33 #include "CamModeSetupPaneHandler.h" |
|
34 #include "CamSetupPaneItemArray.h" |
|
35 #include "CamSetupPane.h" |
|
36 #include "CamSetupPaneItem.h" |
|
37 #include "CamPreCaptureContainerBase.h" |
|
38 #include "CamAppUi.h" |
|
39 #include <cameraapp.rsg> |
|
40 #include <vgacamsettings.rsg> |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CCamModeSetupPaneHandler::NewLC |
|
44 // Part of the two-phase class construction. |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CCamModeSetupPaneHandler* CCamModeSetupPaneHandler::NewLC( CCamAppController& aController ) |
|
48 { |
|
49 CCamModeSetupPaneHandler* self = new( ELeave ) CCamModeSetupPaneHandler(aController); |
|
50 CleanupStack::PushL( self ); |
|
51 self->ConstructL(); |
|
52 return self; |
|
53 } |
|
54 |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CCamModeSetupPaneHandler::NewL |
|
58 // Part of the two-phase class construction. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 CCamModeSetupPaneHandler* CCamModeSetupPaneHandler::NewL( CCamAppController& aController ) |
|
62 { |
|
63 CCamModeSetupPaneHandler* self = CCamModeSetupPaneHandler::NewLC( aController ); |
|
64 CleanupStack::Pop(self); |
|
65 return self; |
|
66 } |
|
67 |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CCamModeSetupPaneHandler::CCamModeSetupPaneHandler |
|
71 // C++ class constructor. |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 CCamModeSetupPaneHandler::CCamModeSetupPaneHandler( CCamAppController& aController ) |
|
75 : iController( aController ), |
|
76 iPaneLevel( EMenuLevel ) |
|
77 { |
|
78 } |
|
79 |
|
80 |
|
81 // ----------------------------------------------------------------------------- |
|
82 // CCamModeSetupPaneHandler::ConstructL |
|
83 // Carries out two-phase class construction. |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 void CCamModeSetupPaneHandler::ConstructL() |
|
87 { |
|
88 // Setup helper context |
|
89 iLastCaptureHelper = iController.LastCaptureHelper(); |
|
90 iLastCaptureHelper->SetPaneModel( this ); // register |
|
91 |
|
92 iCurrentSettingsArrayIndex = KErrNotFound; // Invalidate. |
|
93 } |
|
94 |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CCamModeSetupPaneHandler::~CCamModeSetupPaneHandler |
|
98 // C++ destructor. |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 CCamModeSetupPaneHandler::~CCamModeSetupPaneHandler() |
|
102 { |
|
103 PRINT( _L("Camera => ~CCamModeSetupPaneHandler") ); |
|
104 ResetArray(); |
|
105 |
|
106 iPaneControl = NULL; // Not owned. |
|
107 |
|
108 if ( iLastCaptureHelper ) |
|
109 { |
|
110 iLastCaptureHelper->SetPaneModel( NULL ); // de-register |
|
111 iLastCaptureHelper = NULL; // Not owned |
|
112 } |
|
113 |
|
114 delete iLastCapTitle; |
|
115 PRINT( _L("Camera <= ~CCamModeSetupPaneHandler") ); |
|
116 } |
|
117 |
|
118 |
|
119 // ----------------------------------------------------------------------------- |
|
120 // CCamModeSetupPaneHandler::ResetArray |
|
121 // Deletes the contents of the settings item array |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void CCamModeSetupPaneHandler::ResetArray() |
|
125 { |
|
126 TInt i; |
|
127 for ( i = 0; i < iNoOfSettingsItems; i++ ) |
|
128 { |
|
129 delete iSettingItems[i]; |
|
130 iSettingItems[i] = NULL; |
|
131 } |
|
132 } |
|
133 |
|
134 // ----------------------------------------------------------------------------- |
|
135 // CCamModeSetupPaneHandler::HandleEvent |
|
136 // |
|
137 // ----------------------------------------------------------------------------- |
|
138 // |
|
139 void CCamModeSetupPaneHandler::HandleEvent( TEvent aEvent ) |
|
140 { |
|
141 switch ( aEvent ) |
|
142 { |
|
143 case EEventSelect: |
|
144 { |
|
145 // ASSERT(iPaneLevel == EItemLevel); // Should only get this event for item-level selections. |
|
146 // Eventually need to handle commands from captureViewBase to open menu items. |
|
147 // Let OK button open them for now... |
|
148 if ( iPaneLevel == EItemLevel ) |
|
149 { |
|
150 HandlePaneItemLevelSelection(); |
|
151 } |
|
152 else |
|
153 { |
|
154 if ( iPaneLevel == EMenuLevel && |
|
155 IconIsThumbnail( iHighlightedItemIndex ) ) |
|
156 { |
|
157 HandleLastCaptureSelection(); |
|
158 } |
|
159 else |
|
160 { |
|
161 HandlePaneMenuLevelSelection( iController.IntegerSettingValue( HighlightedItemId() ) ); |
|
162 } |
|
163 } |
|
164 break; |
|
165 } |
|
166 case EEventCancel: |
|
167 { |
|
168 HandlePaneCancel(); |
|
169 break; |
|
170 } |
|
171 case EEventLeft: |
|
172 { |
|
173 MoveToPreviousItem(); |
|
174 break; |
|
175 } |
|
176 case EEventRight: |
|
177 { |
|
178 MoveToNextItem(); |
|
179 break; |
|
180 } |
|
181 case EEventEditUser: |
|
182 { |
|
183 SwitchToUserSceneView(); |
|
184 break; |
|
185 } |
|
186 default: |
|
187 { |
|
188 break; |
|
189 } |
|
190 |
|
191 } |
|
192 } |
|
193 |
|
194 |
|
195 // ----------------------------------------------------------------------------- |
|
196 // CCamModeSetupPaneHandler::MoveToPreviousItem |
|
197 // Changes the highlighted item to the previous one. |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 void CCamModeSetupPaneHandler::MoveToPreviousItem() |
|
201 { |
|
202 iPaneControl->ScrollToPreviousItem(); |
|
203 iHighlightedItemIndex--; |
|
204 if ( iHighlightedItemIndex < 0 ) |
|
205 { |
|
206 iHighlightedItemIndex = NumberOfItems() - 1; |
|
207 } |
|
208 HandlePaneItemChanged(); |
|
209 } |
|
210 |
|
211 |
|
212 // ----------------------------------------------------------------------------- |
|
213 // CCamModeSetupPaneHandler::MoveToNextItem |
|
214 // Changes the highlighted item to the next one. |
|
215 // ----------------------------------------------------------------------------- |
|
216 // |
|
217 void CCamModeSetupPaneHandler::MoveToNextItem() |
|
218 { |
|
219 iPaneControl->ScrollToNextItem(); |
|
220 iHighlightedItemIndex++; |
|
221 if ( iHighlightedItemIndex >= NumberOfItems() ) |
|
222 { |
|
223 iHighlightedItemIndex = 0; |
|
224 } |
|
225 HandlePaneItemChanged(); |
|
226 } |
|
227 |
|
228 |
|
229 // ----------------------------------------------------------------------------- |
|
230 // CCamModeSetupPaneHandler::HighlightedItemId |
|
231 // Returns the id of the currently highlighted item. |
|
232 // ----------------------------------------------------------------------------- |
|
233 // |
|
234 TInt CCamModeSetupPaneHandler::HighlightedItemId() const |
|
235 { |
|
236 if ( iPaneLevel == EMenuLevel ) |
|
237 { |
|
238 return iMenuItemIds[iHighlightedItemIndex]; |
|
239 } |
|
240 else |
|
241 { |
|
242 ASSERT( iPaneLevel == EItemLevel ); |
|
243 ASSERT( iCurrentSettingsArrayIndex != KErrNotFound ); |
|
244 return iSettingItems[iCurrentSettingsArrayIndex]->At( HighlightedItemIndex() )->Id(); |
|
245 } |
|
246 } |
|
247 |
|
248 |
|
249 // ----------------------------------------------------------------------------- |
|
250 // CCamModeSetupPaneHandler::NumberOfItems |
|
251 // Returns the number of items in the current pane model. |
|
252 // ----------------------------------------------------------------------------- |
|
253 // |
|
254 TInt CCamModeSetupPaneHandler::NumberOfItems() const |
|
255 { |
|
256 if ( iPaneLevel == EMenuLevel ) |
|
257 { |
|
258 TInt items = iNoOfSettingsItems; |
|
259 // Check if there is a "last capture" dynamic item to add |
|
260 if ( iLastCaptureHelper->IsThumbValid() ) |
|
261 { |
|
262 items ++; // +1 for dynamic 'last picture taken' item |
|
263 } |
|
264 return items; |
|
265 } |
|
266 else |
|
267 { |
|
268 ASSERT( iPaneLevel == EItemLevel ); |
|
269 ASSERT( iCurrentSettingsArrayIndex != KErrNotFound ); |
|
270 return iSettingItems[iCurrentSettingsArrayIndex]->Count(); |
|
271 } |
|
272 } |
|
273 |
|
274 |
|
275 // ----------------------------------------------------------------------------- |
|
276 // CCamModeSetupPaneHandler::TitleText |
|
277 // Returns the current pane title text (for the highlighted pane item). |
|
278 // ----------------------------------------------------------------------------- |
|
279 // |
|
280 const TDesC& CCamModeSetupPaneHandler::TitleText() const |
|
281 { |
|
282 if ( iPaneLevel == EMenuLevel ) |
|
283 { |
|
284 return iMenuTitles[iHighlightedItemIndex]; |
|
285 } |
|
286 else |
|
287 { |
|
288 ASSERT( iPaneLevel == EItemLevel ); |
|
289 ASSERT( iCurrentSettingsArrayIndex != KErrNotFound ); |
|
290 return iMenuTitles[iCurrentSettingsArrayIndex]; |
|
291 } |
|
292 } |
|
293 |
|
294 |
|
295 // ----------------------------------------------------------------------------- |
|
296 // CCamModeSetupPaneHandler::DescriptorText |
|
297 // Returns the current pane descriptor text (for the highlighted pane item). |
|
298 // ----------------------------------------------------------------------------- |
|
299 // |
|
300 const TDesC& CCamModeSetupPaneHandler::DescriptorText() const |
|
301 { |
|
302 if ( iPaneLevel == EMenuLevel ) |
|
303 { |
|
304 if ( iHighlightedItemIndex < iNoOfSettingsItems ) |
|
305 { |
|
306 const TInt settingVal = iController.IntegerSettingValue( HighlightedItemId() ); |
|
307 const TInt index = iSettingItems[iHighlightedItemIndex]->ItemIndexFromItemId( settingVal ); |
|
308 if ( index != KErrNotFound ) |
|
309 { |
|
310 return iSettingItems[iHighlightedItemIndex]->At( index )->Text(); |
|
311 } |
|
312 } |
|
313 else |
|
314 { |
|
315 ASSERT( iHighlightedItemIndex == iNoOfSettingsItems ); |
|
316 |
|
317 // Return filename of last taken picture. |
|
318 return iLastCapName; |
|
319 } |
|
320 } |
|
321 else |
|
322 { |
|
323 ASSERT( iPaneLevel == EItemLevel ); |
|
324 ASSERT( iCurrentSettingsArrayIndex != KErrNotFound ); |
|
325 return iSettingItems[iCurrentSettingsArrayIndex]->At( iHighlightedItemIndex )->Text(); |
|
326 } |
|
327 |
|
328 return KNullDesC; // All else failed. |
|
329 } |
|
330 |
|
331 |
|
332 // ----------------------------------------------------------------------------- |
|
333 // CCamModeSetupPaneHandler::Icon |
|
334 // Returns the icon for the given pane item index. |
|
335 // ----------------------------------------------------------------------------- |
|
336 // |
|
337 CGulIcon& CCamModeSetupPaneHandler::Icon( TInt aItemIndex ) |
|
338 { |
|
339 ASSERT( aItemIndex >= 0 && aItemIndex < NumberOfItems() ); |
|
340 |
|
341 if ( iPaneLevel == EMenuLevel ) |
|
342 { |
|
343 if ( aItemIndex < iNoOfSettingsItems ) |
|
344 { |
|
345 const TInt settingVal = iController.IntegerSettingValue( iMenuItemIds[aItemIndex] ); |
|
346 const TInt index = iSettingItems[aItemIndex]->ItemIndexFromItemId( settingVal ); |
|
347 if ( index != KErrNotFound ) |
|
348 { |
|
349 return iSettingItems[aItemIndex]->At( index )->Icon(); |
|
350 } |
|
351 } |
|
352 } |
|
353 else |
|
354 { |
|
355 ASSERT( iPaneLevel == EItemLevel ); |
|
356 ASSERT( iCurrentSettingsArrayIndex != KErrNotFound ); |
|
357 return iSettingItems[iCurrentSettingsArrayIndex]->At( aItemIndex )->Icon(); |
|
358 } |
|
359 |
|
360 // Must return something. |
|
361 return iSettingItems[aItemIndex]->At( 0 )->Icon(); |
|
362 } |
|
363 |
|
364 // ----------------------------------------------------------------------------- |
|
365 // CCamModeSetupPaneHandler::Thumbnail |
|
366 // Get the thumbnail (of specified size) for last captured icon |
|
367 // ----------------------------------------------------------------------------- |
|
368 // |
|
369 CGulIcon& CCamModeSetupPaneHandler::Thumbnail( TBool aSmall ) |
|
370 { |
|
371 return *iLastCaptureHelper->Thumbnail( aSmall ); |
|
372 } |
|
373 |
|
374 |
|
375 // ----------------------------------------------------------------------------- |
|
376 // CCamModeSetupPaneHandler::IconIsThumbnail |
|
377 // Returns whether item indicated by aItemIndex is the last captured thumbnail |
|
378 // ----------------------------------------------------------------------------- |
|
379 // |
|
380 TBool CCamModeSetupPaneHandler::IconIsThumbnail( TInt aItemIndex ) const |
|
381 { |
|
382 // Thumbnail is always the last item so check the specified index is the |
|
383 // last item. Also check that the thumbnail is valid. |
|
384 if ( aItemIndex == iNoOfSettingsItems && |
|
385 iPaneLevel == EMenuLevel && |
|
386 iLastCaptureHelper->IsThumbValid() ) |
|
387 { |
|
388 return ETrue; |
|
389 } |
|
390 else |
|
391 { |
|
392 return EFalse; |
|
393 } |
|
394 } |
|
395 |
|
396 |
|
397 // ----------------------------------------------------------------------------- |
|
398 // CCamModeSetupPaneHandler::HighlightedItemIndex |
|
399 // Returns the currently highlighted pane item. |
|
400 // ----------------------------------------------------------------------------- |
|
401 // |
|
402 TInt CCamModeSetupPaneHandler::HighlightedItemIndex() const |
|
403 { |
|
404 return iHighlightedItemIndex; |
|
405 } |
|
406 |
|
407 |
|
408 // ----------------------------------------------------------------------------- |
|
409 // CCamModeSetupPaneHandler::HandlePaneItemChanged |
|
410 // Handles a change of the currently highlighted pane item. |
|
411 // ----------------------------------------------------------------------------- |
|
412 // |
|
413 void CCamModeSetupPaneHandler::HandlePaneItemChanged() |
|
414 { |
|
415 if ( iPaneLevel == EItemLevel ) |
|
416 { |
|
417 HandlePaneItemLevelItemChanged(); |
|
418 } |
|
419 } |
|
420 |
|
421 |
|
422 // ----------------------------------------------------------------------------- |
|
423 // CCamModeSetupPaneHandler::HandlePaneItemLevelItemChanged |
|
424 // Handles a change of the current item at the 'item' level. |
|
425 // ----------------------------------------------------------------------------- |
|
426 // |
|
427 void CCamModeSetupPaneHandler::HandlePaneItemLevelItemChanged() |
|
428 { |
|
429 ASSERT( iPaneLevel == EItemLevel ); |
|
430 ASSERT( iCurrentSettingsArrayIndex != KErrNotFound ); |
|
431 |
|
432 // Showing a Scene item requires the Options menu, and setting of the current highlighted item |
|
433 if ( ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicPhotoScene ) || |
|
434 ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicVideoScene ) |
|
435 || ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemUserSceneBasedOnScene ) ) |
|
436 { |
|
437 CCamPreCaptureContainerBase* parent = static_cast<CCamPreCaptureContainerBase*>( iParent ); |
|
438 parent->SetCurrentSetupPaneItem( HighlightedItemId() ); |
|
439 } |
|
440 |
|
441 else |
|
442 { |
|
443 // Set the controller to preview the new setting. |
|
444 // This will either be comitted by a "Select" or reverted by a "Cancel" |
|
445 TRAPD( ignore, iController.PreviewSettingChangeL( iMenuItemIds[iCurrentSettingsArrayIndex], HighlightedItemId() ); ) |
|
446 if ( ignore ) |
|
447 { |
|
448 // Do nothing ( removes build warning ) |
|
449 } |
|
450 } |
|
451 |
|
452 |
|
453 |
|
454 } |
|
455 |
|
456 |
|
457 // ----------------------------------------------------------------------------- |
|
458 // CCamModeSetupPaneHandler::HandlePaneMenuLevelSelection |
|
459 // Handles pane selections made at the 'menu' level. |
|
460 // ----------------------------------------------------------------------------- |
|
461 // |
|
462 void CCamModeSetupPaneHandler::HandlePaneMenuLevelSelection( TInt aValueToBeHighlighted ) |
|
463 { |
|
464 ASSERT( iPaneLevel == EMenuLevel ); |
|
465 |
|
466 if ( iHighlightedItemIndex < iNoOfSettingsItems ) |
|
467 { |
|
468 iCurrentSettingsArrayIndex = iHighlightedItemIndex; |
|
469 iHighlightedItemIndex = iSettingItems[iCurrentSettingsArrayIndex]->ItemIndexFromItemId( aValueToBeHighlighted ); |
|
470 iPaneLevel = EItemLevel; |
|
471 iPaneControl->HandleModelChanged(); |
|
472 |
|
473 // Showing a Scene item requires the Options menu, and setting of the current highlighted item |
|
474 if ( ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicPhotoScene ) || |
|
475 ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicVideoScene ) || |
|
476 ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemUserSceneBasedOnScene ) ) |
|
477 { |
|
478 CCamPreCaptureContainerBase* parent = static_cast<CCamPreCaptureContainerBase*>( iParent ); |
|
479 parent->SetUseSetupPaneOptions( ETrue ); |
|
480 parent->SetCurrentSetupPaneItem( HighlightedItemId() ); |
|
481 } |
|
482 |
|
483 // Check whether the viewfinder should be active but masked to |
|
484 // preview some settings values |
|
485 if ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicPhotoWhiteBalance || |
|
486 iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicPhotoColourFilter || |
|
487 iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicPhotoBrightness || |
|
488 iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicPhotoContrast || |
|
489 iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicVideoWhiteBalance || |
|
490 iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicVideoColourFilter || |
|
491 iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicVideoBrightness || |
|
492 iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicVideoContrast || |
|
493 iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemUserSceneWhitebalance || |
|
494 iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemUserSceneColourFilter |
|
495 |
|
496 ) |
|
497 { |
|
498 CCamPreCaptureContainerBase* parent = static_cast<CCamPreCaptureContainerBase*>( iParent ); |
|
499 parent->SetViewFinderState( CCamPreCaptureContainerBase::EVfStateActiveMasked ); |
|
500 } |
|
501 } |
|
502 } |
|
503 |
|
504 |
|
505 // ----------------------------------------------------------------------------- |
|
506 // CCamModeSetupPaneHandler::HandleLastCaptureSelection |
|
507 // Handles user selection of the "LastCapture" thumbnail where available |
|
508 // ----------------------------------------------------------------------------- |
|
509 // |
|
510 void CCamModeSetupPaneHandler::HandleLastCaptureSelection() |
|
511 { |
|
512 // Check we have a valid thumbnail |
|
513 if ( IconIsThumbnail( iHighlightedItemIndex ) ) |
|
514 { |
|
515 // Need to fire off post capture view with the snapshot. |
|
516 TRAPD( err, iLastCaptureHelper->ShowPostCaptureViewL() ); |
|
517 if ( err == KErrNoMemory ) |
|
518 { |
|
519 TRAPD( ignore, static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() )->ShowOOMNoteL() ); |
|
520 if ( ignore ) |
|
521 { |
|
522 // Do nothing ( removes build warning ) |
|
523 } |
|
524 } |
|
525 } |
|
526 } |
|
527 |
|
528 // ----------------------------------------------------------------------------- |
|
529 // CCamModeSetupPaneHandler::ActivateMenuItem |
|
530 // Activates a particular sub-menu. |
|
531 // ----------------------------------------------------------------------------- |
|
532 // |
|
533 void CCamModeSetupPaneHandler::ActivateMenuItem( TInt aItemId ) |
|
534 { |
|
535 // Set the current item in the main menu to the item that is to be activated. |
|
536 iHighlightedItemIndex = iNoOfSettingsItems; |
|
537 TInt i; |
|
538 for ( i = 0; i < iNoOfSettingsItems; ++i ) |
|
539 { |
|
540 if ( iMenuItemIds[i] == aItemId ) |
|
541 { |
|
542 iHighlightedItemIndex = i; |
|
543 break; |
|
544 } |
|
545 } |
|
546 ASSERT( iHighlightedItemIndex != iNoOfSettingsItems ); |
|
547 |
|
548 // If the user has just exited the User scene setup, and entered scene pane, |
|
549 // ensure that the user scene is the highlighted scene. |
|
550 if ( aItemId == ECamSettingItemDynamicPhotoScene ) |
|
551 { |
|
552 HandlePaneMenuLevelSelection( ECamSceneUser ); |
|
553 } |
|
554 // Otherwise, ensure that the current setting value is highlighted. |
|
555 else |
|
556 { |
|
557 HandlePaneMenuLevelSelection( iController.IntegerSettingValue( HighlightedItemId() ) ); |
|
558 } |
|
559 } |
|
560 |
|
561 // ----------------------------------------------------------------------------- |
|
562 // CCamModeSetupPaneHandler::HandlePaneItemLevelSelection |
|
563 // Handles pane selections made at the 'item' level. |
|
564 // ----------------------------------------------------------------------------- |
|
565 // |
|
566 void CCamModeSetupPaneHandler::HandlePaneItemLevelSelection() |
|
567 { |
|
568 ASSERT( iPaneLevel == EItemLevel ); // Should only receive 'item' level IDs, not top level 'menu' IDs. |
|
569 ASSERT( iCurrentSettingsArrayIndex != KErrNotFound ); |
|
570 |
|
571 // If current Item was a photo-scene item, the new (cancelled) state will not |
|
572 // need the "options" menu or the current Item information, and the viewfinder |
|
573 // can be activated. |
|
574 if ( ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicPhotoScene ) || |
|
575 ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicVideoScene ) ) |
|
576 |
|
577 { |
|
578 TRAPD( ignore, iController.SetIntegerSettingValueL( iMenuItemIds[iCurrentSettingsArrayIndex], HighlightedItemId() ); ) |
|
579 if ( ignore ) |
|
580 { |
|
581 // Do nothing ( removes build warning ) |
|
582 } |
|
583 CCamPreCaptureContainerBase* parent = static_cast<CCamPreCaptureContainerBase*>( iParent ); |
|
584 parent->SetUseSetupPaneOptions( EFalse ); |
|
585 parent->SetCurrentSetupPaneItem( KErrNotFound ); // Invalidate |
|
586 parent->SetViewFinderState( CCamPreCaptureContainerBase::EVfStateActive ); // Ensure reverted viewfinder |
|
587 } |
|
588 // else if current item is user scene base on scene item, the new (cancelled) state will not |
|
589 // need the "options" menu or the current Item information. |
|
590 else if ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemUserSceneBasedOnScene ) |
|
591 { |
|
592 TRAPD( ignore, iController.SetIntegerSettingValueL( iMenuItemIds[iCurrentSettingsArrayIndex], HighlightedItemId() ); ) |
|
593 if ( ignore ) |
|
594 { |
|
595 // Do nothing ( removes build warning ) |
|
596 } |
|
597 CCamPreCaptureContainerBase* parent = static_cast<CCamPreCaptureContainerBase*>( iParent ); |
|
598 parent->SetUseSetupPaneOptions( EFalse ); |
|
599 parent->SetCurrentSetupPaneItem( KErrNotFound ); // Invalidate |
|
600 } |
|
601 else |
|
602 { |
|
603 // User has selected the highlighted item, so tell controller to commit this setting |
|
604 iController.CommitPreviewChanges(); |
|
605 } |
|
606 |
|
607 iHighlightedItemIndex = iCurrentSettingsArrayIndex; |
|
608 iCurrentSettingsArrayIndex = KErrNotFound; // Invalidate. |
|
609 |
|
610 // If in user scene mode revert back to the user scene setup list. |
|
611 if ( iUserSceneSetupMode ) |
|
612 { |
|
613 SwitchToUserSceneView(); |
|
614 } |
|
615 |
|
616 // else revert back to menu level, and remove focus from setup pane. |
|
617 else |
|
618 { |
|
619 iPaneLevel = EMenuLevel; |
|
620 iPaneControl->HandleModelChanged(); |
|
621 |
|
622 // Select-key focus goes back to viewfinder |
|
623 CCamPreCaptureContainerBase* parent = static_cast<CCamPreCaptureContainerBase*>( iParent ); |
|
624 parent->FocusToSetupPane( EFalse ); |
|
625 } |
|
626 } |
|
627 |
|
628 |
|
629 // ----------------------------------------------------------------------------- |
|
630 // CCamModeSetupPaneHandler::SwitchToUserSceneView |
|
631 // Switches view to the user scene view. |
|
632 // ----------------------------------------------------------------------------- |
|
633 // |
|
634 void CCamModeSetupPaneHandler::SwitchToUserSceneView() |
|
635 { |
|
636 CCamAppUiBase* appUi = static_cast<CCamAppUiBase*>( CEikonEnv::Static()->AppUi() ); |
|
637 TRAPD( ignore, appUi->HandleCommandL( ECamCmdUserScene ) ) |
|
638 if ( ignore ) |
|
639 { |
|
640 // Do nothing ( removes build warning ) |
|
641 } |
|
642 } |
|
643 |
|
644 |
|
645 // ----------------------------------------------------------------------------- |
|
646 // CCamModeSetupPaneHandler::HandlePaneCancel |
|
647 // Handles the user Cancelling from the setup pane. Will revert to last selected |
|
648 // menu level and force a redraw |
|
649 // ----------------------------------------------------------------------------- |
|
650 // |
|
651 void CCamModeSetupPaneHandler::HandlePaneCancel() |
|
652 { |
|
653 if ( iPaneLevel == EItemLevel ) |
|
654 { |
|
655 ASSERT( iCurrentSettingsArrayIndex != KErrNotFound ); |
|
656 // If current Item was a photo-scene item, the new (cancelled) state will not |
|
657 // need the "options" menu or the current Item information, and the viewfinder |
|
658 // can be activated. |
|
659 if ( ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicPhotoScene ) || |
|
660 ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemDynamicVideoScene ) ) |
|
661 { |
|
662 CCamPreCaptureContainerBase* parent = static_cast<CCamPreCaptureContainerBase*>( iParent ); |
|
663 parent->SetUseSetupPaneOptions( EFalse ); |
|
664 parent->SetCurrentSetupPaneItem( KErrNotFound ); // Invalidate |
|
665 parent->SetViewFinderState( CCamPreCaptureContainerBase::EVfStateActive ); // Ensure reverted viewfinder |
|
666 } |
|
667 |
|
668 // else if current item is user scene base on scene item, the new (cancelled) state will not |
|
669 // need the "options" menu or the current Item information. |
|
670 else if ( iMenuItemIds[iCurrentSettingsArrayIndex] == ECamSettingItemUserSceneBasedOnScene ) |
|
671 { |
|
672 CCamPreCaptureContainerBase* parent = static_cast<CCamPreCaptureContainerBase*>( iParent ); |
|
673 parent->SetUseSetupPaneOptions( EFalse ); |
|
674 parent->SetCurrentSetupPaneItem( KErrNotFound ); // Invalidate |
|
675 } |
|
676 // otherwise, do nothing |
|
677 else |
|
678 { |
|
679 // empty statement to remove Lint error. |
|
680 } |
|
681 |
|
682 iHighlightedItemIndex = iCurrentSettingsArrayIndex; |
|
683 iCurrentSettingsArrayIndex = KErrNotFound; // Invalidate. |
|
684 |
|
685 // User has cancelled the highlighted item, so tell controller to cancel this change |
|
686 TRAPD( ignore, iController.CancelPreviewChangesL() ); |
|
687 if ( ignore ) |
|
688 { |
|
689 // Do nothing ( removes build warning ) |
|
690 } |
|
691 } |
|
692 |
|
693 // If in user scene mode revert back to the user scene setup list. |
|
694 if ( iUserSceneSetupMode ) |
|
695 { |
|
696 SwitchToUserSceneView(); |
|
697 } |
|
698 |
|
699 // else revert back to menu level, and remove focus from setup pane. |
|
700 else |
|
701 { |
|
702 iPaneLevel = EMenuLevel; |
|
703 iPaneControl->HandleModelChanged(); |
|
704 |
|
705 // Select-key focus goes back to viewfinder |
|
706 CCamPreCaptureContainerBase* parent = static_cast<CCamPreCaptureContainerBase*>( iParent ); |
|
707 parent->FocusToSetupPane( EFalse ); |
|
708 } |
|
709 } |
|
710 |
|
711 // ----------------------------------------------------------------------------- |
|
712 // CCamModeSetupPaneHandler::CreatePaneControlL |
|
713 // Creates and returns a pointer to a new pane control. Used by the control container. |
|
714 // Keeps a pointer to the pane control, but gives ownership to caller. |
|
715 // ----------------------------------------------------------------------------- |
|
716 // |
|
717 CCoeControl* CCamModeSetupPaneHandler::CreatePaneControlL( CCoeControl* aParent, const TRect& aRect ) |
|
718 { |
|
719 iPaneControl = CCamSetupPane::NewL( *aParent, aRect, *this, *this ); |
|
720 iParent = aParent; |
|
721 return iPaneControl; |
|
722 } |
|
723 |
|
724 |
|
725 // ----------------------------------------------------------------------------- |
|
726 // CCamModeSetupPaneHandler::UpdateFromResourceL |
|
727 // Updates the contents of the setup pane based on the supplied resource |
|
728 // ----------------------------------------------------------------------------- |
|
729 // |
|
730 void CCamModeSetupPaneHandler::UpdateFromResourceL( TInt aResource ) |
|
731 { |
|
732 TResourceReader reader; |
|
733 |
|
734 ResetArray(); |
|
735 |
|
736 CCoeEnv::Static()->CreateResourceReaderLC( reader, aResource ); |
|
737 |
|
738 const TInt menuItemCount = reader.ReadInt16(); |
|
739 |
|
740 TInt i; |
|
741 for ( i = 0 ; i < menuItemCount ; i++ ) |
|
742 { |
|
743 iMenuItemIds[i] = reader.ReadInt16(); |
|
744 iMenuTitles[i] = reader.ReadTPtrC().Left( KMaxTitleCharLength ); |
|
745 TInt itemsId = reader.ReadInt32(); |
|
746 iSettingItems[i] = new( ELeave ) CCamSetupPaneItemArray( KItemArrayGranularity ); |
|
747 iSettingItems[i]->ConstructFromResourceL( itemsId ); |
|
748 ASSERT( iSettingItems[i]->Count() > 0 ); |
|
749 } |
|
750 |
|
751 iNoOfSettingsItems = menuItemCount; |
|
752 |
|
753 CleanupStack::PopAndDestroy(); // reader |
|
754 |
|
755 if ( iLastCapTitle ) |
|
756 { |
|
757 iMenuItemIds[i] = 0; |
|
758 iMenuTitles[i] = iLastCapTitle->Des(); |
|
759 } |
|
760 |
|
761 iCurrentSettingsArrayIndex = KErrNotFound; // Invalidate. |
|
762 |
|
763 // Given mode change, set highlight back to start of items list |
|
764 iHighlightedItemIndex = 0; |
|
765 iPaneControl->HandleModelChanged(); |
|
766 } |
|
767 |
|
768 |
|
769 |
|
770 // ----------------------------------------------------------------------------- |
|
771 // CCamModeSetupPaneHandler::Refresh |
|
772 // Forces a refresh of the SetupPane control |
|
773 // ----------------------------------------------------------------------------- |
|
774 // |
|
775 void CCamModeSetupPaneHandler::Refresh() |
|
776 { |
|
777 TParse parse; |
|
778 parse.Set( iLastCaptureHelper->FileName(), NULL, NULL ); |
|
779 iLastCapName = parse.Name(); |
|
780 |
|
781 // Only refresh the control if we are in the foreground |
|
782 if ( iForeground ) |
|
783 { |
|
784 iPaneControl->DrawNow(); |
|
785 } |
|
786 } |
|
787 |
|
788 // ----------------------------------------------------------------------------- |
|
789 // CCamModeSetupPaneHandler::SetForeground |
|
790 // Sets whether SetupPane is in foreground or background |
|
791 // ----------------------------------------------------------------------------- |
|
792 // |
|
793 void CCamModeSetupPaneHandler::SetForeground( TBool aForeground ) |
|
794 { |
|
795 iForeground = aForeground; |
|
796 } |
|
797 |
|
798 // ----------------------------------------------------------------------------- |
|
799 // CCamModeSetupPaneHandler::SetMenuContextL |
|
800 // Used to change the contents of the Setup Pane depending on which camera and |
|
801 // mode is to be used. |
|
802 // ----------------------------------------------------------------------------- |
|
803 // |
|
804 void CCamModeSetupPaneHandler::SetMenuContextL( TBool aFirstCamera, TBool aPhoto, TBool aUserSceneSetup ) |
|
805 { |
|
806 TInt resource = KErrNotFound; |
|
807 iPhotoMode = aPhoto; |
|
808 |
|
809 // Identify which resource to use |
|
810 |
|
811 // ...User scene setup mode |
|
812 if ( aUserSceneSetup ) |
|
813 { |
|
814 resource = ROID(R_CAM_USER_SCENE_SETUP_PANE_MENU_ITEM_ARRAY_ID); |
|
815 iUserSceneSetupMode = ETrue; |
|
816 } |
|
817 // ...Non-user scene setup mode. |
|
818 else |
|
819 { |
|
820 iUserSceneSetupMode = EFalse; |
|
821 |
|
822 if ( aFirstCamera ) |
|
823 { |
|
824 if ( aPhoto ) |
|
825 { |
|
826 resource = ROID(R_CAM_IMAGE_MODE_SETUP_PANE_MENU_ITEM_ARRAY_ID); |
|
827 } |
|
828 else |
|
829 { |
|
830 resource = ROID(R_CAM_VIDEO_MODE_SETUP_PANE_MENU_ITEM_ARRAY_ID); |
|
831 } |
|
832 } |
|
833 else |
|
834 { |
|
835 if ( aPhoto ) |
|
836 { |
|
837 resource = ROID(R_CAM_SECONDARY_IMAGE_MODE_SETUP_PANE_MENU_ITEM_ARRAY_ID); |
|
838 } |
|
839 else |
|
840 { |
|
841 resource = ROID(R_CAM_SECONDARY_VIDEO_MODE_SETUP_PANE_MENU_ITEM_ARRAY_ID); |
|
842 } |
|
843 } |
|
844 } |
|
845 |
|
846 iLastCaptureHelper->SetPhotoMode( aPhoto ); |
|
847 |
|
848 // Load the string for the last captured item title |
|
849 if ( iLastCapTitle ) |
|
850 { |
|
851 delete iLastCapTitle; |
|
852 iLastCapTitle = NULL; |
|
853 } |
|
854 TInt lastCapRes = 0; |
|
855 if ( aPhoto ) |
|
856 { |
|
857 lastCapRes = ROID(R_CAM_SETUP_LASTCAP_PHOTO_TITLE_ID); |
|
858 } |
|
859 else |
|
860 { |
|
861 lastCapRes = ROID(R_CAM_SETUP_LASTCAP_VIDEO_TITLE_ID); |
|
862 } |
|
863 iLastCapTitle = StringLoader::LoadLC( lastCapRes ); |
|
864 CleanupStack::Pop( iLastCapTitle ); |
|
865 |
|
866 TParse parse; |
|
867 parse.Set( iLastCaptureHelper->FileName(), NULL, NULL ); |
|
868 iLastCapName = parse.Name(); |
|
869 |
|
870 |
|
871 // Make the change |
|
872 if ( resource != KErrNotFound ) |
|
873 { |
|
874 UpdateFromResourceL( resource ); |
|
875 } |
|
876 } |
|
877 |
|
878 |
|