1 /* |
|
2 * Copyright (c) 2007-2009 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: Control for displaying elapse/remaining record time |
|
15 * in Navi Pane |
|
16 * |
|
17 * Copyright (c) 2007-2008 Nokia. All rights reserved. |
|
18 * This material, including documentation and any related computer |
|
19 * programs, is protected by copyright controlled by Nokia. All |
|
20 * rights are reserved. Copying, including reproducing, storing, |
|
21 * adapting or translating, any or all of this material requires the |
|
22 * prior written consent of Nokia. This material also contains |
|
23 * confidential information which may not be disclosed to others |
|
24 * without the prior written consent of Nokia. |
|
25 |
|
26 * |
|
27 * |
|
28 */ |
|
29 |
|
30 |
|
31 // INCLUDE FILES |
|
32 #include <eiklabel.h> |
|
33 #include <eikenv.h> |
|
34 #include <eikapp.h> // For CEikApplication |
|
35 #include <AknsUtils.h> |
|
36 #include <AknsDrawUtils.h> |
|
37 #include <aknconsts.h> |
|
38 #include <StringLoader.h> // StringLoader |
|
39 #include <e32base.h> |
|
40 #include <barsread.h> // TResourceReader |
|
41 #include <AknBidiTextUtils.h> |
|
42 #include <cameraapp.mbg> |
|
43 #include <AknLayoutFont.h> |
|
44 #include <aknlayoutscalable_apps.cdl.h> |
|
45 #include <aknlayoutscalable_avkon.cdl.h> |
|
46 #include <layoutmetadata.cdl.h> |
|
47 #include <cameraapp.rsg> |
|
48 #include <vgacamsettings.rsg> |
|
49 #include <avkon.mbg> |
|
50 |
|
51 #include "CamNaviProgressBarModel.h" |
|
52 #include "CamAppUi.h" |
|
53 #include "CamLogger.h" |
|
54 #include "CamUtility.h" |
|
55 #include "CamDecorator.h" |
|
56 #include "CamObserverHandler.h" |
|
57 #include "camcameraevents.h" |
|
58 #include "camcameracontrollertypes.h" |
|
59 #include "camtextitem.h" |
|
60 #include "OstTraceDefinitions.h" |
|
61 #ifdef OST_TRACE_COMPILER_IN_USE |
|
62 #include "CamNaviProgressBarModelTraces.h" |
|
63 #endif |
|
64 |
|
65 |
|
66 // CONSTANTS |
|
67 const TInt KFlashInterval = 200000; |
|
68 const TUint KCameraEventInterest = ECamCameraEventClassVideoTimes; |
|
69 |
|
70 // ========================= MEMBER FUNCTIONS ================================ |
|
71 |
|
72 // --------------------------------------------------------- |
|
73 // CCamNaviProgressBarModel::NewL |
|
74 // Factory construction function |
|
75 // --------------------------------------------------------- |
|
76 // |
|
77 CCamNaviProgressBarModel* CCamNaviProgressBarModel::NewL( CCamAppController& aController ) |
|
78 { |
|
79 CCamNaviProgressBarModel* self = new( ELeave ) CCamNaviProgressBarModel( aController ); |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 CleanupStack::Pop( self ); |
|
83 return self; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // CCamNaviProgressBarModel::~CCamNaviProgressBarModel |
|
88 // Destructor |
|
89 // --------------------------------------------------------- |
|
90 // |
|
91 CCamNaviProgressBarModel::~CCamNaviProgressBarModel() |
|
92 { |
|
93 PRINT( _L("Camera => ~CCamNaviProgressBarModel") ); |
|
94 |
|
95 delete iElapsedTimeTextItem; |
|
96 delete iRemainingTimeTextItem; |
|
97 |
|
98 UnloadResourceData(); |
|
99 |
|
100 iController.RemoveControllerObserver( this ); |
|
101 iController.RemoveCameraObserver( this ); |
|
102 |
|
103 delete iTimeFormat; |
|
104 delete iObserverHandler; |
|
105 |
|
106 if ( iFlashingTimer && iFlashingTimer->IsActive() ) |
|
107 { |
|
108 iFlashingTimer->Cancel(); |
|
109 } |
|
110 delete iFlashingTimer; |
|
111 PRINT( _L("Camera <= ~CCamNaviProgressBarModel") ); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------- |
|
115 // CCamNaviProgressBarModel::CCamNaviProgressBarModel |
|
116 // C++ constructor |
|
117 // --------------------------------------------------------- |
|
118 // |
|
119 CCamNaviProgressBarModel::CCamNaviProgressBarModel( |
|
120 CCamAppController& aController ) |
|
121 : iController( aController ) |
|
122 { |
|
123 } |
|
124 |
|
125 // --------------------------------------------------------- |
|
126 // CCamNaviProgressBarModel::DrawProgressBar |
|
127 // Draw Navi-progress |
|
128 // --------------------------------------------------------- |
|
129 // |
|
130 void |
|
131 CCamNaviProgressBarModel::DrawProgressBar( CBitmapContext& aGc, |
|
132 const CCoeControl* aControl ) const |
|
133 { |
|
134 DrawProgBar( aGc, aControl ); |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------- |
|
138 // CCamNaviProgressBarModel::ConstructL |
|
139 // Symbian OS 2nd phase constructor |
|
140 // --------------------------------------------------------- |
|
141 // |
|
142 void CCamNaviProgressBarModel::ConstructL() |
|
143 { |
|
144 OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMNAVIPROGRESSBARMODEL_CONSTRUCTL, "e_CCamNaviProgressBarModel_ConstructL 1" ); |
|
145 iController.AddControllerObserverL( this ); |
|
146 iController.AddCameraObserverL( this, KCameraEventInterest ); |
|
147 |
|
148 LoadResourceDataL(); |
|
149 |
|
150 iObserverHandler = CCamObserverHandler::NewL(); |
|
151 |
|
152 iFlashingTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
153 OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMNAVIPROGRESSBARMODEL_CONSTRUCTL, "e_CCamNaviProgressBarModel_ConstructL 0" ); |
|
154 } |
|
155 |
|
156 // ----------------------------------------------------------------------------- |
|
157 // CCamNaviProgressBarModel::LoadResourceDataL() |
|
158 // Reads in all information needed from resources |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 void CCamNaviProgressBarModel::LoadResourceDataL() |
|
162 { |
|
163 OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, CCAMNAVIPROGRESSBARMODEL_LOADRESOURCEDATAL, "e_CCamNaviProgressBarModel_LoadResourceDataL 1" ); |
|
164 // Create component bitmaps |
|
165 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
166 |
|
167 TFileName resFileName; |
|
168 CamUtility::ResourceFileName( resFileName ); |
|
169 TPtrC resname = resFileName; |
|
170 |
|
171 AknsUtils::CreateIconL( |
|
172 skin, |
|
173 KAknsIIDQgnGrafMup2BarProgress, |
|
174 iProgressBarBitmap, |
|
175 iProgressBarMask, |
|
176 resname, |
|
177 EMbmCameraappQgn_graf_mup2_bar_progress, |
|
178 EMbmCameraappQgn_graf_mup2_bar_progress_mask ); |
|
179 |
|
180 AknsUtils::CreateIconL( |
|
181 skin, |
|
182 KAknsIIDQgnGrafMup2BarFrame, |
|
183 iProgressBarFrame, |
|
184 resname, |
|
185 EMbmCameraappQgn_graf_mup2_bar_frame ); |
|
186 |
|
187 delete iElapsedTimeTextItem; |
|
188 iElapsedTimeTextItem = NULL; |
|
189 CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() ); |
|
190 iElapsedTimeTextItem = CCamTextItem::NewL(); |
|
191 |
|
192 delete iRemainingTimeTextItem; |
|
193 iRemainingTimeTextItem = NULL; |
|
194 iRemainingTimeTextItem = CCamTextItem::NewL(); |
|
195 |
|
196 iCamOrientation = appUi->CamOrientation(); |
|
197 |
|
198 if ( CamUtility::IsNhdDevice() ) |
|
199 { |
|
200 TouchLayoutL(); |
|
201 } |
|
202 else |
|
203 { |
|
204 if ( ECamOrientationPortrait == appUi->CamOrientation() ) |
|
205 { |
|
206 NonTouchLayoutSecondaryL(); |
|
207 } |
|
208 else |
|
209 { |
|
210 NonTouchLayoutL(); |
|
211 } |
|
212 } |
|
213 |
|
214 // Read the time format resource |
|
215 // We have to free the memory first if it has been |
|
216 // allocated already |
|
217 if ( iTimeFormat ) |
|
218 { |
|
219 delete iTimeFormat; |
|
220 iTimeFormat = NULL; |
|
221 } |
|
222 if ( ECamOrientationPortrait == appUi->CamOrientation() ) |
|
223 { |
|
224 iTimeFormat = CEikonEnv::Static()->AllocReadResourceL( R_QTN_TIME_DURAT_MIN_SEC_WITH_ZERO ); |
|
225 } |
|
226 else |
|
227 { |
|
228 iTimeFormat = CEikonEnv::Static()->AllocReadResourceL( R_QTN_TIME_DURAT_LONG ); |
|
229 } |
|
230 |
|
231 TBool progressBarVisible = ETrue; |
|
232 |
|
233 if ( progressBarVisible ) |
|
234 { |
|
235 iDecorator = CCamDecorator::NewL( iController, |
|
236 ROID(R_CAM_VIDEO_CAP_LIMIT_RECORDING_ICON_ID), this ); |
|
237 } |
|
238 else |
|
239 { |
|
240 iDecorator = CCamDecorator::NewL( iController, |
|
241 ROID(R_CAM_VIDEO_CAP_UNLIMIT_RECORDING_ICON_ID), this ); |
|
242 } |
|
243 |
|
244 AknIconUtils::SetSize( |
|
245 iProgressBarBitmap, |
|
246 iProgressBarRect.Rect().Size(), |
|
247 EAspectRatioNotPreserved ); |
|
248 |
|
249 // Progress bar area background |
|
250 AknIconUtils::SetSize( |
|
251 iProgressBarFrame, |
|
252 iProgressBarRect.Rect().Size(), |
|
253 EAspectRatioNotPreserved); |
|
254 |
|
255 // Create component bitmaps |
|
256 TSize size; |
|
257 if ( CamUtility::IsNhdDevice() ) |
|
258 { |
|
259 size = iProgressIconRect.Rect().Size(); |
|
260 } |
|
261 else |
|
262 { |
|
263 size = iVidStorageIconRect.Rect().Size(); |
|
264 } |
|
265 TCamOrientation orientation = appUi->CamOrientation(); |
|
266 AknIconUtils::CreateIconL( iPhoneIcon, |
|
267 iPhoneIconMask, |
|
268 resname, |
|
269 EMbmCameraappQgn_indi_cam4_memory_phone, |
|
270 EMbmCameraappQgn_indi_cam4_memory_phone_mask ); |
|
271 AknIconUtils::SetSize( iPhoneIcon, size ); |
|
272 |
|
273 AknIconUtils::CreateIconL( iMMCIcon, |
|
274 iMMCIconMask, |
|
275 resname, |
|
276 EMbmCameraappQgn_indi_cam4_memory_mmc, |
|
277 EMbmCameraappQgn_indi_cam4_memory_mmc_mask ); |
|
278 AknIconUtils::SetSize( iMMCIcon, size ); |
|
279 |
|
280 AknIconUtils::CreateIconL( iMassStorageIcon, |
|
281 iMassStorageIconMask, |
|
282 resname, |
|
283 EMbmCameraappQgn_indi_cam4_memory_mass, |
|
284 EMbmCameraappQgn_indi_cam4_memory_mass_mask ); |
|
285 |
|
286 |
|
287 AknIconUtils::SetSize( iMassStorageIcon, size ); |
|
288 OstTrace0( CAMERAAPP_PERFORMANCE_DETAIL, DUP1_CCAMNAVIPROGRESSBARMODEL_LOADRESOURCEDATAL, "e_CCamNaviProgressBarModel_LoadResourceDataL 0" ); |
|
289 } |
|
290 |
|
291 // ----------------------------------------------------------------------------- |
|
292 // CCamNaviProgressBarModel::UnloadResourceData() |
|
293 // Frees all dynamic resources allocated in LoadResourceDataL |
|
294 // ----------------------------------------------------------------------------- |
|
295 // |
|
296 void CCamNaviProgressBarModel::UnloadResourceData() |
|
297 { |
|
298 delete iDecorator; |
|
299 iDecorator = NULL; |
|
300 |
|
301 delete iPhoneIcon; |
|
302 iPhoneIcon = NULL; |
|
303 delete iPhoneIconMask; |
|
304 iPhoneIconMask = NULL; |
|
305 delete iMMCIcon; |
|
306 iMMCIcon = NULL; |
|
307 delete iMMCIconMask; |
|
308 iMMCIconMask = NULL; |
|
309 delete iMassStorageIcon; |
|
310 iMassStorageIcon = NULL; |
|
311 delete iMassStorageIconMask; |
|
312 iMassStorageIconMask = NULL; |
|
313 delete iProgressBarBitmap; |
|
314 iProgressBarBitmap = NULL; |
|
315 delete iProgressBarMask; |
|
316 iProgressBarMask = NULL; |
|
317 delete iProgressBarFrame; |
|
318 iProgressBarFrame = NULL; |
|
319 } |
|
320 |
|
321 // ----------------------------------------------------------------------------- |
|
322 // CCamNaviProgressBarModel::ReloadResourceDataL() |
|
323 // Refreshes all resource-based information stored in the class |
|
324 // ----------------------------------------------------------------------------- |
|
325 // |
|
326 void CCamNaviProgressBarModel::ReloadResourceDataL() |
|
327 { |
|
328 UnloadResourceData(); |
|
329 LoadResourceDataL(); |
|
330 } |
|
331 |
|
332 // --------------------------------------------------------- |
|
333 // CCamNaviProgressBarModel::DrawProgBar |
|
334 // Draw the control |
|
335 // --------------------------------------------------------- |
|
336 // |
|
337 void |
|
338 CCamNaviProgressBarModel::DrawProgBar( CBitmapContext& aGc, |
|
339 const CCoeControl* /*aControl*/ ) const |
|
340 { |
|
341 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
342 |
|
343 iDecorator->Draw( aGc, iExtent ); |
|
344 |
|
345 CFbsBitmap* icon = NULL; |
|
346 CFbsBitmap* mask = NULL; |
|
347 switch( iStorageLocation ) |
|
348 { |
|
349 case ECamMediaStoragePhone: |
|
350 { |
|
351 icon = iPhoneIcon; |
|
352 mask = iPhoneIconMask; |
|
353 } |
|
354 break; |
|
355 case ECamMediaStorageMassStorage: |
|
356 { |
|
357 icon = iMassStorageIcon; |
|
358 mask = iMassStorageIconMask; |
|
359 } |
|
360 break; |
|
361 case ECamMediaStorageCard: |
|
362 { |
|
363 icon = iMMCIcon; |
|
364 mask = iMMCIconMask; |
|
365 } |
|
366 break; |
|
367 case ECamMediaStorageNone: |
|
368 default: |
|
369 { |
|
370 //TODO: Get icons when none is available |
|
371 } |
|
372 break; |
|
373 } |
|
374 |
|
375 DrawElapsedTimeText( aGc ); |
|
376 DrawRemainingTimeText( aGc, skin ); |
|
377 if ( CamUtility::IsNhdDevice() ) |
|
378 { |
|
379 aGc.BitBltMasked( iProgressIconRect.Rect().iTl, |
|
380 icon, icon->SizeInPixels(), mask, ETrue ); |
|
381 } |
|
382 else |
|
383 { |
|
384 aGc.BitBltMasked( iVidStorageIconRect.Rect().iTl, |
|
385 icon, icon->SizeInPixels(), mask, ETrue ); |
|
386 } |
|
387 |
|
388 DrawProgressBar( aGc ); |
|
389 } |
|
390 |
|
391 // --------------------------------------------------------- |
|
392 // CCamNaviProgressBarModel::HandleControllerEventL |
|
393 // Handle an event from CCamAppController. |
|
394 // --------------------------------------------------------- |
|
395 // |
|
396 void CCamNaviProgressBarModel::HandleControllerEventL( |
|
397 TCamControllerEvent aEvent, TInt /* aError */ ) |
|
398 { |
|
399 PRINT( _L("Camera => CCamNaviProgressBarModel::HandleControllerEventL")) |
|
400 |
|
401 switch( aEvent ) |
|
402 { |
|
403 // --------------------------------------------------- |
|
404 /* Get it from CCameraController now. |
|
405 // if this is a record counter update event |
|
406 case ECamEventCounterUpdated: |
|
407 { |
|
408 PRINT( _L("Camera => CCamNaviProgressBarModel::HandleControllerEventL update")) |
|
409 iRecordTimeElapsed = iController.RecordTimeElapsed(); |
|
410 iRecordTimeRemaining = iController.RecordTimeRemaining(); |
|
411 FormatTimeL(); |
|
412 BroadcastEvent( ECamObserverEventNaviModelUpdated ); |
|
413 |
|
414 // See if we need to start blinking the elapsed time |
|
415 TTime time( iRecordTimeElapsed.Int64() ); |
|
416 TDateTime recordTime = time.DateTime(); |
|
417 |
|
418 if ( recordTime.Minute() != 0 && |
|
419 recordTime.Second() == 0 && |
|
420 !iFlashingTimer->IsActive() ) |
|
421 { |
|
422 iFlashingTimer->Start( KFlashInterval, |
|
423 KFlashInterval, |
|
424 TCallBack( FlashCallBack, this ) ); |
|
425 } |
|
426 break; |
|
427 } |
|
428 */ |
|
429 // --------------------------------------------------- |
|
430 case ECamEventEngineStateChanged: |
|
431 { |
|
432 // <CAMERAAPP_CAPI_V2_MIGRATION/> |
|
433 // if ( iController.EngineState() == ECamEngineVideoCapturePrepared ) |
|
434 if ( ECamCameraPreparedVideo == iController.CameraState() ) |
|
435 { |
|
436 iRecordTimeRemaining = iController.RecordTimeRemaining(); |
|
437 FormatTimeL(); |
|
438 BroadcastEvent( ECamObserverEventNaviModelUpdated ); |
|
439 } |
|
440 else |
|
441 { |
|
442 // empty statement to remove Lint error |
|
443 } |
|
444 break; |
|
445 } |
|
446 // --------------------------------------------------- |
|
447 case ECamEventOperationStateChanged: |
|
448 { |
|
449 if ( ECamControllerVideo == iController.CurrentMode() |
|
450 && ECamCapturing == iController.CurrentOperation() ) |
|
451 { |
|
452 // get the current media storage |
|
453 iStorageLocation = static_cast< TCamMediaStorage > |
|
454 ( iController.IntegerSettingValue( ECamSettingItemVideoMediaStorage ) ); |
|
455 } |
|
456 else |
|
457 { |
|
458 // empty statement to remove Lint error |
|
459 } |
|
460 break; |
|
461 } |
|
462 // --------------------------------------------------- |
|
463 case ECamEventRecordComplete: |
|
464 { |
|
465 // reset elapsed recording time |
|
466 iController.RecordTimeElapsed( iRecordTimeElapsed ); |
|
467 iRecordTimeElapsed = static_cast<TInt64>(0); |
|
468 iFlashingTimer->Cancel(); |
|
469 iFlash = EFalse; |
|
470 break; |
|
471 } |
|
472 // --------------------------------------------------- |
|
473 default: |
|
474 { |
|
475 break; |
|
476 } |
|
477 // --------------------------------------------------- |
|
478 } |
|
479 PRINT( _L("Camera <= CCamNaviProgressBarModel::HandleControllerEventL")) |
|
480 } |
|
481 |
|
482 // ----------------------------------------------------------------------------- |
|
483 // HandleCameraEventL |
|
484 // |
|
485 // ----------------------------------------------------------------------------- |
|
486 // |
|
487 void |
|
488 CCamNaviProgressBarModel |
|
489 ::HandleCameraEventL( TInt /*aStatus*/, |
|
490 TCamCameraEventId aEventId, |
|
491 TAny* aEventData /*= NULL*/ ) |
|
492 { |
|
493 PRINT( _L("Camera => CCamNaviProgressBarModel::HandleCameraEventL") ); |
|
494 switch( aEventId ) |
|
495 { |
|
496 // --------------------------------------------------- |
|
497 case ECamCameraEventVideoTimes: |
|
498 { |
|
499 TCamVideoRecordingTimes* times = |
|
500 static_cast<TCamVideoRecordingTimes*>( aEventData ); |
|
501 if( times ) |
|
502 { |
|
503 iRecordTimeElapsed = times->iTimeElapsed; |
|
504 iRecordTimeRemaining = times->iTimeRemaining; |
|
505 |
|
506 // If the time we have is greater than the maximum allowed, return the |
|
507 // maximum |
|
508 TTimeIntervalMicroSeconds maxRecordingLength( static_cast<TInt64>(KMaxRecordingLength) ); |
|
509 |
|
510 if( iRecordTimeRemaining > maxRecordingLength ) |
|
511 { |
|
512 iRecordTimeRemaining = maxRecordingLength; |
|
513 } |
|
514 |
|
515 FormatTimeL(); |
|
516 BroadcastEvent( ECamObserverEventNaviModelUpdated ); |
|
517 |
|
518 // See if we need to start blinking the elapsed time |
|
519 TTime time( iRecordTimeElapsed.Int64() ); |
|
520 TDateTime recordTime = time.DateTime(); |
|
521 |
|
522 if ( recordTime.Minute() != 0 |
|
523 && recordTime.Second() == 0 |
|
524 && !iFlashingTimer->IsActive() ) |
|
525 { |
|
526 iFlashingTimer->Start( KFlashInterval, |
|
527 KFlashInterval, |
|
528 TCallBack( FlashCallBack, this ) ); |
|
529 } |
|
530 } |
|
531 break; |
|
532 } |
|
533 // --------------------------------------------------- |
|
534 default: |
|
535 break; |
|
536 // --------------------------------------------------- |
|
537 } |
|
538 PRINT( _L("Camera <= CCamNaviProgressBarModel::HandleCameraEventL") ); |
|
539 } |
|
540 |
|
541 |
|
542 // ----------------------------------------------------------------------------- |
|
543 // CCamNaviProgressBarModel::FormatTimeL |
|
544 // Formats the elapsed/remaining record time |
|
545 // ----------------------------------------------------------------------------- |
|
546 // |
|
547 void CCamNaviProgressBarModel::FormatTimeL() |
|
548 { |
|
549 TTime time( iRecordTimeElapsed.Int64() ); |
|
550 time.FormatL( iElapsedTimeText, *iTimeFormat ); |
|
551 |
|
552 time = iRecordTimeRemaining.Int64(); |
|
553 time.FormatL( iRemainingTimeText, *iTimeFormat ); |
|
554 |
|
555 if ( iElapsedTimeTextItem ) |
|
556 { |
|
557 iElapsedTimeTextItem->SetTextL( iElapsedTimeText ); |
|
558 } |
|
559 |
|
560 if ( iRemainingTimeTextItem ) |
|
561 { |
|
562 iRemainingTimeTextItem->SetTextL( iRemainingTimeText ); |
|
563 } |
|
564 } |
|
565 |
|
566 // ----------------------------------------------------------------------------- |
|
567 // CCamNaviProgressBarModel::DrawElapsedTimeText |
|
568 // Draws the elapsed record time to the navi pane |
|
569 // ----------------------------------------------------------------------------- |
|
570 // |
|
571 void |
|
572 CCamNaviProgressBarModel::DrawElapsedTimeText( CBitmapContext& aGc ) const |
|
573 { |
|
574 if ( !iFlash && iElapsedTimeTextItem ) |
|
575 { |
|
576 iElapsedTimeTextItem->Draw( aGc ); |
|
577 } |
|
578 } |
|
579 |
|
580 // ----------------------------------------------------------------------------- |
|
581 // CCamNaviProgressBarModel::DrawRemainingTimeText |
|
582 // Draws the remaining record time to the navi pane |
|
583 // ----------------------------------------------------------------------------- |
|
584 // |
|
585 void |
|
586 CCamNaviProgressBarModel::DrawRemainingTimeText( CBitmapContext& aGc, |
|
587 MAknsSkinInstance* /*aSkin*/ ) const |
|
588 { |
|
589 if ( iRemainingTimeTextItem ) |
|
590 { |
|
591 iRemainingTimeTextItem->Draw( aGc ); |
|
592 } |
|
593 } |
|
594 |
|
595 // ----------------------------------------------------------------------------- |
|
596 // CCamNaviProgressBarModel::DrawProgressBar |
|
597 // Draws the progress bar to the navi pane |
|
598 // ----------------------------------------------------------------------------- |
|
599 // |
|
600 void |
|
601 CCamNaviProgressBarModel::DrawProgressBar( CBitmapContext& aGc ) const |
|
602 { |
|
603 PRINT( _L("Camera => CCamNaviProgressBarModel::DrawProgressBar")) |
|
604 |
|
605 // Draw frame |
|
606 TRect rect = iProgressBarRect.Rect(); |
|
607 |
|
608 aGc.BitBlt( rect.iTl, iProgressBarFrame ); |
|
609 |
|
610 // Draw the progress bar |
|
611 |
|
612 // Define the area of bitmap that is to be drawn |
|
613 TRect srcRect( 0, 0, 0, iProgressBarBitmap->SizeInPixels().iHeight ); |
|
614 TInt newWidth = rect.Width(); |
|
615 |
|
616 // If remaining record time is zero, do not try to perform the percentage |
|
617 // calculation, the progress bar will be full |
|
618 if ( iRecordTimeRemaining.Int64() > 0 ) |
|
619 { |
|
620 newWidth = static_cast<TInt>(( iRecordTimeElapsed.Int64() * rect.Width() ) |
|
621 / ( iRecordTimeElapsed.Int64() + iRecordTimeRemaining.Int64() )); |
|
622 } |
|
623 else |
|
624 { |
|
625 // empty statement to remove Lint error. |
|
626 } |
|
627 |
|
628 srcRect.SetWidth( newWidth ); |
|
629 |
|
630 aGc.BitBltMasked( rect.iTl, iProgressBarBitmap, srcRect, iProgressBarMask, ETrue ); |
|
631 } |
|
632 |
|
633 // --------------------------------------------------------- |
|
634 // CCamNaviProgressBarModel::SetExtentL |
|
635 // Sets the extent |
|
636 // --------------------------------------------------------- |
|
637 // |
|
638 void CCamNaviProgressBarModel::SetExtentL( const TRect& aExtent ) |
|
639 { |
|
640 iExtent = aExtent; |
|
641 } |
|
642 |
|
643 // --------------------------------------------------------- |
|
644 // CCamNaviProgressBarModel::RegisterObserverL |
|
645 // Registers an observer |
|
646 // --------------------------------------------------------- |
|
647 // |
|
648 void CCamNaviProgressBarModel::RegisterObserverL(MCamObserver* aObserver) |
|
649 { |
|
650 iObserverHandler->RegisterObserverL(aObserver); |
|
651 } |
|
652 |
|
653 // --------------------------------------------------------- |
|
654 // CCamNaviProgressBarModel::DeregisterObserver |
|
655 // Deregisters an observer |
|
656 // --------------------------------------------------------- |
|
657 // |
|
658 void CCamNaviProgressBarModel::DeregisterObserver(MCamObserver* aObserver) |
|
659 { |
|
660 iObserverHandler->DeregisterObserver(aObserver); |
|
661 } |
|
662 |
|
663 // --------------------------------------------------------- |
|
664 // CCamNaviProgressBarModel::BroadcastEvent |
|
665 // Broadcasts an event to all observers |
|
666 // --------------------------------------------------------- |
|
667 // |
|
668 void CCamNaviProgressBarModel::BroadcastEvent(TCamObserverEvent aEvent) |
|
669 { |
|
670 iObserverHandler->BroadcastEvent(aEvent); |
|
671 } |
|
672 |
|
673 // --------------------------------------------------------- |
|
674 // CCamNaviProgressBarModel::HandleObservedEvent |
|
675 // Handles observed events |
|
676 // --------------------------------------------------------- |
|
677 // |
|
678 void CCamNaviProgressBarModel::HandleObservedEvent(TCamObserverEvent aEvent) |
|
679 { |
|
680 if( aEvent == ECamObserverEventRecordingIconUpdated ) |
|
681 { |
|
682 BroadcastEvent(ECamObserverEventNaviModelUpdated); |
|
683 } |
|
684 } |
|
685 |
|
686 // --------------------------------------------------------- |
|
687 // CCamNaviProgressBarModel::DoCancel |
|
688 // Called when the flashing timer elapses |
|
689 // --------------------------------------------------------- |
|
690 // |
|
691 TInt CCamNaviProgressBarModel::FlashCallBack( TAny* aAny ) |
|
692 { |
|
693 CCamNaviProgressBarModel* self = static_cast<CCamNaviProgressBarModel*>( aAny ); |
|
694 TTime time( self->iRecordTimeElapsed.Int64() ); |
|
695 TDateTime recordTime = time.DateTime(); |
|
696 if ( recordTime.Second() != 0 ) |
|
697 { |
|
698 self->iFlashingTimer->Cancel(); |
|
699 self->iFlash = EFalse; |
|
700 } |
|
701 else |
|
702 { |
|
703 self->iFlash = !self->iFlash; |
|
704 self->BroadcastEvent( ECamObserverEventNaviModelUpdated ); |
|
705 } |
|
706 return KErrNone; |
|
707 } |
|
708 |
|
709 // --------------------------------------------------------- |
|
710 // CCamNaviProgressBarModel::TouchLayoutL |
|
711 // --------------------------------------------------------- |
|
712 void CCamNaviProgressBarModel::TouchLayoutL() |
|
713 { |
|
714 TInt variant = 0; // portrait |
|
715 TInt iconVariant = 1; |
|
716 if ( Layout_Meta_Data::IsLandscapeOrientation() ) |
|
717 { |
|
718 variant = 1; // landscape |
|
719 iconVariant = 0; |
|
720 } |
|
721 |
|
722 TAknLayoutRect progressPaneLayout; |
|
723 progressPaneLayout.LayoutRect( iExtent, |
|
724 AknLayoutScalable_Apps::vid4_progress_pane( variant ) ); |
|
725 |
|
726 TRect progressPaneRect = progressPaneLayout.Rect(); |
|
727 iElapsedTimeTextItem->SetLayoutL( progressPaneRect, |
|
728 AknLayoutScalable_Apps::vid4_progress_pane_t1( iconVariant ) ); |
|
729 iRemainingTimeTextItem->SetLayoutL( progressPaneRect, |
|
730 AknLayoutScalable_Apps::vid4_progress_pane_t2( iconVariant ) ); |
|
731 iProgressIconRect.LayoutRect( progressPaneRect, |
|
732 AknLayoutScalable_Apps::vid4_progress_pane_g4( iconVariant ) ); |
|
733 |
|
734 // Progress bar |
|
735 iProgressBarRect.LayoutRect( progressPaneRect, |
|
736 AknLayoutScalable_Apps::wait_bar_pane_cp07( iconVariant ) ); |
|
737 |
|
738 // Minimum progress pane rect for drawing while recording |
|
739 iProgPaneRect = iRemainingTimeTextItem->Rect(); |
|
740 iProgPaneRect.BoundingRect( iElapsedTimeTextItem->Rect() ); |
|
741 iProgPaneRect.BoundingRect( iProgressIconRect.Rect() ); |
|
742 iProgPaneRect.BoundingRect( iProgressBarRect.Rect() ); |
|
743 } |
|
744 |
|
745 // --------------------------------------------------------- |
|
746 // CCamNaviProgressBarModel::NonTouchLayoutL |
|
747 // Read nontouch layout for primary camera |
|
748 // --------------------------------------------------------- |
|
749 void CCamNaviProgressBarModel::NonTouchLayoutL() |
|
750 { |
|
751 TInt variant = 0; // Magic: layout Opt1 |
|
752 |
|
753 TInt cba = 1; // Magic: layout Opt1 |
|
754 |
|
755 TAknLayoutRect progressPaneLayout; |
|
756 |
|
757 progressPaneLayout.LayoutRect( iExtent, |
|
758 AknLayoutScalable_Apps::vid6_indi_pane( variant ) ); |
|
759 TRect progressPaneRect = progressPaneLayout.Rect(); |
|
760 |
|
761 iVidStorageIconRect.LayoutRect( progressPaneRect, |
|
762 AknLayoutScalable_Apps::vid6_indi_pane_g3( cba ) ); |
|
763 iElapsedTimeTextItem->SetLayoutL( progressPaneRect, |
|
764 AknLayoutScalable_Apps::vid6_indi_pane_t2( cba ) ); |
|
765 iRemainingTimeTextItem->SetLayoutL( progressPaneRect, |
|
766 AknLayoutScalable_Apps::vid6_indi_pane_t3( cba ) ); |
|
767 iProgressIconRect.LayoutRect( progressPaneRect, |
|
768 AknLayoutScalable_Apps::wait_bar_pane_cp08( 0 ) ); |
|
769 |
|
770 // Progress bar |
|
771 iProgressBarRect.LayoutRect( progressPaneRect, |
|
772 AknLayoutScalable_Apps::wait_bar_pane_cp08( 0 ) ); |
|
773 |
|
774 // Minimum progress pane rect for drawing while recording |
|
775 iProgPaneRect = iRemainingTimeTextItem->Rect(); |
|
776 iProgPaneRect.BoundingRect( iElapsedTimeTextItem->Rect() ); |
|
777 iProgPaneRect.BoundingRect( iProgressIconRect.Rect() ); |
|
778 iProgPaneRect.BoundingRect( iProgressBarRect.Rect() ); |
|
779 } |
|
780 |
|
781 // --------------------------------------------------------- |
|
782 // CCamNaviProgressBarModel::NonTouchLayoutSecondaryL |
|
783 // Read nontouch layout for secondary camera |
|
784 // --------------------------------------------------------- |
|
785 void CCamNaviProgressBarModel::NonTouchLayoutSecondaryL() |
|
786 { |
|
787 TRect screenRect; |
|
788 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, screenRect ); |
|
789 iExtent = screenRect; |
|
790 // Magic numbers used for layout variation |
|
791 TAknLayoutRect progressPaneLayout; |
|
792 progressPaneLayout.LayoutRect( iExtent, |
|
793 AknLayoutScalable_Apps::vid6_indi_pane( 3 ) ); |
|
794 |
|
795 iVidStorageIconRect.LayoutRect( progressPaneLayout.Rect(), |
|
796 AknLayoutScalable_Apps::vid6_indi_pane_g3( 3 ) ); |
|
797 |
|
798 TRect progressPaneRect = progressPaneLayout.Rect(); |
|
799 iElapsedTimeTextItem->SetLayoutL( progressPaneRect, |
|
800 AknLayoutScalable_Apps::vid6_indi_pane_t2( 2 ) ); |
|
801 iRemainingTimeTextItem->SetLayoutL( progressPaneRect, |
|
802 AknLayoutScalable_Apps::vid6_indi_pane_t3( 2 ) ); |
|
803 iProgressIconRect.LayoutRect( progressPaneRect, |
|
804 AknLayoutScalable_Apps::wait_bar_pane_cp08( 1 ) ); |
|
805 |
|
806 // Progress bar |
|
807 iProgressBarRect.LayoutRect( progressPaneRect, |
|
808 AknLayoutScalable_Apps::wait_bar_pane_cp08( 1 ) ); |
|
809 } |
|
810 |
|
811 // --------------------------------------------------------- |
|
812 // CCamNaviProgressBarModel::ProgPaneRect |
|
813 // |
|
814 // --------------------------------------------------------- |
|
815 TRect CCamNaviProgressBarModel::ProgPaneRect() |
|
816 { |
|
817 return iProgPaneRect; |
|
818 } |
|
819 |
|
820 // End of File |
|