|
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: Controls the state of the zoom* |
|
15 */ |
|
16 |
|
17 |
|
18 // Defining this will reduce the wait period between repeated |
|
19 // zoom in/out events being sent. This is just a development |
|
20 // test feature. |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "CamZoomModel.h" |
|
24 #include "CamZoomPane.h" |
|
25 #include "CamPSI.h" |
|
26 #include "CamUtility.h" |
|
27 #include "CamAppUi.h" |
|
28 |
|
29 // CONSTANTS |
|
30 |
|
31 // MACROS |
|
32 |
|
33 // LOCAL CONSTANTS AND MACROS |
|
34 |
|
35 // MODULE DATA STRUCTURES |
|
36 |
|
37 // LOCAL FUNCTION PROTOTYPES |
|
38 |
|
39 // FORWARD DECLARATIONS |
|
40 |
|
41 // ============================ MEMBER FUNCTIONS =============================== |
|
42 |
|
43 // ----------------------------------------------------------------------------- |
|
44 // CCamZoomModel::CCamZoomModel |
|
45 // C++ default constructor can NOT contain any code, that |
|
46 // might leave. |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 CCamZoomModel::CCamZoomModel( CCamAppController& aController, |
|
50 CCamZoomPane* aPane ) |
|
51 : iCurrentResolution( KErrNotReady ), |
|
52 iController( aController ), |
|
53 iPane( aPane ) |
|
54 { |
|
55 } |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CCamZoomModel::ConstructL |
|
59 // Symbian 2nd phase constructor can leave. |
|
60 // ----------------------------------------------------------------------------- |
|
61 // |
|
62 void CCamZoomModel::ConstructL() |
|
63 { |
|
64 PRINT( _L( "Camera => CCamZoomModel::ConstructL " ) ); |
|
65 |
|
66 // Retrieve the max digital zoom levels |
|
67 TPckgBuf <TCamMaxZoomSteps> pckg; |
|
68 CamUtility::GetPsiAnyL( ECamPsiMaxZoomSteps, &pckg ); |
|
69 iDigZoomSteps = pckg(); |
|
70 |
|
71 // Retrieve the max EXTENDED zoom levels |
|
72 TPckgBuf <TCamMaxZoomSteps> pckg2; |
|
73 CamUtility::GetPsiAnyL( ECamPsiMaxExtendedZoomSteps, &pckg2 ); |
|
74 iExtZoomSteps = pckg2(); |
|
75 |
|
76 // Retrieve the max OPTICAL zoom levels |
|
77 TPckgBuf <TCamMaxZoomSteps> pckg3; |
|
78 CamUtility::GetPsiAnyL( ECamPsiMaxOpticalZoomSteps, &pckg3 ); |
|
79 iOptZoomSteps = pckg3(); |
|
80 |
|
81 // Retrieve the timing and step values for each of the zoom bar |
|
82 // modes for Optical/Digital/Extended |
|
83 TPckgBuf <TCamZoomLAF> pckg4; |
|
84 CamUtility::GetPsiAnyL( ECamPsiZoomBarLAF, &pckg4); |
|
85 iZoomLAF = pckg4(); |
|
86 |
|
87 // Setting up initial internal values for zoom levels |
|
88 iCurZoomStepOptical = 0; |
|
89 iCurZoomStepDigital = 0; |
|
90 |
|
91 // Timer used to give smooth zooming |
|
92 iZoomTimer = CPeriodic::NewL( CActive::EPriorityHigh ); |
|
93 |
|
94 // Register for controller events |
|
95 iController.AddControllerObserverL( this ); |
|
96 |
|
97 // Create Zoom Update manager, which is used to |
|
98 // minimize the amount of times we send updates to |
|
99 // the camera driver. |
|
100 iCamZoomUpdateManager = CCamZoomUpdateManager::NewL( iController ); |
|
101 |
|
102 // This class and zoom pane are created on application start. |
|
103 // On app start, we should be setting the zoom to 1x, to |
|
104 // tidy up incase a previous app has not reset to defaults. |
|
105 ResetZoomTo1x(); |
|
106 |
|
107 PRINT( _L( "Camera <= CCamZoomModel::ConstructL " ) ); |
|
108 } |
|
109 |
|
110 // ----------------------------------------------------------------------------- |
|
111 // CCamZoomModel::NewL |
|
112 // Two-phased constructor. |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 CCamZoomModel* CCamZoomModel::NewL( CCamAppController& aController, CCamZoomPane* aPane ) |
|
116 { |
|
117 CCamZoomModel* self = new( ELeave ) CCamZoomModel( aController, aPane ); |
|
118 |
|
119 CleanupStack::PushL( self ); |
|
120 self->ConstructL(); |
|
121 CleanupStack::Pop(); |
|
122 |
|
123 return self; |
|
124 } |
|
125 |
|
126 |
|
127 // ----------------------------------------------------------------------------- |
|
128 // CCamZoomModel::~CCamZoomModel |
|
129 // Destructor. |
|
130 // ----------------------------------------------------------------------------- |
|
131 // |
|
132 CCamZoomModel::~CCamZoomModel() |
|
133 { |
|
134 PRINT( _L("Camera => ~CCamZoomModel" )) |
|
135 |
|
136 iController.RemoveControllerObserver( this ); |
|
137 if ( iZoomTimer && iZoomTimer->IsActive() ) |
|
138 { |
|
139 iZoomTimer->Cancel(); |
|
140 } |
|
141 delete iZoomTimer; |
|
142 |
|
143 if ( iCamZoomUpdateManager && iCamZoomUpdateManager->IsActive() ) |
|
144 { |
|
145 iCamZoomUpdateManager->Cancel(); |
|
146 } |
|
147 delete iCamZoomUpdateManager; |
|
148 |
|
149 iPane = NULL; // Not owned |
|
150 PRINT( _L("Camera <= ~CCamZoomModel" )) |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CCamZoomModel::ZoomTo |
|
155 // Attempts to zoom to a specified value. |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CCamZoomModel::ZoomTo( TInt aValue ) |
|
159 { |
|
160 PRINT( _L( "Camera => CCamZoomModel::ZoomTo " ) ); |
|
161 // Note: The following code only supports digital or |
|
162 // digital+extended zoom combinations. |
|
163 // Optical zoom is not taken into consideration. |
|
164 |
|
165 // avoid mixups between button and touch presses |
|
166 if ( ZoomingState() != ECamZoomModelStateZoomNone ) |
|
167 { |
|
168 PRINT( _L( "Camera <> CCamZoomModel::ZoomTo stopping keypress zoom" ) ); |
|
169 StopZoom(); |
|
170 } |
|
171 |
|
172 // Start the zoom state |
|
173 iState = ECamZoomModelStateZoomTo; |
|
174 |
|
175 // We don't support pausing between boundaries. If the |
|
176 // user experience so requires, it should be implemented here. |
|
177 |
|
178 // Update the zoom values |
|
179 // Note: Both digital and extended zoom are represented by iCurZoomStepDigital. |
|
180 // We assume the maximum value is already checked |
|
181 // in CCamZoomPane::StartTouchZoomL |
|
182 PRINT1( _L( "Camera <> CCamZoomModel::ZoomTo iMaxZoomStepDig=%d" ), iMaxZoomStepDig ); |
|
183 PRINT1( _L( "Camera <> CCamZoomModel::ZoomTo iMaxZoomStepExt=%d" ), iMaxZoomStepExt ); |
|
184 PRINT1( _L( "Camera <> CCamZoomModel::ZoomTo iCurZoomStepDigital=%d" ), iCurZoomStepDigital ); |
|
185 iCurZoomStepDigital = aValue; |
|
186 if ( iCurZoomStepDigital < iMaxZoomStepDig ) |
|
187 { |
|
188 CheckZoomMode( ECamZoomModeExtended ); |
|
189 } |
|
190 else |
|
191 { |
|
192 CheckZoomMode( ECamZoomModeDigital ); |
|
193 } |
|
194 |
|
195 // Notify the camera driver |
|
196 PRINT1( _L( "Camera <> CCamZoomModel::ZoomTo to (aValue) %d" ), aValue ); |
|
197 iCamZoomUpdateManager->SetZoomValue( iCurZoomStepDigital ); |
|
198 |
|
199 // Tell the zoom pane the value to show. |
|
200 PRINT1( _L( "CCamZoomModel::ZoomTo set zoom pane %d" ), CurrentZoom() ); |
|
201 iPane->SetZoomValue( CurrentZoom() ); |
|
202 |
|
203 // Clear the zoom state |
|
204 iState = ECamZoomModelStateZoomNone; |
|
205 |
|
206 PRINT( _L( "Camera <= CCamZoomModel::ZoomTo " ) ); |
|
207 } |
|
208 |
|
209 // ----------------------------------------------------------------------------- |
|
210 // CCamZoomModel::ZoomIn |
|
211 // Attempts to zoom in one step (if one more step available). |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 void CCamZoomModel::ZoomIn( TBool aOneClick ) |
|
215 { |
|
216 PRINT( _L( "Camera => CCamZoomModel::ZoomIn " ) ); |
|
217 iState = ECamZoomModelStateZoomIn; |
|
218 TInt optZoomJump = 0; |
|
219 TInt digZoomJump = 0; |
|
220 TInt extZoomJump = 0; |
|
221 |
|
222 ZoomStepsToJump( optZoomJump, digZoomJump, extZoomJump ); |
|
223 PRINT3( _L( "CCamZoomModel::ZoomIn steps opt(%d) dig(%d) ext(%d) " ), optZoomJump, digZoomJump, extZoomJump ); |
|
224 |
|
225 // First of all, check what the current boundary condition is |
|
226 // then check if we need to pause at that boundary. |
|
227 PRINT( _L( "ZoomIn boundary check start" ) ); |
|
228 |
|
229 TCamZoomBoundary boundary = CheckBoundary(); |
|
230 if ( PauseAtBoundary( boundary ) ) |
|
231 { |
|
232 if ( iPauseState == EPauseStateNone ) |
|
233 { |
|
234 PRINT( _L( "ZoomIn at boundary EPauseStateNone return" ) ); |
|
235 // If this is a new pause, update the state and return |
|
236 // (no zoom allowed until release) |
|
237 iPauseState = EPauseStatePaused; |
|
238 return; |
|
239 } |
|
240 else if ( iPauseState == EPauseStatePaused ) |
|
241 { |
|
242 PRINT( _L( "ZoomIn at boundary EPauseStatePaused return" ) ); |
|
243 // If still paused, return (no zoom allowed until release) |
|
244 return; |
|
245 } |
|
246 else // EPauseStateReleased |
|
247 { |
|
248 PRINT( _L( "ZoomIn at boundary EPauseStateReleased allow" ) ); |
|
249 // If released, allow the zoom, but set the state |
|
250 // back to none. |
|
251 iPauseState = EPauseStateNone; |
|
252 } |
|
253 } |
|
254 |
|
255 PRINT( _L( "ZoomIn at boundary EPauseStateNone boundary check end" ) ); |
|
256 |
|
257 if ( optZoomJump ) |
|
258 { |
|
259 CheckZoomMode( ECamZoomModeOptical ); |
|
260 iCurZoomStepOptical += optZoomJump; |
|
261 PRINT1( _L( "Camera => CCamZoomModel::ZoomIn opt to %d" ), iCurZoomStepOptical ); |
|
262 //iController.SetZoomValue( iCurZoomStepOptical ); |
|
263 iCamZoomUpdateManager->SetZoomValue( iCurZoomStepOptical ); |
|
264 } |
|
265 |
|
266 if ( digZoomJump ) |
|
267 { |
|
268 CheckZoomMode( ECamZoomModeDigital ); |
|
269 iCurZoomStepDigital += digZoomJump; |
|
270 PRINT1( _L( "Camera => CCamZoomModel::ZoomIn dig to %d" ), iCurZoomStepDigital ); |
|
271 //iController.SetZoomValue( iCurZoomStepDigital ); |
|
272 iCamZoomUpdateManager->SetZoomValue( iCurZoomStepDigital ); |
|
273 } |
|
274 |
|
275 if ( extZoomJump ) |
|
276 { |
|
277 CheckZoomMode( ECamZoomModeExtended ); |
|
278 iCurZoomStepDigital += extZoomJump; |
|
279 PRINT1( _L( "Camera => CCamZoomModel::ZoomIn ext to %d" ), iCurZoomStepDigital ); |
|
280 //iController.SetZoomValue( iCurZoomStepDigital ); |
|
281 iCamZoomUpdateManager->SetZoomValue( iCurZoomStepDigital ); |
|
282 } |
|
283 |
|
284 // Tell the zoom pane the value to show. |
|
285 PRINT1( _L( "CCamZoomModel::ZoomIn set zoom pane %d" ), CurrentZoom() ); |
|
286 iPane->SetZoomValue( CurrentZoom() ); |
|
287 |
|
288 if ( aOneClick ) |
|
289 { |
|
290 // Do not start zoom timer |
|
291 PRINT( _L( "CCamZoomModel::ZoomIn one click" ) ); |
|
292 iState = ECamZoomModelStateZoomNone; |
|
293 } |
|
294 else |
|
295 { |
|
296 // Start the timer to zoom-in again when timer expires |
|
297 PRINT( _L( "CCamZoomModel::ZoomIn start zoom timer" ) ); |
|
298 StartZoomTimer(); |
|
299 } |
|
300 |
|
301 PRINT( _L( "Camera <= CCamZoomModel::ZoomIn " ) ); |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // CCamZoomModel::CheckBoundary |
|
306 // Checks whether the next zoom operation will cross a zoom mode boundary. |
|
307 // For example from Optical to Digital or from Digital to Extended |
|
308 // --------------------------------------------------------------------------- |
|
309 // |
|
310 CCamZoomModel::TCamZoomBoundary CCamZoomModel::CheckBoundary() const |
|
311 { |
|
312 PRINT( _L( "Camera => CCamZoomModel::CheckBoundary " ) ); |
|
313 |
|
314 TCamZoomBoundary retVal = ECamZoomBoundaryNone; |
|
315 |
|
316 TCamZoomMode modeBefore = CurrentZoomType(); |
|
317 TCamZoomMode modeAfter = CurrentZoomType( ZoomStepsToJump() ); |
|
318 |
|
319 if ( modeBefore != modeAfter ) |
|
320 { |
|
321 if ( modeBefore == ECamZoomModeOptical && modeAfter == ECamZoomModeDigital || |
|
322 modeBefore == ECamZoomModeDigital && modeAfter == ECamZoomModeOptical ) |
|
323 { |
|
324 PRINT( _L( "Camera <> CCamZoomModel::CheckBoundary ECamZoomBoundaryOptDig" ) ); |
|
325 retVal = ECamZoomBoundaryOptDig; |
|
326 } |
|
327 else if ( modeBefore == ECamZoomModeExtended && modeAfter == ECamZoomModeDigital || |
|
328 modeBefore == ECamZoomModeDigital && modeAfter == ECamZoomModeExtended ) |
|
329 { |
|
330 PRINT( _L( "Camera <> CCamZoomModel::CheckBoundary ECamZoomBoundaryDigExt" ) ); |
|
331 retVal = ECamZoomBoundaryDigExt; |
|
332 } |
|
333 else |
|
334 { |
|
335 // Undefined boundary, should not allow further zooming |
|
336 PRINT( _L( "Camera <> CCamZoomModel::CheckBoundary ECamZoomBoundaryUndefined" ) ); |
|
337 retVal = ECamZoomBoundaryUndefined; |
|
338 } |
|
339 } |
|
340 else |
|
341 { |
|
342 PRINT( _L( "Camera <> CCamZoomModel::CheckBoundary ECamZoomBoundaryNone" ) ); |
|
343 retVal = ECamZoomBoundaryNone; |
|
344 } |
|
345 |
|
346 PRINT( _L( "Camera <= CCamZoomModel::CheckBoundary " ) ); |
|
347 return retVal; |
|
348 } |
|
349 |
|
350 |
|
351 // --------------------------------------------------------------------------- |
|
352 // CCamZoomModel::ZoomStepsToJump |
|
353 // Returns the total number of zoom steps to jump based on the current |
|
354 // zoom mode (opt/dig/ext). Does not break these steps into optical/digital |
|
355 // steps to jump, as may be the case on a boundary. |
|
356 // --------------------------------------------------------------------------- |
|
357 // |
|
358 TInt CCamZoomModel::ZoomStepsToJump() const |
|
359 { |
|
360 PRINT( _L( "Camera => CCamZoomModel::ZoomStepsToJump " ) ); |
|
361 |
|
362 TInt steps = 0; |
|
363 |
|
364 if ( iController.ActiveCamera() == ECamActiveCameraPrimary ) |
|
365 { |
|
366 // Works out the current zoom mode (opt/dig/ext) |
|
367 TCamZoomMode mode = CurrentZoomType(); |
|
368 PRINT1( _L( "Camera <> CCamZoomModel::ZoomStepsToJump mode = %d" ), mode ); |
|
369 |
|
370 if ( mode == ECamZoomModeOptical ) |
|
371 { |
|
372 steps = iZoomLAF.iZoomStepsOpt; |
|
373 PRINT1( _L( "Camera <> CCamZoomModel::ZoomStepsToJump ECamZoomModeOptical steps = %d" ), steps ); |
|
374 } |
|
375 else if ( mode == ECamZoomModeDigital ) |
|
376 { |
|
377 steps = iZoomLAF.iZoomStepsDig; |
|
378 PRINT1( _L( "Camera <> CCamZoomModel::ZoomStepsToJump ECamZoomModeDigital steps = %d" ), steps ); |
|
379 } |
|
380 else if ( mode == ECamZoomModeExtended ) |
|
381 { |
|
382 steps = iZoomLAF.iZoomStepsExt; |
|
383 PRINT1( _L( "Camera <> CCamZoomModel::ZoomStepsToJump ECamZoomModeExtended steps = %d" ), steps ); |
|
384 } |
|
385 else |
|
386 { |
|
387 steps = 0; |
|
388 } |
|
389 } |
|
390 else if ( iController.ActiveCamera() == ECamActiveCameraSecondary ) |
|
391 { |
|
392 //steps = K2ndCamZoomStepSize; |
|
393 steps = iZoomLAF.iSecondCameraZoomSteps; |
|
394 PRINT1( _L( "Camera <> CCamZoomModel::ZoomStepsToJump K2ndCamZoomStepSize steps = %d" ), steps ); |
|
395 } |
|
396 else |
|
397 { |
|
398 } |
|
399 |
|
400 |
|
401 if ( iState == ECamZoomModelStateZoomOut ) |
|
402 { |
|
403 steps = -steps; |
|
404 PRINT1( _L( "Camera <> CCamZoomModel::ZoomStepsToJump Inverse, since ZoomOut: steps = %d" ), steps ); |
|
405 } |
|
406 |
|
407 PRINT( _L( "Camera <= CCamZoomModel::ZoomStepsToJump " ) ); |
|
408 return steps; |
|
409 } |
|
410 |
|
411 // --------------------------------------------------------------------------- |
|
412 // CCamZoomModel::ZoomStepsToJump |
|
413 // Returns the number of Optical, Digital and Extended zoom steps to jump |
|
414 // --------------------------------------------------------------------------- |
|
415 // |
|
416 void CCamZoomModel::ZoomStepsToJump( TInt& aOpt, TInt& aDig, TInt& aExt ) const |
|
417 { |
|
418 PRINT( _L( "Camera => CCamZoomModel::ZoomStepsToJump (by reference)" ) ); |
|
419 |
|
420 TInt steps = ZoomStepsToJump(); |
|
421 |
|
422 TCamZoomBoundary boundary = CheckBoundary(); |
|
423 |
|
424 // If jumping this number of steps will make us cross the boundary, |
|
425 // we need to split the steps up into the composite opt/dig steps. |
|
426 // Depending on if we are pausing or not, we may not want to cross |
|
427 // the boundary yet |
|
428 if ( boundary == ECamZoomBoundaryOptDig ) |
|
429 { |
|
430 if ( iState == ECamZoomModelStateZoomIn ) |
|
431 { |
|
432 // Zooming in, then assign what we can to Optical, to get to max step |
|
433 // any remainder then goes to digital |
|
434 TInt optJumpMax = iMaxZoomStepOpt - iCurZoomStepOptical; |
|
435 aOpt = optJumpMax; |
|
436 aDig = steps - optJumpMax; |
|
437 |
|
438 // If the zoom in was going to take the digital zoom beyond the max |
|
439 // allowed, clip it |
|
440 if ( aDig > iMaxZoomStepDig ) |
|
441 aDig = iMaxZoomStepDig; |
|
442 } |
|
443 else if ( iState == ECamZoomModelStateZoomOut ) |
|
444 { |
|
445 // Zooming out, then assign what we can to Digital, to get to min step |
|
446 // any remainder then goes to optical |
|
447 aDig = -iCurZoomStepDigital; |
|
448 aOpt = steps + iCurZoomStepDigital; // zooming out, steps is -ve |
|
449 } |
|
450 else |
|
451 { |
|
452 // Lint |
|
453 } |
|
454 } |
|
455 else if ( boundary == ECamZoomBoundaryDigExt ) |
|
456 { |
|
457 if ( iState == ECamZoomModelStateZoomIn ) |
|
458 { |
|
459 // Zooming in, then assign what we can to Optical, to get to max step |
|
460 // any remainder then goes to digital |
|
461 TInt digJumpMax = iMaxZoomStepDig - iCurZoomStepDigital; |
|
462 aDig = digJumpMax; |
|
463 aExt = steps - digJumpMax; |
|
464 |
|
465 // If the zoom in was going to take the digital zoom beyond the max |
|
466 // allowed, clip it |
|
467 if ( aExt > iMaxZoomStepExt ) |
|
468 aExt = iMaxZoomStepExt; |
|
469 } |
|
470 else if ( iState == ECamZoomModelStateZoomOut ) |
|
471 { |
|
472 // Zooming out, then assign what we can to Digital, to get to min step |
|
473 // any remainder then goes to optical |
|
474 //aDig = iCurZoomStepDigital; |
|
475 aDig = steps; |
|
476 //aExt = steps - iCurZoomStepDigital; |
|
477 } |
|
478 else |
|
479 { |
|
480 // Lint |
|
481 } |
|
482 } |
|
483 else if ( boundary == ECamZoomBoundaryNone ) |
|
484 { |
|
485 // No boundary crossed. Can assign the steps to the current |
|
486 // mode |
|
487 TCamZoomMode mode = CurrentZoomType(); |
|
488 |
|
489 if ( iState == ECamZoomModelStateZoomIn ) |
|
490 { |
|
491 if ( mode == ECamZoomModeOptical && AllowOptZoom() ) |
|
492 { |
|
493 aOpt = steps; |
|
494 if ( iCurZoomStepOptical + aOpt > iMaxZoomStepOpt ) |
|
495 { |
|
496 aOpt = iMaxZoomStepOpt - iCurZoomStepOptical; |
|
497 } |
|
498 } |
|
499 else if ( mode == ECamZoomModeDigital && AllowDigZoom() ) |
|
500 { |
|
501 aDig = steps; |
|
502 if ( iCurZoomStepDigital + aDig > iMaxZoomStepDig ) |
|
503 { |
|
504 aDig = iMaxZoomStepDig - iCurZoomStepDigital; |
|
505 } |
|
506 } |
|
507 else if ( mode == ECamZoomModeExtended && AllowExtZoom() ) |
|
508 { |
|
509 aExt = steps; |
|
510 if ( iCurZoomStepDigital + aExt > iMaxZoomStepExt ) |
|
511 { |
|
512 aExt = iMaxZoomStepExt - iCurZoomStepDigital; |
|
513 } |
|
514 } |
|
515 else |
|
516 { |
|
517 // Do nothing (as invalid state) |
|
518 } |
|
519 } |
|
520 else if ( iState == ECamZoomModelStateZoomOut ) |
|
521 { |
|
522 if ( mode == ECamZoomModeOptical && AllowOptZoom() ) |
|
523 { |
|
524 aOpt = steps; |
|
525 if ( iCurZoomStepOptical + aOpt < 0 ) |
|
526 { |
|
527 aOpt = -iCurZoomStepOptical; |
|
528 } |
|
529 } |
|
530 else if ( mode == ECamZoomModeDigital && AllowDigZoom() ) |
|
531 { |
|
532 aDig = steps; |
|
533 if ( iCurZoomStepDigital + aDig < 0 ) |
|
534 { |
|
535 aDig = -iCurZoomStepDigital; |
|
536 } |
|
537 } |
|
538 else if ( mode == ECamZoomModeExtended && AllowExtZoom() ) |
|
539 { |
|
540 aExt = steps; |
|
541 if ( iCurZoomStepDigital + aExt < iMaxZoomStepDig ) |
|
542 { |
|
543 aExt = iMaxZoomStepDig - iCurZoomStepDigital; |
|
544 } |
|
545 } |
|
546 else |
|
547 { |
|
548 // Do nothing (as invalid state) |
|
549 } |
|
550 } |
|
551 else |
|
552 { |
|
553 // Lint |
|
554 } |
|
555 } |
|
556 else // ECamZoomBoundaryUndefined |
|
557 { |
|
558 // If undefined boundary, this would result in an invalid |
|
559 // zoom valid if we zoom, so set all steps to zero. |
|
560 // This will stop any zoom operation from changing state. |
|
561 aOpt = 0; |
|
562 aDig = 0; |
|
563 aExt = 0; |
|
564 } |
|
565 |
|
566 PRINT( _L( "Camera <= CCamZoomModel::ZoomStepsToJump " ) ); |
|
567 } |
|
568 |
|
569 |
|
570 // --------------------------------------------------------------------------- |
|
571 // CCamZoomModel::CurrentZoomType |
|
572 // Returns the zoom type (opt/dig/ext) based on current zoom levels modified |
|
573 // by the specified optical/digital valies |
|
574 // --------------------------------------------------------------------------- |
|
575 // |
|
576 TCamZoomMode CCamZoomModel::CurrentZoomType( TInt aStepModifier ) const |
|
577 { |
|
578 PRINT( _L( "Camera => CCamZoomModel::CurrentZoomType " ) ); |
|
579 |
|
580 TInt maxOptZoomStep = ( iMaxZoomStepOpt == KErrNotSupported || !AllowOptZoom() )? 0 : iMaxZoomStepOpt; |
|
581 TInt maxStdZoomStep = ( iMaxZoomStepDig == KErrNotSupported || !AllowDigZoom() )? maxOptZoomStep : maxOptZoomStep + iMaxZoomStepDig; |
|
582 TInt maxExtZoomStep = ( iMaxZoomStepExt == KErrNotSupported || !AllowExtZoom() )? maxStdZoomStep : maxStdZoomStep + iMaxZoomStepExt; |
|
583 |
|
584 // |
|
585 TInt step = CurrentZoom() + aStepModifier; |
|
586 |
|
587 // Optical runs from step 0 to maxOptZoomStep |
|
588 if ( step <= maxOptZoomStep && // Not at max opt zoom level |
|
589 AllowOptZoom() ) // ... and optical zoom is allowed |
|
590 { |
|
591 PRINT( _L( "Camera <= CCamZoomModel::CurrentZoomType ECamZoomModeOptical" ) ); |
|
592 return ECamZoomModeOptical; |
|
593 } |
|
594 // Digital runs from maxOptZoomStep to maxOptZoomStep+maxStdZoomStep |
|
595 else if ( step >= maxOptZoomStep && |
|
596 step <= maxStdZoomStep && // Inside std zoom step limits |
|
597 AllowDigZoom() ) // ...and is allowed by user setting |
|
598 { |
|
599 PRINT( _L( "Camera <= CCamZoomModel::CurrentZoomType ECamZoomModeDigital" ) ); |
|
600 return ECamZoomModeDigital; |
|
601 } |
|
602 // Extended runs from maxOptZoomStep+maxStdZoomStep to maxOptZoomStep+maxStdZoomStep |
|
603 else if ( step >= maxStdZoomStep && |
|
604 step <= maxExtZoomStep && // Inside ext zoom step limits |
|
605 AllowExtZoom() ) // ...and ext zoom is allowed by user |
|
606 { |
|
607 PRINT( _L( "Camera <= CCamZoomModel::CurrentZoomType ECamZoomModeExtended" ) ); |
|
608 return ECamZoomModeExtended; |
|
609 } |
|
610 else |
|
611 { |
|
612 PRINT( _L( "Camera <= CCamZoomModel::CurrentZoomType ECamZoomModeUndefined" ) ); |
|
613 return ECamZoomModeUndefined; |
|
614 } |
|
615 } |
|
616 |
|
617 // ----------------------------------------------------------------------------- |
|
618 // CCamZoomModel::ZoomOut |
|
619 // Attempts to zoom out one step (if one more step available). |
|
620 // ----------------------------------------------------------------------------- |
|
621 // |
|
622 void CCamZoomModel::ZoomOut( TBool aOneClick ) |
|
623 { |
|
624 PRINT( _L( "Camera => CCamZoomModel::ZoomOut " ) ); |
|
625 iState = ECamZoomModelStateZoomOut; |
|
626 TInt optZoomJump = 0; |
|
627 TInt digZoomJump = 0; |
|
628 TInt extZoomJump = 0; |
|
629 |
|
630 ZoomStepsToJump( optZoomJump, digZoomJump, extZoomJump ); |
|
631 PRINT3( _L( "CCamZoomModel::ZoomOut steps opt(%d) dig(%d) ext(%d) " ), optZoomJump, digZoomJump, extZoomJump ); |
|
632 |
|
633 if ( optZoomJump ) |
|
634 { |
|
635 CheckZoomMode( ECamZoomModeOptical ); |
|
636 iCurZoomStepOptical += optZoomJump; |
|
637 PRINT1( _L( "Camera => CCamZoomModel::ZoomOut opt to %d" ), iCurZoomStepOptical ); |
|
638 //iController.SetZoomValue( iCurZoomStepOptical ); |
|
639 iCamZoomUpdateManager->SetZoomValue( iCurZoomStepOptical ); |
|
640 } |
|
641 |
|
642 if ( digZoomJump ) |
|
643 { |
|
644 CheckZoomMode( ECamZoomModeDigital ); |
|
645 iCurZoomStepDigital += digZoomJump; |
|
646 PRINT1( _L( "Camera => CCamZoomModel::ZoomOut dig to %d" ), iCurZoomStepDigital ); |
|
647 //iController.SetZoomValue( iCurZoomStepDigital ); |
|
648 iCamZoomUpdateManager->SetZoomValue( iCurZoomStepDigital ); |
|
649 } |
|
650 |
|
651 if ( extZoomJump ) |
|
652 { |
|
653 CheckZoomMode( ECamZoomModeExtended ); |
|
654 iCurZoomStepDigital += extZoomJump; |
|
655 PRINT1( _L( "Camera => CCamZoomModel::ZoomOut ext to %d" ), iCurZoomStepDigital ); |
|
656 //iController.SetZoomValue( iCurZoomStepDigital ); |
|
657 iCamZoomUpdateManager->SetZoomValue( iCurZoomStepDigital ); |
|
658 } |
|
659 |
|
660 // Tell the zoom pane the value to show. |
|
661 PRINT1( _L( "ZoomOut set zoom pane %d" ), CurrentZoom() ); |
|
662 iPane->SetZoomValue( CurrentZoom() ); |
|
663 |
|
664 if ( aOneClick ) |
|
665 { |
|
666 // Do not start zoom timer |
|
667 PRINT( _L( "CCamZoomModel::ZoomIn one click" ) ); |
|
668 iState = ECamZoomModelStateZoomNone; |
|
669 } |
|
670 else |
|
671 { |
|
672 // Start the timer to zoom-in again when timer expires |
|
673 PRINT( _L( "CCamZoomModel::ZoomIn start zoom timer" ) ); |
|
674 StartZoomTimer(); |
|
675 } |
|
676 |
|
677 PRINT( _L( "Camera <= CCamZoomModel::ZoomOut " ) ); |
|
678 } |
|
679 |
|
680 // ----------------------------------------------------------------------------- |
|
681 // CCamZoomModel::CheckZoomMode |
|
682 // Checks to see if the zoom mode needs to be changed. |
|
683 // The purpose is to avoid unneccessary calls to SetZoomMode where possible |
|
684 // ----------------------------------------------------------------------------- |
|
685 // |
|
686 void CCamZoomModel::CheckZoomMode( TCamZoomMode aMode ) |
|
687 { |
|
688 PRINT( _L( "Camera => CCamZoomModel::CheckZoomMode " ) ); |
|
689 if ( iZoomMode != aMode |
|
690 && ECamZoomModeUndefined != aMode ) |
|
691 { |
|
692 //iController.SetZoomMode( aMode ); |
|
693 PRINT2( _L( "Camera <> CCamZoomModel::CheckZoomMode iZoomMode changed (%d) -> (%d) " ), aMode, iZoomMode ); |
|
694 iZoomMode = aMode; |
|
695 } |
|
696 PRINT( _L( "Camera <= CCamZoomModel::CheckZoomMode " ) ); |
|
697 } |
|
698 |
|
699 // ----------------------------------------------------------------------------- |
|
700 // CCamZoomModel::RefreshSettings |
|
701 // Checks the current state of the Camera application, and adjusts the min/max |
|
702 // range of the zoom pane accordingly. |
|
703 // ----------------------------------------------------------------------------- |
|
704 // |
|
705 void CCamZoomModel::RefreshSettings() |
|
706 { |
|
707 PRINT( _L("Camera => CCamZoomModel::RefreshSettings") ); |
|
708 // If there is no active camera yet, or engine is not |
|
709 // in a prepared state yet, do not try to refresh settings |
|
710 // as we can't work out what to base it on. |
|
711 |
|
712 // <CAMERAAPP_CAPI_V2_MIGRATION/> |
|
713 if( iController.ActiveCamera() == ECamActiveCameraNone |
|
714 || !( iCameraState & (ECamImageOn|ECamVideoOn) ) |
|
715 ) |
|
716 { |
|
717 return; |
|
718 } |
|
719 |
|
720 // Cache the current resolution to be used when |
|
721 // determining zoom limits and steps. |
|
722 ReadCurrentResolution(); |
|
723 |
|
724 // Read settings to update internal state |
|
725 ReadOpticalZoomSetting(); |
|
726 ReadDigitalZoomSetting(); |
|
727 |
|
728 iMaxZoomStepOpt = MaxZoomStep( iOptZoomSteps ); |
|
729 iMaxZoomStepDig = MaxZoomStep( iDigZoomSteps ); |
|
730 iMaxZoomStepExt = MaxZoomStep( iExtZoomSteps ); |
|
731 |
|
732 iMaxZoomStep = 0; |
|
733 |
|
734 PRINT3( _L("Camera <> CCamZoomModel: max steps opt:%d dig:%d ext:%d"), iMaxZoomStepOpt, iMaxZoomStepDig, iMaxZoomStepExt ); |
|
735 |
|
736 if ( AllowOptZoom() ) |
|
737 { |
|
738 iMaxZoomStep += iMaxZoomStepOpt; |
|
739 } |
|
740 |
|
741 // Check if Digital zoom is allowed |
|
742 if ( AllowDigZoom() ) |
|
743 { |
|
744 // Check if EXTENDED zoom is allowed by user setting |
|
745 // and the value is valid. For secondary camera, it may |
|
746 // be that it is not supported. |
|
747 if ( AllowExtZoom() ) // done in AllowExtZoom: && iMaxZoomStepExt != KErrNotSupported) |
|
748 { |
|
749 iMaxZoomStep += iMaxZoomStepExt; |
|
750 } |
|
751 else |
|
752 { |
|
753 iMaxZoomStep += iMaxZoomStepDig; |
|
754 } |
|
755 } |
|
756 |
|
757 TInt optSteps = ( AllowOptZoom() ) ? iMaxZoomStepOpt : 0; |
|
758 TInt stdSteps = ( AllowDigZoom() ) ? iMaxZoomStepDig : 0; |
|
759 TInt extSteps = ( AllowExtZoom() ) ? Max( (iMaxZoomStepExt - iMaxZoomStepDig), 0 ) : 0; |
|
760 |
|
761 // Check that the max zoom is within (possibly new) limits |
|
762 CheckZoomLimit(); |
|
763 |
|
764 if ( iPane ) |
|
765 { |
|
766 // Inform the zoom pane of the new range of zoom steps |
|
767 iPane->SetZoomRange( 0, iMaxZoomStep ); |
|
768 iPane->SetZoomSteps( optSteps, stdSteps, extSteps ); |
|
769 iPane->SetZoomValue( CurrentZoom() ); |
|
770 } |
|
771 |
|
772 PRINT( _L("Camera <= CCamZoomModel::RefreshSettings") ); |
|
773 } |
|
774 |
|
775 |
|
776 // ----------------------------------------------------------------------------- |
|
777 // CCamZoomModel::ReadDigitalZoomSetting |
|
778 // Updates the setting for digital/extended zoom or not depending if user |
|
779 // setting for it is on AND we have a valid setting for it. |
|
780 // ----------------------------------------------------------------------------- |
|
781 // |
|
782 void CCamZoomModel::ReadDigitalZoomSetting() |
|
783 { |
|
784 iZoomSetting = static_cast<TCamSettingsDigitalZoom>( |
|
785 iController.IntegerSettingValue( ECamSettingItemPhotoDigitalZoom ) ); |
|
786 } |
|
787 |
|
788 |
|
789 |
|
790 // ----------------------------------------------------------------------------- |
|
791 // CCamZoomModel::ReadOpticalZoomSetting |
|
792 // Reads whether optical zoom is allowed |
|
793 // ----------------------------------------------------------------------------- |
|
794 // |
|
795 void CCamZoomModel::ReadOpticalZoomSetting() |
|
796 { |
|
797 } |
|
798 |
|
799 |
|
800 // ----------------------------------------------------------------------------- |
|
801 // CCamZoomModel::CheckZoomLimit |
|
802 // Checks whether the current zoom level is too great for the limits. |
|
803 // This can happen if the resolution is changed, as this may result in new limits |
|
804 // The zoom level should be cropped to where appropriate |
|
805 // ----------------------------------------------------------------------------- |
|
806 // |
|
807 void CCamZoomModel::CheckZoomLimit() |
|
808 { |
|
809 TInt maxOptZoomStep = MaxZoomStep( iOptZoomSteps ); |
|
810 TInt maxStdZoomStep = MaxZoomStep( iDigZoomSteps ); |
|
811 TInt maxExtZoomStep = MaxZoomStep( iExtZoomSteps ); |
|
812 |
|
813 if ( AllowOptZoom() && // If settings allow optical zoom, |
|
814 iCurZoomStepOptical > maxOptZoomStep ) // ...and value now too high |
|
815 { |
|
816 iCurZoomStepOptical = maxOptZoomStep; |
|
817 // iController.SetZoomMode ( ECamZoomModeOptical ); |
|
818 iController.SetZoomValue( iCurZoomStepOptical ); |
|
819 } |
|
820 |
|
821 if ( AllowDigZoom() // If digital zoom is allowed |
|
822 && iCurZoomStepDigital > maxStdZoomStep // and value now too high |
|
823 && !AllowExtZoom() ) // and extended not allowed |
|
824 { |
|
825 // If we get here, digital zoom IS allowed, but extended isn't |
|
826 // and the digital zoom is too high. |
|
827 iCurZoomStepDigital = maxStdZoomStep; |
|
828 //iController.SetZoomMode ( ECamZoomModeDigital ); |
|
829 iController.SetZoomValue( iCurZoomStepDigital ); |
|
830 } |
|
831 else if ( AllowExtZoom() // If extended digitial zoom is allowed |
|
832 && iCurZoomStepDigital > maxExtZoomStep ) // but over the max extended range |
|
833 { |
|
834 iCurZoomStepDigital = maxExtZoomStep; |
|
835 // iController.SetZoomMode ( ECamZoomModeDigital ); |
|
836 iController.SetZoomValue( iCurZoomStepDigital ); |
|
837 } |
|
838 // otherwise, do nothing |
|
839 else |
|
840 { |
|
841 // empty statement to remove Lint error. |
|
842 } |
|
843 |
|
844 // If we have had to manually set the mode and value of zoom, |
|
845 // make sure that the zoom mode is still set to what internal state |
|
846 // dictates it should be. |
|
847 |
|
848 /* |
|
849 if ( iZoomMode == ECamZoomModeOptical ) |
|
850 { |
|
851 iController.SetZoomMode( ECamZoomModeOptical ); |
|
852 } |
|
853 else if ( iZoomMode == ECamZoomModeDigital || |
|
854 iZoomMode == ECamZoomModeExtended ) |
|
855 { |
|
856 iController.SetZoomMode( ECamZoomModeDigital ); |
|
857 } |
|
858 // otherwise, do nothing |
|
859 else |
|
860 { |
|
861 // empty statement to remove Lint error. |
|
862 */ |
|
863 } |
|
864 |
|
865 // ----------------------------------------------------------------------------- |
|
866 // CCamZoomModel::ResetZoomTo1x |
|
867 // Resets the zoom level to 1x. |
|
868 // ----------------------------------------------------------------------------- |
|
869 // |
|
870 void CCamZoomModel::ResetZoomTo1x() |
|
871 { |
|
872 PRINT( _L( "Camera => CCamZoomModel::ResetZoomTo1x " ) ); |
|
873 // Recalculates the min/max values for the zoom pane and |
|
874 // forwards them to the control. |
|
875 RefreshSettings(); |
|
876 |
|
877 // Reset the actual values used by the engine |
|
878 iCurZoomStepOptical = 0; |
|
879 iCurZoomStepDigital = 0; |
|
880 |
|
881 iZoomMode = ECamZoomModeUndefined; |
|
882 |
|
883 // Only digital mode supported for now. |
|
884 //iController.SetZoomMode( ECamZoomModeDigital ); |
|
885 iController.SetZoomValue( iCurZoomStepDigital ); |
|
886 if ( iPane ) |
|
887 { |
|
888 iPane->SetZoomValue( 0 ); |
|
889 iPane->MakeVisible( EFalse, EFalse ); |
|
890 } |
|
891 |
|
892 PRINT( _L( "Camera <= CCamZoomModel::ResetZoomTo1x " ) ); |
|
893 } |
|
894 |
|
895 |
|
896 // ----------------------------------------------------------------------------- |
|
897 // CCamZoomModel::MaxZoomStep |
|
898 // Returns the maximum zoom step for the supplied step array |
|
899 // (optical/digital/extended), based on current camera state. |
|
900 // ----------------------------------------------------------------------------- |
|
901 // |
|
902 TInt CCamZoomModel::MaxZoomStep( const TCamMaxZoomSteps& aStepArray ) const |
|
903 { |
|
904 PRINT( _L( "Camera => CCamZoomModel::MaxZoomStep " ) ); |
|
905 |
|
906 TInt maxStep = KErrNotSupported; |
|
907 if ( iCameraState & ECamImageOn ) |
|
908 { |
|
909 // TCamPhotoSizeId sizeId = iController.GetCurrentImageResolution(); |
|
910 TCamActiveCamera camera = iController.ActiveCamera(); |
|
911 if ( ECamActiveCameraPrimary == camera ) |
|
912 { |
|
913 // switch ( sizeId ) |
|
914 switch ( iCurrentResolution ) |
|
915 { |
|
916 case ECamPhotoSizeVGA: // 640 x 480 |
|
917 maxStep = aStepArray.iMaxPhotoStepVGA; |
|
918 break; |
|
919 case ECamPhotoSizeXGA: // 0.8MegaPixel (1024 x 768 ) |
|
920 maxStep = aStepArray.iMaxPhotoStep0_8MP; |
|
921 break; |
|
922 case ECamPhotoSize1MP: |
|
923 maxStep = aStepArray.iMaxPhotoStep1MP; |
|
924 break; |
|
925 case ECamPhotoSize1_3MP: // 1280x960 |
|
926 maxStep = aStepArray.iMaxPhotoStep1_3MP; |
|
927 break; |
|
928 case ECamPhotoSize2MP: // 1600x1200 |
|
929 maxStep = aStepArray.iMaxPhotoStep2MP; |
|
930 break; |
|
931 case ECamPhotoSize3MP: // |
|
932 maxStep = aStepArray.iMaxPhotoStep3MP; |
|
933 break; |
|
934 case ECamPhotoSize5MP: |
|
935 maxStep = aStepArray.iMaxPhotoStep5MP; |
|
936 break; |
|
937 case ECamPhotoSize8MP: |
|
938 maxStep = aStepArray.iMaxPhotoStep8MP; |
|
939 break; |
|
940 case ECamPhotoSize12MP: |
|
941 maxStep = aStepArray.iMaxPhotoStep12MP; |
|
942 break; |
|
943 case ECamPhotoSizeW6MP: // 3264x1832 |
|
944 maxStep = aStepArray.iMaxPhotoStepW6MP; |
|
945 break; |
|
946 case ECamPhotoSizeW9MP: // 4000x2248 |
|
947 maxStep = aStepArray.iMaxPhotoStepW9MP; |
|
948 break; |
|
949 default: |
|
950 break; |
|
951 } |
|
952 } |
|
953 else if ( ECamActiveCameraSecondary == camera ) |
|
954 { |
|
955 maxStep = aStepArray.iMax2ndCamPhotoStep; |
|
956 } |
|
957 // otherwise, do nothing |
|
958 else |
|
959 { |
|
960 // empty statement to remove Lint error. |
|
961 } |
|
962 } |
|
963 else if ( iCameraState & ECamVideoOn ) |
|
964 { |
|
965 // TCamVideoResolution resId = iController.GetCurrentVideoResolution(); |
|
966 |
|
967 if ( iController.ActiveCamera() == ECamActiveCameraPrimary ) |
|
968 { |
|
969 // switch ( resId ) |
|
970 switch ( iCurrentResolution ) |
|
971 { |
|
972 case ECamVideoResolutionSubQCIF: // Small (128 x 96) |
|
973 maxStep = aStepArray.iMaxVideoStepSQCIF; |
|
974 break; |
|
975 case ECamVideoResolutionQCIF: // Medium (176 x 144) |
|
976 maxStep = aStepArray.iMaxVideoStepQCIF; |
|
977 break; |
|
978 case ECamVideoResolutionCIF: // Large (352 x 288) (Default) |
|
979 maxStep = aStepArray.iMaxVideoStepCIF; |
|
980 break; |
|
981 case ECamVideoResolutionVGA: // VGA (640 x 480) |
|
982 maxStep = aStepArray.iMaxVideoStepVGA; |
|
983 break; |
|
984 case ECamVideoResolutionQVGA: // QVGA ( 320 x 240 ) |
|
985 maxStep = aStepArray.iMaxVideoStepQVGA; |
|
986 break; |
|
987 case ECamVideoResolutionNHD: // NHD ( 640 x 352 ) |
|
988 maxStep = aStepArray.iMaxVideoStepNHD; |
|
989 break; |
|
990 case ECamVideoResolutionWVGA: // WVGA ( 864 x 480 ) |
|
991 maxStep = aStepArray.iMaxVideoStepWVGA; |
|
992 break; |
|
993 case ECamVideoResolutionHD: // HD ( 1280 x 720 ) |
|
994 maxStep = aStepArray.iMaxVideoStepHD; |
|
995 break; |
|
996 default: |
|
997 break; |
|
998 } |
|
999 } |
|
1000 else if ( iController.ActiveCamera() == ECamActiveCameraSecondary ) |
|
1001 { |
|
1002 switch ( iCurrentResolution ) |
|
1003 { |
|
1004 case ECamVideoResolutionCIF: // Large (352 x 288) (Default) |
|
1005 maxStep = aStepArray.iMax2ndCamVideoStepCIF; |
|
1006 break; |
|
1007 case ECamVideoResolutionQCIF: // Medium (176 x 144) |
|
1008 maxStep = aStepArray.iMax2ndCamVideoStepQCIF; |
|
1009 break; |
|
1010 case ECamVideoResolutionSubQCIF: // Small (128 x 96) |
|
1011 maxStep = aStepArray.iMax2ndCamVideoStepSQCIF; |
|
1012 break; |
|
1013 default: |
|
1014 break; |
|
1015 } |
|
1016 } |
|
1017 // otherwise, do nothing |
|
1018 else |
|
1019 { |
|
1020 // empty statement to remove Lint error. |
|
1021 } |
|
1022 } |
|
1023 // otherwise, do nothing |
|
1024 else |
|
1025 { |
|
1026 // empty statement to remove Lint error. |
|
1027 } |
|
1028 |
|
1029 PRINT1( _L( "Camera <= CCamZoomModel::MaxZoomStep maxStep=%d" ), maxStep ); |
|
1030 return maxStep; |
|
1031 } |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 // ----------------------------------------------------------------------------- |
|
1037 // CCamZoomModel::StopZoom |
|
1038 // Called when the user releases the zoom key to stop an ongoing zoom operation. |
|
1039 // ----------------------------------------------------------------------------- |
|
1040 // |
|
1041 void CCamZoomModel::StopZoom() |
|
1042 { |
|
1043 PRINT( _L( "Camera => CCamZoomModel::StopZoom " ) ); |
|
1044 |
|
1045 if ( iZoomTimer->IsActive() ) |
|
1046 { |
|
1047 iZoomTimer->Cancel(); |
|
1048 } |
|
1049 |
|
1050 // Clear the zoom state |
|
1051 iState = ECamZoomModelStateZoomNone; |
|
1052 |
|
1053 if ( iPauseState == EPauseStatePaused ) |
|
1054 { |
|
1055 iPauseState = EPauseStateReleased; |
|
1056 } |
|
1057 else |
|
1058 { |
|
1059 iPauseState = EPauseStateNone; |
|
1060 } |
|
1061 |
|
1062 PRINT( _L( "Camera <= CCamZoomModel::StopZoom " ) ); |
|
1063 } |
|
1064 |
|
1065 // ----------------------------------------------------------------------------- |
|
1066 // CCamZoomModel::HandleControllerEventL |
|
1067 // Called when a controller event occurs |
|
1068 // ----------------------------------------------------------------------------- |
|
1069 // |
|
1070 void CCamZoomModel::HandleControllerEventL( TCamControllerEvent aEvent, |
|
1071 TInt /*aError*/ ) |
|
1072 { |
|
1073 PRINT( _L( "Camera => CCamZoomModel::HandleControllerEventL " ) ); |
|
1074 switch( aEvent ) |
|
1075 { |
|
1076 // ----------------------------------------- |
|
1077 case ECamEventEngineStateChanged: |
|
1078 { |
|
1079 iCameraState = iController.CameraControllerState(); |
|
1080 |
|
1081 // If a reset is waiting. This happens if the application 'pretends to exit' |
|
1082 // but this occurred when the engine was not prepared e.g. in standby. |
|
1083 // The zoom needs to be set back to default when prepared, and the engine has |
|
1084 // now entered a prepared state |
|
1085 if ( iResetPending |
|
1086 && ( iCameraState & (ECamImageOn|ECamVideoOn) ) ) |
|
1087 { |
|
1088 // The zoom pane will not be redrawn while the iResetPending flag is on. |
|
1089 // This calls RefreshSettings() |
|
1090 ResetZoomTo1x(); |
|
1091 // In this situation the zoom pane should not be shown. |
|
1092 /*if ( iPane->IsVisible() ) |
|
1093 { |
|
1094 iPane->MakeVisible( EFalse, ETrue ); |
|
1095 }*/ |
|
1096 iResetPending = EFalse; |
|
1097 } |
|
1098 else |
|
1099 { |
|
1100 // If state changes (video <-> photo) refresh settings |
|
1101 RefreshSettings(); |
|
1102 } |
|
1103 } |
|
1104 break; |
|
1105 // ----------------------------------------- |
|
1106 case ECamEventCameraChanged: |
|
1107 { |
|
1108 // If state changes (camera change) refresh settings |
|
1109 RefreshSettings(); |
|
1110 |
|
1111 ResetZoomTo1x(); |
|
1112 } |
|
1113 break; |
|
1114 // ----------------------------------------- |
|
1115 // Zoom settings now involve basic digital zoom too. |
|
1116 // Event name changed ECamEventExtZoomStateChanged => ECamEventZoomSetupChanged |
|
1117 case ECamEventImageQualityChanged: |
|
1118 case ECamEventZoomSetupChanged: // Digital/Extended zoom turned on/off/paused/continuous |
|
1119 { |
|
1120 // If image quality has changed, this may update zoom levels. |
|
1121 RefreshSettings(); |
|
1122 } |
|
1123 break; |
|
1124 // ----------------------------------------- |
|
1125 case ECamEventOperationStateChanged: |
|
1126 { |
|
1127 // As the iRecordingVideo state has changed, need to update |
|
1128 // the settings, as this may disable the optical zoom |
|
1129 RefreshSettings(); |
|
1130 } |
|
1131 break; |
|
1132 // ----------------------------------------- |
|
1133 // otherwise, do nothing |
|
1134 default: |
|
1135 break; |
|
1136 } // switch |
|
1137 |
|
1138 PRINT( _L( "Camera <= CCamZoomModel::HandleControllerEventL " ) ); |
|
1139 } |
|
1140 |
|
1141 // --------------------------------------------------------------------------- |
|
1142 // CCamZoomModel::ZoomTimerCallback |
|
1143 // Callback for Zoom Pane timer, used to give smooth zooming |
|
1144 // --------------------------------------------------------------------------- |
|
1145 // |
|
1146 TInt CCamZoomModel::ZoomTimerCallback( TAny* aObject ) |
|
1147 { |
|
1148 CCamZoomModel* model = static_cast< CCamZoomModel* >( aObject ); |
|
1149 model->ZoomTimerTick(); |
|
1150 return KErrNone; |
|
1151 } |
|
1152 |
|
1153 // --------------------------------------------------------------------------- |
|
1154 // CCamZoomModel::ZoomTimerTick |
|
1155 // Called each timer period while the zoom in/out key is held down. |
|
1156 // --------------------------------------------------------------------------- |
|
1157 // |
|
1158 void CCamZoomModel::ZoomTimerTick() |
|
1159 { |
|
1160 PRINT( _L("Camera => CCamZoomModel::ZoomTimerTick") ); |
|
1161 TCamZoomMode modeBefore = iZoomMode; |
|
1162 |
|
1163 // Continue the ongoing zoom operation |
|
1164 if ( iState == ECamZoomModelStateZoomIn ) |
|
1165 { |
|
1166 ZoomIn(); |
|
1167 } |
|
1168 else if ( iState == ECamZoomModelStateZoomOut ) |
|
1169 { |
|
1170 ZoomOut(); |
|
1171 } |
|
1172 else |
|
1173 { |
|
1174 // Do nothing |
|
1175 } |
|
1176 |
|
1177 // Check if we're currently on a boundary, in which case we need |
|
1178 // to stop and re-initialise the timer for the (potentially) new |
|
1179 // interval. |
|
1180 TCamZoomMode modeAfter = iZoomMode; |
|
1181 |
|
1182 if ( modeBefore != modeAfter ) |
|
1183 { |
|
1184 // Restart zoom; |
|
1185 if ( iZoomTimer->IsActive() ) |
|
1186 { |
|
1187 iZoomTimer->Cancel(); |
|
1188 } |
|
1189 StartZoomTimer(); |
|
1190 } |
|
1191 PRINT( _L("Camera <= CCamZoomModel::ZoomTimerTick") ); |
|
1192 } |
|
1193 |
|
1194 |
|
1195 |
|
1196 // --------------------------------------------------------------------------- |
|
1197 // CCamZoomModel::StartZoomTimer |
|
1198 // Called each timer period while the zoom in/out key is held down. |
|
1199 // --------------------------------------------------------------------------- |
|
1200 // |
|
1201 void CCamZoomModel::StartZoomTimer() |
|
1202 { |
|
1203 PRINT( _L( "Camera => CCamZoomModel::StartZoomTimer " ) ); |
|
1204 |
|
1205 if ( iZoomTimer->IsActive() ) |
|
1206 { |
|
1207 return; // If only one speed, we're already running so just return. |
|
1208 } |
|
1209 |
|
1210 TCamZoomMode mode = CurrentZoomType(); |
|
1211 |
|
1212 TInt stepPeriod = 0; |
|
1213 |
|
1214 switch ( mode ) |
|
1215 { |
|
1216 case ECamZoomModeOptical: |
|
1217 { |
|
1218 stepPeriod = iZoomLAF.iZoomSpeedOpt * 1000; |
|
1219 break; |
|
1220 } |
|
1221 |
|
1222 case ECamZoomModeDigital: |
|
1223 { |
|
1224 stepPeriod = iZoomLAF.iZoomSpeedDig * 1000; |
|
1225 break; |
|
1226 } |
|
1227 |
|
1228 case ECamZoomModeExtended: |
|
1229 { |
|
1230 stepPeriod = iZoomLAF.iZoomSpeedExt * 1000; |
|
1231 break; |
|
1232 } |
|
1233 |
|
1234 case ECamZoomModeUndefined: |
|
1235 default: |
|
1236 { |
|
1237 stepPeriod = 1000000; |
|
1238 break; |
|
1239 } |
|
1240 } |
|
1241 |
|
1242 |
|
1243 iZoomTimer->Start( stepPeriod, stepPeriod, TCallBack( ZoomTimerCallback , this) ); |
|
1244 iZoomMode = mode; |
|
1245 |
|
1246 PRINT( _L( "Camera <= CCamZoomModel::StartZoomTimer " ) ); |
|
1247 } |
|
1248 |
|
1249 // --------------------------------------------------------------------------- |
|
1250 // CCamZoomModel::AllowExtZoom |
|
1251 // Returns whether extended zoom is allowed or not, based on current settings |
|
1252 // --------------------------------------------------------------------------- |
|
1253 // |
|
1254 TBool CCamZoomModel::AllowExtZoom() const |
|
1255 { |
|
1256 PRINT( _L( "Camera => CCamZoomModel::AllowExtZoom " ) ); |
|
1257 |
|
1258 TInt extendedStep = MaxZoomStep( iExtZoomSteps ); |
|
1259 |
|
1260 // Check there is a valid extended zoom step to allow to first, and that |
|
1261 // we are not in embedded mode (extended zoom not allowed in embedded) |
|
1262 if ( KErrNotSupported != extendedStep ) |
|
1263 { |
|
1264 if ( iZoomSetting == ECamSettDigZoomExtendPause |
|
1265 || iZoomSetting == ECamSettDigZoomExtendCont ) |
|
1266 { |
|
1267 // If setting allows extended zoom, return true |
|
1268 PRINT( _L( "Camera <= CCamZoomModel::AllowExtZoom ETrue" ) ); |
|
1269 return ETrue; |
|
1270 } |
|
1271 else |
|
1272 { |
|
1273 // else user setting disallows it, so return false |
|
1274 PRINT( _L( "Camera <= CCamZoomModel::AllowExtZoom EFalse" ) ); |
|
1275 return EFalse; |
|
1276 } |
|
1277 } |
|
1278 else |
|
1279 { |
|
1280 // No valid extended zoom, so not allowed even if user said so. |
|
1281 PRINT( _L( "Camera <= CCamZoomModel::AllowExtZoom EFalse" ) ); |
|
1282 return EFalse; |
|
1283 } |
|
1284 } |
|
1285 |
|
1286 // --------------------------------------------------------------------------- |
|
1287 // CCamZoomModel::AllowOptZoom |
|
1288 // Returns whether optical zoom is allowed |
|
1289 // --------------------------------------------------------------------------- |
|
1290 // |
|
1291 TBool CCamZoomModel::AllowOptZoom() const |
|
1292 { |
|
1293 PRINT( _L( "Camera => CCamZoomModel::AllowOptZoom " ) ); |
|
1294 TInt maxOptZoomStep = MaxZoomStep( iOptZoomSteps ); |
|
1295 if ( KErrNotSupported == maxOptZoomStep // Zoom is NOT supported or |
|
1296 || ( !iAllowOptZoom // Settings dont allow zoom during recording |
|
1297 && iRecordingVideo ) ) // ...and we're recording now |
|
1298 { |
|
1299 PRINT( _L( "Camera <= CCamZoomModel::AllowOptZoom EFalse" ) ); |
|
1300 return EFalse; |
|
1301 } |
|
1302 else |
|
1303 { |
|
1304 PRINT( _L( "Camera <= CCamZoomModel::AllowOptZoom ETrue" ) ); |
|
1305 return ETrue; |
|
1306 } |
|
1307 } |
|
1308 |
|
1309 // --------------------------------------------------------------------------- |
|
1310 // CCamZoomModel::AllowDigZoom |
|
1311 // Returns whether digital zoom is allowed |
|
1312 // --------------------------------------------------------------------------- |
|
1313 // |
|
1314 TBool CCamZoomModel::AllowDigZoom() const |
|
1315 { |
|
1316 PRINT( _L( "Camera => CCamZoomModel::AllowDigZoom " ) ); |
|
1317 TInt maxStdZoomStep = MaxZoomStep( iDigZoomSteps ); |
|
1318 |
|
1319 if ( KErrNotSupported != maxStdZoomStep // Zoom is supported in current state |
|
1320 && ECamSettDigZoomNone != iZoomSetting ) // ...and is allowed by user setting |
|
1321 { |
|
1322 PRINT( _L( "Camera <= CCamZoomModel::AllowDigZoom ETrue" ) ); |
|
1323 return ETrue; |
|
1324 } |
|
1325 else |
|
1326 { |
|
1327 PRINT( _L( "Camera <= CCamZoomModel::AllowDigZoom ETrue" ) ); |
|
1328 return EFalse; |
|
1329 } |
|
1330 } |
|
1331 |
|
1332 |
|
1333 // --------------------------------------------------------------------------- |
|
1334 // CCamZoomModel::CurrentZoom |
|
1335 // Returns the current zoom level, taking into account optical (if allowed) |
|
1336 // *and* digital zooms. |
|
1337 // --------------------------------------------------------------------------- |
|
1338 // |
|
1339 TInt CCamZoomModel::CurrentZoom() const |
|
1340 { |
|
1341 PRINT( _L( "Camera => CCamZoomModel::CurrentZoom" ) ); |
|
1342 // If we are recording video, and optical isn't allowed while recording |
|
1343 // then we only need to represent the Digital zoom in the zoom pane. |
|
1344 if ( iRecordingVideo && !iAllowOptZoom ) |
|
1345 { |
|
1346 // Only use digital value if optical not allowed |
|
1347 PRINT( _L( "Camera <= CCamZoomModel::CurrentZoom digital" ) ); |
|
1348 return iCurZoomStepDigital; |
|
1349 } |
|
1350 else |
|
1351 { |
|
1352 // Return the combined zoom value |
|
1353 PRINT( _L( "Camera <= CCamZoomModel::CurrentZoom optical+digital" ) ); |
|
1354 return (iCurZoomStepOptical + iCurZoomStepDigital); |
|
1355 } |
|
1356 } |
|
1357 |
|
1358 |
|
1359 // --------------------------------------------------------------------------- |
|
1360 // CCamZoomModel::PauseAtBoundary |
|
1361 // Returns whether to pause at the specified boundary |
|
1362 // --------------------------------------------------------------------------- |
|
1363 // |
|
1364 TBool CCamZoomModel::PauseAtBoundary( TCamZoomBoundary aBoundary ) const |
|
1365 { |
|
1366 PRINT( _L( "Camera => CCamZoomModel::PauseAtBoundary" ) ); |
|
1367 if ( iCameraState & ECamVideoOn ) |
|
1368 { |
|
1369 // Always return false for video, as we do not want to |
|
1370 // force the zoom operation to pause at any boundary |
|
1371 // in video mode. |
|
1372 PRINT( _L( "Camera <= CCamZoomModel::PauseAtBoundary EFalse" ) ); |
|
1373 return EFalse; |
|
1374 } |
|
1375 else |
|
1376 { |
|
1377 if ( ECamZoomBoundaryOptDig == aBoundary ) |
|
1378 { |
|
1379 // Reason to *not* pause at the optical/digital boundary is if |
|
1380 // user set the "On (continuous)" or "Extended on (continuous) setting |
|
1381 if ( ECamSettDigZoomNormalCont == iZoomSetting |
|
1382 || ECamSettDigZoomExtendCont == iZoomSetting ) |
|
1383 { |
|
1384 PRINT( _L( "Camera <= CCamZoomModel::PauseAtBoundary EFalse" ) ); |
|
1385 return EFalse; |
|
1386 } |
|
1387 else |
|
1388 { |
|
1389 PRINT( _L( "Camera <= CCamZoomModel::PauseAtBoundary ETrue" ) ); |
|
1390 return ETrue; |
|
1391 } |
|
1392 } |
|
1393 else if ( ECamZoomBoundaryDigExt == aBoundary ) |
|
1394 { |
|
1395 // Only reason *not* to pause in digital/extended boundary is if |
|
1396 // user zoom setting states "extended on without pauses". |
|
1397 if ( ECamSettDigZoomExtendCont == iZoomSetting ) |
|
1398 { |
|
1399 PRINT( _L( "Camera <= CCamZoomModel::PauseAtBoundary EFalse" ) ); |
|
1400 return EFalse; |
|
1401 } |
|
1402 else |
|
1403 { |
|
1404 PRINT( _L( "Camera <= CCamZoomModel::PauseAtBoundary ETrue" ) ); |
|
1405 return ETrue; |
|
1406 } |
|
1407 } |
|
1408 else // No other boundaries known, return "no pause". |
|
1409 { |
|
1410 PRINT( _L( "Camera <= CCamZoomModel::PauseAtBoundary EFalse" ) ); |
|
1411 return EFalse; |
|
1412 } |
|
1413 } |
|
1414 } |
|
1415 |
|
1416 |
|
1417 // ----------------------------------------------------------------------------- |
|
1418 // CCamZoomPane::IsCurrentlyZooming |
|
1419 // Returns ETrue if the zoom model is currently zooming in/out, |
|
1420 // else returns EFalse |
|
1421 // ----------------------------------------------------------------------------- |
|
1422 // |
|
1423 TBool CCamZoomModel::IsCurrentlyZooming() const |
|
1424 { |
|
1425 PRINT( _L( "Camera => CCamZoomModel::IsCurrentlyZooming" ) ); |
|
1426 if ( ECamZoomModelStateZoomIn == iState |
|
1427 || ECamZoomModelStateZoomOut == iState ) |
|
1428 { |
|
1429 PRINT( _L( "Camera <= CCamZoomModel::IsCurrentlyZooming ETrue" ) ); |
|
1430 return ETrue; |
|
1431 } |
|
1432 else |
|
1433 { |
|
1434 PRINT( _L( "Camera <= CCamZoomModel::IsCurrentlyZooming EFalse" ) ); |
|
1435 return EFalse; |
|
1436 } |
|
1437 } |
|
1438 |
|
1439 // ----------------------------------------------------------------------------- |
|
1440 // CCamZoomModel::ZoomingState |
|
1441 // ----------------------------------------------------------------------------- |
|
1442 // |
|
1443 CCamZoomModel::TCamZoomModelState CCamZoomModel::ZoomingState() |
|
1444 { |
|
1445 return iState; |
|
1446 } |
|
1447 |
|
1448 |
|
1449 // ----------------------------------------------------------------------------- |
|
1450 // CCamZoomPane::ResetToDefaultAfterPrepare |
|
1451 // Sets the zoompane to reset the zoom level to default values |
|
1452 // next time the engine is prepared |
|
1453 // ----------------------------------------------------------------------------- |
|
1454 // |
|
1455 void CCamZoomModel::ResetToDefaultAfterPrepare( TBool aReset ) |
|
1456 { |
|
1457 iResetPending = aReset; |
|
1458 } |
|
1459 |
|
1460 // ----------------------------------------------------------------------------- |
|
1461 // CCamZoomPane::IsResetPending |
|
1462 // Whether or not the zoom level is waiting to be reset to default |
|
1463 // ----------------------------------------------------------------------------- |
|
1464 // |
|
1465 TBool CCamZoomModel::IsResetPending() const |
|
1466 { |
|
1467 return iResetPending; |
|
1468 } |
|
1469 |
|
1470 // ----------------------------------------------------------------------------- |
|
1471 // ReadCurrentResolution |
|
1472 // ----------------------------------------------------------------------------- |
|
1473 // |
|
1474 void |
|
1475 CCamZoomModel::ReadCurrentResolution() |
|
1476 { |
|
1477 PRINT1( _L("Camera => CCamZoomModel::ReadCurrentResolution, now:%d"), iCurrentResolution ); |
|
1478 if ( iCameraState & ECamImageOn ) |
|
1479 { |
|
1480 iCurrentResolution = iController.GetCurrentImageResolution(); |
|
1481 } |
|
1482 else if( iCameraState & ECamVideoOn ) |
|
1483 { |
|
1484 iCurrentResolution = iController.GetCurrentVideoResolution(); |
|
1485 } |
|
1486 else |
|
1487 { |
|
1488 iCurrentResolution = KErrNotReady; |
|
1489 } |
|
1490 PRINT1( _L("Camera <= CCamZoomModel::ReadCurrentResolution, got:%d"), iCurrentResolution ); |
|
1491 } |
|
1492 |
|
1493 // End of File |