|
1 /* |
|
2 * Copyright (c) 2007-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: This implements a control which acts as a container for the* |
|
15 */ |
|
16 |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <gulutil.h> |
|
20 #include <aknview.h> |
|
21 #include <avkon.hrh> |
|
22 #include <AknUtils.h> |
|
23 #include <barsread.h> |
|
24 #include <AknsFrameBackgroundControlContext.h> |
|
25 #include <AknsDrawUtils.h> |
|
26 #include <aknlayoutscalable_apps.cdl.h> |
|
27 #include <touchfeedback.h> |
|
28 #include <akntoolbar.h> |
|
29 |
|
30 |
|
31 #include "CamCaptureSetupContainer.h" |
|
32 #include "CamAppController.h" |
|
33 #include "CamCaptureSetupControlHandler.h" |
|
34 #include "CamUtility.h" |
|
35 #include "CamCaptureSetupListBox.h" |
|
36 |
|
37 |
|
38 #include <cameraapp.rsg> |
|
39 #include <vgacamsettings.rsg> |
|
40 |
|
41 #include "CamAppUi.h" |
|
42 |
|
43 #include "camcameraevents.h" |
|
44 #include "mcamlistboxmodel.h" |
|
45 |
|
46 // =========================================================================== |
|
47 // CONSTANTS |
|
48 |
|
49 const TUint KCameraEventInterest = ECamCameraEventClassVfData; |
|
50 |
|
51 // =========================================================================== |
|
52 // MEMBER FUNCTIONS |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // CCamCaptureSetupContainer::NewL |
|
56 // Symbian OS two-phased constructor |
|
57 // --------------------------------------------------------------------------- |
|
58 // |
|
59 CCamCaptureSetupContainer* CCamCaptureSetupContainer::NewL( |
|
60 CCamAppController& aController, |
|
61 CAknView& aView, |
|
62 CCamCaptureSetupControlHandler& aControlHandler, |
|
63 const TRect& aRect ) |
|
64 { |
|
65 CCamCaptureSetupContainer* self = new( ELeave ) CCamCaptureSetupContainer( |
|
66 aController, |
|
67 aView, |
|
68 aControlHandler ); |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL( aRect ); |
|
71 CleanupStack::Pop( self ); |
|
72 // return newly created CCamCaptureSetupContainer instance |
|
73 return self; |
|
74 } |
|
75 |
|
76 // --------------------------------------------------------- |
|
77 // CCamCaptureSetupContainer::~CCamCaptureSetupContainer |
|
78 // Destructor |
|
79 // --------------------------------------------------------- |
|
80 // |
|
81 CCamCaptureSetupContainer::~CCamCaptureSetupContainer() |
|
82 { |
|
83 PRINT( _L("Camera => ~CCamCaptureSetupContainer") ); |
|
84 // <CAMERAAPP_CAPI_V2_MIGRATION/> |
|
85 |
|
86 iController.ViewfinderWindowDeleted( &Window() ); |
|
87 |
|
88 iController.RemoveCameraObserver( this ); |
|
89 if ( iFeedback ) |
|
90 { |
|
91 iFeedback->RemoveFeedbackForControl( iCaptureSetupControl ); |
|
92 } |
|
93 delete iCaptureSetupControl; |
|
94 delete iTitleText; |
|
95 PRINT( _L("Camera <= ~CCamCaptureSetupContainer") ); |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // CCamCaptureSetupContainer::ConstructL |
|
100 // Symbian OS 2nd phase constructor |
|
101 // --------------------------------------------------------- |
|
102 // |
|
103 void CCamCaptureSetupContainer::ConstructL( const TRect& aRect ) |
|
104 { |
|
105 PRINT( _L("Camera => CCamCaptureSetupContainer::ConstructL ") ); |
|
106 |
|
107 CCamContainerBase::BaseConstructL( aRect ); |
|
108 if ( iController.IsTouchScreenSupported() ) |
|
109 { |
|
110 CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() ); |
|
111 CAknToolbar* fixedToolbar = appUi->CurrentFixedToolbar(); |
|
112 if ( fixedToolbar ) |
|
113 { |
|
114 // Remove toolbar from the settings view, before drawing VF, |
|
115 // in order to avoid flickering |
|
116 fixedToolbar->SetToolbarVisibility( EFalse ); |
|
117 } |
|
118 } |
|
119 |
|
120 iCaptureSetupControl = iControlHandler.CreateCaptureSetupControlL( this ); |
|
121 iCaptureSetupControl->SetContainerWindowL( *this ); |
|
122 iViewFinding = iControlHandler.ControlUsesViewFinder(); |
|
123 |
|
124 // If the control requires a viewfinder then add it |
|
125 if ( iViewFinding ) |
|
126 { |
|
127 // <CAMERAAPP_CAPI_V2_MIGRATION> |
|
128 iController.AddCameraObserverL( this, KCameraEventInterest ); |
|
129 // iController.AddViewFinderObserverL( this ); |
|
130 // </CAMERAAPP_CAPI_V2_MIGRATION> |
|
131 } |
|
132 |
|
133 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
134 iLayoutAreaRect ); |
|
135 |
|
136 // layout area rectangle contains the area, where components need to be |
|
137 // drawn to. the container size is the whole screen, but the layouts are |
|
138 // for the client area. aRect is the container size that might include or |
|
139 // might not include statuspane area. calculating area self will |
|
140 // go around the problem |
|
141 |
|
142 TRect listboxRect; |
|
143 if ( CamUtility::IsNhdDevice() ) |
|
144 { |
|
145 listboxRect = TouchLayout(); |
|
146 } |
|
147 else |
|
148 { |
|
149 listboxRect = NonTouchLayout(); |
|
150 } |
|
151 |
|
152 if ( iControlHandler.ControlIsListBox() ) |
|
153 { |
|
154 CCamCaptureSetupListBox* listbox = |
|
155 static_cast<CCamCaptureSetupListBox*>(iCaptureSetupControl); |
|
156 |
|
157 // Determine the height of the listbox; Either the height based on the |
|
158 // number of items, or the maximum allowed listbox height. |
|
159 CEikScrollBarFrame::TScrollBarVisibility visibility = |
|
160 CEikScrollBarFrame::EOff; |
|
161 TInt maxListBoxHeight = listboxRect.Height(); |
|
162 TInt listBoxHeight = listbox->CalcHeightBasedOnNumOfItems( |
|
163 listbox->Model()->NumberOfItems() ); |
|
164 if ( maxListBoxHeight < listBoxHeight ) |
|
165 { |
|
166 listBoxHeight = maxListBoxHeight; |
|
167 visibility = CEikScrollBarFrame::EOn; |
|
168 } |
|
169 |
|
170 const AknLayoutUtils::SAknLayoutControl listboxLayout = |
|
171 { ELayoutEmpty, listboxRect.iTl.iX, listboxRect.iTl.iY, |
|
172 ELayoutEmpty, ELayoutEmpty, listboxRect.Width(), listBoxHeight }; |
|
173 |
|
174 AknLayoutUtils::LayoutControl( iCaptureSetupControl, iLayoutAreaRect, |
|
175 listboxLayout); |
|
176 |
|
177 listbox->CreateScrollBarFrameL( ETrue ); |
|
178 listbox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
179 CEikScrollBarFrame::EOff, visibility ); |
|
180 listbox->MakeVisible( ETrue ); |
|
181 listbox->SetFocus( EFalse, ENoDrawNow ); |
|
182 listbox->UpdateScrollBarsL(); |
|
183 listbox->ScrollBarFrame()->DrawScrollBarsNow(); |
|
184 listbox->SetListBoxObserver(this); |
|
185 } |
|
186 |
|
187 iFeedback = MTouchFeedback::Instance(); |
|
188 if ( iFeedback ) |
|
189 { |
|
190 iFeedback->SetFeedbackArea( iCaptureSetupControl, 0, |
|
191 iCaptureSetupControl->Rect(), |
|
192 ETouchFeedbackBasic, |
|
193 ETouchEventStylusDown ); |
|
194 } |
|
195 |
|
196 iCaptureSetupControl->MakeVisible( ETrue ); |
|
197 iCaptureSetupControl->SetFocus( EFalse, EDrawNow ); |
|
198 iTitleText = iEikonEnv->AllocReadResourceL( |
|
199 iControlHandler.ControlTitleResourceId() ); |
|
200 iController.SetViewfinderWindowHandle( &Window() ); |
|
201 |
|
202 PRINT( _L("Camera <= CCamCaptureSetupContainer::ConstructL") ); |
|
203 } |
|
204 |
|
205 // --------------------------------------------------------------------------- |
|
206 // CCamCaptureSetupContainer::ControlPositionL |
|
207 // Return the top left position for the control |
|
208 // --------------------------------------------------------------------------- |
|
209 // |
|
210 TPoint CCamCaptureSetupContainer::ControlPositionL() const |
|
211 { |
|
212 TPoint pos; |
|
213 |
|
214 // If the viewfinder preview is showing |
|
215 if ( iViewFinding ) |
|
216 { |
|
217 /* |
|
218 // Get the control pos from resource |
|
219 TResourceReader reader; |
|
220 TInt resource = iControlHandler.ControlPositionResourceId(); |
|
221 iEikonEnv->CreateResourceReaderLC( reader, resource ); |
|
222 |
|
223 pos.iX = reader.ReadInt16( ); |
|
224 pos.iY = reader.ReadInt16( ); |
|
225 iCaptureSetupControl->SetPosition( pos ); |
|
226 |
|
227 // Cleanup the resource reader. |
|
228 CleanupStack::PopAndDestroy(); // resource reader |
|
229 */ |
|
230 |
|
231 } |
|
232 else // The control should be centered horizontally |
|
233 { |
|
234 |
|
235 /* |
|
236 pos.iX = ( Rect().Width() - iListBoxWidth ) /2; |
|
237 pos.iY = ( Rect().Height() - |
|
238 iCaptureSetupControl->MinimumSize().iHeight ) /2; |
|
239 */ |
|
240 |
|
241 |
|
242 } |
|
243 return pos; |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------------------------- |
|
247 // CCamCaptureSetupContainer::CCamCaptureSetupContainer |
|
248 // C++ constructor |
|
249 // --------------------------------------------------------------------------- |
|
250 // |
|
251 CCamCaptureSetupContainer::CCamCaptureSetupContainer( |
|
252 CCamAppController& aController, |
|
253 CAknView& aView, |
|
254 CCamCaptureSetupControlHandler& aControlHandler ) |
|
255 : CCamContainerBase( aController, aView ), |
|
256 iControlHandler( aControlHandler ), |
|
257 iActivateOnTouchRelease(EFalse) |
|
258 { |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------- |
|
262 // CCamCaptureSetupContainer::CountComponentControls |
|
263 // Returns the number of controls owned |
|
264 // --------------------------------------------------------- |
|
265 // |
|
266 TInt CCamCaptureSetupContainer::CountComponentControls() const |
|
267 { |
|
268 return 1; // Return the number of controls inside this container |
|
269 } |
|
270 |
|
271 // --------------------------------------------------------- |
|
272 // CCamCaptureSetupContainer::ComponentControl |
|
273 // --------------------------------------------------------- |
|
274 // |
|
275 CCoeControl* CCamCaptureSetupContainer::ComponentControl(TInt /*aIndex*/) const |
|
276 { |
|
277 return iCaptureSetupControl; |
|
278 } |
|
279 |
|
280 // --------------------------------------------------------- |
|
281 // CCamCaptureSetupContainer::Draw |
|
282 // Draw control |
|
283 // --------------------------------------------------------- |
|
284 // |
|
285 void CCamCaptureSetupContainer::Draw( const TRect& aRect ) const |
|
286 { |
|
287 PRINT( _L("Camera => CCamCaptureSetupContainer::Draw")) |
|
288 CWindowGc& gc = SystemGc(); |
|
289 |
|
290 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
291 AknsDrawUtils::Background( skin, iBgContext, gc, aRect/*Rect()*/ ); |
|
292 |
|
293 CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() ); |
|
294 |
|
295 PRINT( _L("Camera => CCamCaptureSetupContainer::Draw direct VF")) |
|
296 |
|
297 if( appUi->IsDirectViewfinderActive() && |
|
298 iViewFinding ) |
|
299 { |
|
300 // Fill control with transparency bg colour |
|
301 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
302 |
|
303 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
304 gc.SetBrushColor( TRgb::Color16MA( 0 ) ); |
|
305 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
306 gc.DrawRect( iViewFinderRectLayout.Rect() ); |
|
307 |
|
308 // Reset the brush after use (otherwise anything drawn |
|
309 // after the viewfinder will also show viewfinder frames) |
|
310 gc.SetBrushStyle( CGraphicsContext::ENullBrush ); |
|
311 } |
|
312 |
|
313 // draw the title text |
|
314 TRgb color; |
|
315 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, |
|
316 EAknsCIQsnTextColorsCG6 ); |
|
317 if ( CamUtility::IsNhdDevice() ) |
|
318 { |
|
319 iTitleTextRectLayout.DrawText( gc, *iTitleText, ETrue, color ); |
|
320 } |
|
321 else |
|
322 { |
|
323 TRAP_IGNORE( appUi->SetTitleL( *iTitleText )); |
|
324 } |
|
325 PRINT( _L("Camera <= CCamCaptureSetupContainer::Draw")) |
|
326 } |
|
327 |
|
328 // ---------------------------------------------------- |
|
329 // CCamCaptureSetupContainer::OfferKeyEventL |
|
330 // ---------------------------------------------------- |
|
331 // |
|
332 TKeyResponse CCamCaptureSetupContainer::OfferKeyEventL( |
|
333 const TKeyEvent& aKeyEvent, |
|
334 TEventCode aType ) |
|
335 { |
|
336 if( iController.CurrentMode() == ECamControllerIdle || |
|
337 iController.CurrentMode() == ECamControllerShutdown ) |
|
338 { |
|
339 if( !iController.IsViewFinding() && iViewFinding |
|
340 && IsCaptureKeyL( aKeyEvent, aType ) ) |
|
341 { |
|
342 PRINT( _L("Camera <> CCamCaptureSetupContainer::OfferKeyEventL coming back from standby" )) |
|
343 ReserveAndStartVF(); |
|
344 } |
|
345 return EKeyWasNotConsumed; |
|
346 } |
|
347 |
|
348 PRINT( _L("Camera => CCamCaptureSetupContainer::OfferKeyEventL" )) |
|
349 iController.StartIdleTimer(); |
|
350 |
|
351 if( !iController.IsViewFinding() && iViewFinding |
|
352 && IsCaptureKeyL( aKeyEvent, aType ) ) |
|
353 { |
|
354 // If VF was stopped by stand-by-timer, restart VF here |
|
355 ReserveAndStartVF(); |
|
356 } |
|
357 |
|
358 // If the Ok button is pressed, select the current item |
|
359 if ( aKeyEvent.iCode == EKeyOK && aKeyEvent.iRepeats == 0 && aType == EEventKey ) |
|
360 { |
|
361 TKeyResponse response = iCaptureSetupControl->OfferKeyEventL( aKeyEvent, aType ); |
|
362 iView.HandleCommandL( EAknSoftkeyOk ); |
|
363 return response; |
|
364 } |
|
365 return iCaptureSetupControl->OfferKeyEventL( aKeyEvent, aType ); |
|
366 } |
|
367 |
|
368 // <CAMERAAPP_CAPI_V2_MIGRATION> |
|
369 // =========================================================================== |
|
370 // From MCamCameraObserver |
|
371 |
|
372 // --------------------------------------------------------------------------- |
|
373 // virtual HandleCameraEventL |
|
374 // --------------------------------------------------------------------------- |
|
375 // |
|
376 void |
|
377 CCamCaptureSetupContainer::HandleCameraEventL( TInt aStatus, |
|
378 TCamCameraEventId aEventId, |
|
379 TAny* aEventData /*= NULL*/ ) |
|
380 { |
|
381 if ( iViewFinding |
|
382 && ECamCameraEventVfFrameReady == aEventId |
|
383 && KErrNone == aStatus ) |
|
384 { |
|
385 CFbsBitmap* frame = static_cast<CFbsBitmap*>( aEventData ); |
|
386 if( frame ) |
|
387 { |
|
388 // Draw a portion of the viewfinder |
|
389 CWindowGc& gc = SystemGc(); |
|
390 gc.Activate( *DrawableWindow() ); |
|
391 TRect rect = iViewFinderRectLayout.Rect(); |
|
392 RWindow window = Window(); |
|
393 window.Invalidate( rect ); |
|
394 window.BeginRedraw( rect ); |
|
395 TRect bitmapPortion = rect; |
|
396 TSize bitmapSize = frame->SizeInPixels(); |
|
397 // if the bitmap is too short to offset vertically |
|
398 // display from its top edge |
|
399 if ( bitmapSize.iHeight - rect.iTl.iY < rect.Height() ) |
|
400 { |
|
401 bitmapPortion.Move( 0, 0 - rect.iTl.iY ); |
|
402 } |
|
403 // if the bitmap is too narrow to offset horizontally |
|
404 // display from its left edge |
|
405 if ( bitmapSize.iWidth - rect.iTl.iX < rect.Width() ) |
|
406 { |
|
407 bitmapPortion.Move( 0 - rect.iTl.iX, 0 ); |
|
408 } |
|
409 gc.BitBlt( rect.iTl, frame, bitmapPortion ); |
|
410 |
|
411 window.EndRedraw(); |
|
412 gc.Deactivate(); |
|
413 } |
|
414 } |
|
415 } |
|
416 |
|
417 // --------------------------------------------------------- |
|
418 // CCamCaptureSetupContainer::HandlePointerEventL |
|
419 // --------------------------------------------------------- |
|
420 // |
|
421 void CCamCaptureSetupContainer::HandlePointerEventL( const TPointerEvent& aPointerEvent ) |
|
422 { |
|
423 |
|
424 RDebug::Print(_L("CCamCaptureSetupContainer::HandlePointerEventL iType=%d iPosition=(%d, %d)"), |
|
425 aPointerEvent.iType, |
|
426 aPointerEvent.iPosition.iX, |
|
427 aPointerEvent.iPosition.iY ); |
|
428 if( !iController.IsViewFinding() && iViewFinding ) |
|
429 { |
|
430 PRINT ( _L("Camera <> CCamCaptureSetupContainer::HandlePointerEventL start viewfinder") ); |
|
431 ReserveAndStartVF(); |
|
432 } |
|
433 |
|
434 /*if( iController.CurrentMode() == ECamControllerIdle || |
|
435 iController.CurrentMode() == ECamControllerShutdown ) |
|
436 { |
|
437 return; |
|
438 } |
|
439 |
|
440 if( !iController.IsViewFinding() && iViewFinding ) |
|
441 { |
|
442 // First tap just starts viewfinder |
|
443 iController.StartViewFinder(); |
|
444 iController.StartIdleTimer(); |
|
445 return; |
|
446 } |
|
447 |
|
448 if ( iControlHandler.ControlIsListBox() && iCaptureSetupControl ) |
|
449 { |
|
450 |
|
451 TInt oldListItemIndex = -1; |
|
452 TInt newListItemIndex = -1; |
|
453 TBool handleItemActivation = EFalse; |
|
454 |
|
455 CCamCaptureSetupListBox* listbox = static_cast<CCamCaptureSetupListBox*>(iCaptureSetupControl); |
|
456 |
|
457 if ( listbox ) |
|
458 { |
|
459 oldListItemIndex = listbox->CurrentItemIndex(); |
|
460 } |
|
461 |
|
462 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
463 |
|
464 if ( listbox ) |
|
465 { |
|
466 newListItemIndex = listbox->CurrentItemIndex(); |
|
467 } |
|
468 |
|
469 if ( oldListItemIndex != -1 && newListItemIndex != -1 ) |
|
470 { |
|
471 |
|
472 // figure out if item was activated by touch down + release combination on same item |
|
473 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
474 { |
|
475 if ( newListItemIndex != oldListItemIndex ) |
|
476 { |
|
477 iActivateOnTouchRelease = EFalse; |
|
478 } |
|
479 else |
|
480 { |
|
481 // set the current item to be activated on touch release |
|
482 iActivateOnTouchRelease = ETrue; |
|
483 } |
|
484 } |
|
485 else if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
486 { |
|
487 if ( iActivateOnTouchRelease && ( newListItemIndex == oldListItemIndex ) ) |
|
488 { |
|
489 TInt pointedItemIndex; |
|
490 TBool focusableItemPointed = listbox->View()->XYPosToItemIndex(aPointerEvent.iPosition, pointedItemIndex ); |
|
491 // check that pointer is in focusable area |
|
492 if ( focusableItemPointed ) |
|
493 { |
|
494 // only if list item index has not changed during event and iActivateOnTouchRelease is true |
|
495 handleItemActivation = ETrue; |
|
496 iActivateOnTouchRelease = EFalse; |
|
497 } |
|
498 else |
|
499 { |
|
500 iActivateOnTouchRelease = EFalse; |
|
501 } |
|
502 } |
|
503 } |
|
504 else |
|
505 { |
|
506 // aPointerEvent.iType == TPointerEvent::EDrag |
|
507 |
|
508 if ( newListItemIndex != oldListItemIndex ) |
|
509 { |
|
510 // change only when drag event changes the listitem index |
|
511 iActivateOnTouchRelease = EFalse; |
|
512 } |
|
513 |
|
514 } |
|
515 |
|
516 } // end if ( oldListItemIndex != -1 && newListItemIndex != -1 ) |
|
517 |
|
518 if ( handleItemActivation ) |
|
519 { |
|
520 iView.HandleCommandL( EAknSoftkeyOk ); |
|
521 } |
|
522 |
|
523 } // end if ( iControlHandler.ControlIsListBox() && iCaptureSetupControl ) |
|
524 else |
|
525 { |
|
526 // make sure that base class functionality is called even if |
|
527 // container has some other control than listbox |
|
528 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
529 }*/ |
|
530 iCaptureSetupControl->HandlePointerEventL( aPointerEvent ); |
|
531 } |
|
532 |
|
533 // --------------------------------------------------------- |
|
534 // CCamCaptureSetupContainer::TouchLayout |
|
535 // --------------------------------------------------------- |
|
536 // |
|
537 TRect CCamCaptureSetupContainer::TouchLayout() |
|
538 { |
|
539 TRect statusPaneRect; |
|
540 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, |
|
541 statusPaneRect ); |
|
542 iLayoutAreaRect.BoundingRect( statusPaneRect ); |
|
543 |
|
544 if ( iControlHandler.ControlIsListBox() ) |
|
545 { |
|
546 TAknLayoutRect listboxLayoutRect; |
|
547 if ( iViewFinding ) |
|
548 { |
|
549 listboxLayoutRect.LayoutRect( iLayoutAreaRect, |
|
550 AknLayoutScalable_Apps::main_cset_listscroll_pane( 2 ) ); |
|
551 } |
|
552 else |
|
553 { |
|
554 listboxLayoutRect.LayoutRect( iLayoutAreaRect, |
|
555 AknLayoutScalable_Apps::main_cset_listscroll_pane( 3 ) ); |
|
556 } |
|
557 iViewFinderRectLayout.LayoutRect( iLayoutAreaRect, |
|
558 AknLayoutScalable_Apps::main_cam_set_pane_g2( 2 ) ); |
|
559 iTitleTextRectLayout.LayoutText( iLayoutAreaRect, |
|
560 AknLayoutScalable_Apps::main_cam_set_pane_t1( 3 ) ); |
|
561 return listboxLayoutRect.Rect(); |
|
562 } |
|
563 else // slider |
|
564 { |
|
565 TAknLayoutRect settingLayout; |
|
566 settingLayout.LayoutRect( iLayoutAreaRect, |
|
567 AknLayoutScalable_Apps::main_cam_set_pane( 0 ) ); |
|
568 TRect settingRect( settingLayout.Rect() ); |
|
569 AknLayoutUtils::LayoutControl( iCaptureSetupControl, settingRect, |
|
570 AknLayoutScalable_Apps::main_cset_slider_pane( 1 ) ); |
|
571 |
|
572 iViewFinderRectLayout.LayoutRect( iLayoutAreaRect, |
|
573 AknLayoutScalable_Apps::main_cam_set_pane_g2( 3 ) ); |
|
574 iTitleTextRectLayout.LayoutText( iLayoutAreaRect, |
|
575 AknLayoutScalable_Apps::main_cam_set_pane_t1( 5 ) ); |
|
576 return settingRect; |
|
577 } |
|
578 } |
|
579 |
|
580 // --------------------------------------------------------- |
|
581 // CCamCaptureSetupContainer::NonTouchLayout |
|
582 // --------------------------------------------------------- |
|
583 // |
|
584 TRect CCamCaptureSetupContainer::NonTouchLayout() |
|
585 { |
|
586 // Non-touch has a visible title & status panes |
|
587 TRect titlePaneRect; |
|
588 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ETitlePane, |
|
589 titlePaneRect ); |
|
590 iLayoutAreaRect.Move( 0, -titlePaneRect.Height() ); |
|
591 |
|
592 if ( iControlHandler.ControlIsListBox() ) |
|
593 { |
|
594 TAknLayoutRect listboxLayoutRect; |
|
595 if ( iViewFinding ) |
|
596 { |
|
597 listboxLayoutRect.LayoutRect( iLayoutAreaRect, |
|
598 AknLayoutScalable_Apps::main_cset6_listscroll_pane( 2 ) ); |
|
599 } |
|
600 else |
|
601 { |
|
602 listboxLayoutRect.LayoutRect( iLayoutAreaRect, |
|
603 AknLayoutScalable_Apps::main_cset6_listscroll_pane( 3 ) ); |
|
604 } |
|
605 iViewFinderRectLayout.LayoutRect( iLayoutAreaRect, |
|
606 AknLayoutScalable_Apps::main_cam6_set_pane_g2( 2 ) ); |
|
607 return listboxLayoutRect.Rect(); |
|
608 } |
|
609 else // slider |
|
610 { |
|
611 TAknLayoutRect settingLayout; |
|
612 settingLayout.LayoutRect( iLayoutAreaRect, |
|
613 AknLayoutScalable_Apps::main_cam6_set_pane() ); |
|
614 TRect settingRect( settingLayout.Rect() ); |
|
615 AknLayoutUtils::LayoutControl( iCaptureSetupControl, settingRect, |
|
616 AknLayoutScalable_Apps::main_cset6_slider_pane( 1 ) ); |
|
617 iViewFinderRectLayout.LayoutRect( iLayoutAreaRect, |
|
618 AknLayoutScalable_Apps::main_cam6_set_pane_g2( 3 ) ); |
|
619 return settingRect; |
|
620 } |
|
621 } |
|
622 |
|
623 // ---------------------------------------------------- |
|
624 // CCamContainerBase::HandleForegroundEvent |
|
625 // Called to notify of change of app fore/background state |
|
626 // ---------------------------------------------------- |
|
627 // |
|
628 void CCamCaptureSetupContainer::HandleForegroundEventL( TBool aForeground ) |
|
629 { |
|
630 |
|
631 if ( aForeground ) |
|
632 { |
|
633 DrawDeferred(); |
|
634 } |
|
635 } |
|
636 |
|
637 // --------------------------------------------------------------------------- |
|
638 // CCamCaptureSetupContainer::HandleListBoxEventL |
|
639 // Handles Listbox events |
|
640 // --------------------------------------------------------------------------- |
|
641 // |
|
642 void CCamCaptureSetupContainer::HandleListBoxEventL( CEikListBox* aListBox, |
|
643 TListBoxEvent aEventType ) |
|
644 { |
|
645 if( iController.CurrentMode() == ECamControllerIdle || |
|
646 iController.CurrentMode() == ECamControllerShutdown ) |
|
647 { |
|
648 return; |
|
649 } |
|
650 |
|
651 if( !iController.IsViewFinding() && iViewFinding ) |
|
652 { |
|
653 PRINT( _L("Camera <> CCamCaptureSetupContainer::HandleListBoxEventL start viewfinder") ); |
|
654 ReserveAndStartVF(); |
|
655 return; |
|
656 } |
|
657 |
|
658 switch( aEventType ) |
|
659 { |
|
660 |
|
661 case EEventEnterKeyPressed: |
|
662 case EEventItemDoubleClicked: |
|
663 { |
|
664 iView.HandleCommandL(EAknSoftkeyOk); |
|
665 } |
|
666 break; |
|
667 |
|
668 case EEventItemClicked: |
|
669 { |
|
670 MCamListboxModel* model = static_cast<MCamListboxModel*>( aListBox->Model() ); |
|
671 iControlHandler.HandleSettingValueUpdateL( model->ItemValue( aListBox->CurrentItemIndex() ) ); |
|
672 } |
|
673 break; |
|
674 case EEventItemSingleClicked: |
|
675 { |
|
676 MCamListboxModel* model = static_cast<MCamListboxModel*>( aListBox->Model() ); //Warning: downcasting |
|
677 iControlHandler.HandleSettingValueUpdateL( model->ItemValue( aListBox->CurrentItemIndex() ) ); |
|
678 iView.HandleCommandL(EAknSoftkeyOk); |
|
679 } |
|
680 break; |
|
681 default: |
|
682 break; |
|
683 } |
|
684 } |
|
685 /* |
|
686 // --------------------------------------------------------- |
|
687 // CCamCaptureSetupContainer::ShowViewFinderFrame |
|
688 // Receives new viewfinder frame when one is available |
|
689 // --------------------------------------------------------- |
|
690 // |
|
691 void CCamCaptureSetupContainer::ShowViewFinderFrame( const CFbsBitmap* aFrame, TBool /aFrozen/ ) |
|
692 { |
|
693 // If a bitmap pointer was passed |
|
694 if ( aFrame && iViewFinding ) |
|
695 { |
|
696 // draw a portion of the viewfinder |
|
697 // temporary values used, waiting for specification |
|
698 CWindowGc& gc = SystemGc(); |
|
699 gc.Activate( *DrawableWindow() ); |
|
700 TRect rect = iViewFinderRectLayout.Rect(); |
|
701 RWindow window = Window(); |
|
702 window.Invalidate( rect ); |
|
703 window.BeginRedraw( rect ); |
|
704 TRect bitmapPortion = rect; |
|
705 TSize bitmapSize = aFrame->SizeInPixels(); |
|
706 // if the bitmap is too short to offset vertically |
|
707 // display from its top edge |
|
708 if ( bitmapSize.iHeight - rect.iTl.iY < rect.Height() ) |
|
709 { |
|
710 bitmapPortion.Move( 0, 0 - rect.iTl.iY ); |
|
711 } |
|
712 // if the bitmap is too narrow to offset horizontally |
|
713 // display from its left edge |
|
714 if ( bitmapSize.iWidth - rect.iTl.iX < rect.Width() ) |
|
715 { |
|
716 bitmapPortion.Move( 0 - rect.iTl.iX, 0 ); |
|
717 } |
|
718 gc.BitBlt( rect.iTl, aFrame, bitmapPortion ); |
|
719 window.EndRedraw(); |
|
720 gc.Deactivate(); |
|
721 } |
|
722 else // otherwise a null bitmap pointer was passed |
|
723 { |
|
724 |
|
725 } |
|
726 } |
|
727 */ |
|
728 |
|
729 // --------------------------------------------------------- |
|
730 // CCamCaptureSetupContainer::ReserveAndStartVF |
|
731 // --------------------------------------------------------- |
|
732 // |
|
733 void CCamCaptureSetupContainer::ReserveAndStartVF() |
|
734 { |
|
735 PRINT ( _L("Camera => CCamCaptureSetupContainer::ReserveAndStartVF") ); |
|
736 TCamCameraMode mode = iController.CurrentMode(); |
|
737 if(iController.IsAppUiAvailable()) |
|
738 { |
|
739 TVwsViewId currentViewId; |
|
740 CCamAppUi* appUi = static_cast<CCamAppUi*>( iEikonEnv->AppUi() ); |
|
741 appUi->GetActiveViewId( currentViewId ); |
|
742 switch ( currentViewId.iViewUid.iUid ) |
|
743 { |
|
744 case ECamViewIdPhotoUserSceneSetup: |
|
745 case ECamViewIdStillPreCapture: |
|
746 { |
|
747 mode = ECamControllerImage; |
|
748 } |
|
749 break; |
|
750 case ECamViewIdVideoPreCapture: |
|
751 { |
|
752 mode = ECamControllerVideo; |
|
753 } |
|
754 break; |
|
755 default: |
|
756 { |
|
757 //Assume imagemode if view cannot be determined. |
|
758 if(mode==ECamControllerIdle) |
|
759 { |
|
760 mode = ECamControllerImage; |
|
761 } |
|
762 } |
|
763 break; |
|
764 } |
|
765 } |
|
766 //Don't reserve camera and start viewfinder if shutting down. |
|
767 if(mode!=ECamControllerShutdown) |
|
768 { |
|
769 iController.EnterViewfinderMode( mode ); |
|
770 iController.StartIdleTimer(); |
|
771 } |
|
772 PRINT ( _L("Camera <= CCamCaptureSetupContainer::ReserveAndStartVF") ); |
|
773 } |
|
774 // </CAMERAAPP_CAPI_V2_MIGRATION> |
|
775 |
|
776 // End of File |