54
|
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 |
|
|
19 |
#ifndef CAMZOOMMODEL_H
|
|
20 |
#define CAMZOOMMODEL_H
|
|
21 |
|
|
22 |
// INCLUDES
|
|
23 |
#include <e32base.h>
|
|
24 |
#include "CamPSI.h"
|
|
25 |
#include "CamAppController.h"
|
|
26 |
#include "CamControllerObservers.h" // MCamControllerObserver
|
|
27 |
#include "CamZoomUpdateManager.h"
|
|
28 |
|
|
29 |
// CONSTANTS
|
|
30 |
|
|
31 |
// MACROS
|
|
32 |
|
|
33 |
// DATA TYPES
|
|
34 |
|
|
35 |
// FUNCTION PROTOTYPES
|
|
36 |
|
|
37 |
// FORWARD DECLARATIONS
|
|
38 |
class CCamZoomPane;
|
|
39 |
|
|
40 |
// CLASS DECLARATION
|
|
41 |
|
|
42 |
/**
|
|
43 |
* This class contains the logic for handling zoom operations
|
|
44 |
* with support for Optical, Digital and Extended Digital zoom
|
|
45 |
*
|
|
46 |
* @since 3.0
|
|
47 |
*/
|
|
48 |
class CCamZoomModel : public CBase,
|
|
49 |
public MCamControllerObserver
|
|
50 |
{
|
|
51 |
// =========================================================================
|
|
52 |
// Types
|
|
53 |
public:
|
|
54 |
|
|
55 |
enum TCamZoomModelState
|
|
56 |
{
|
|
57 |
ECamZoomModelStateZoomNone,
|
|
58 |
ECamZoomModelStateZoomIn,
|
|
59 |
ECamZoomModelStateZoomOut,
|
|
60 |
ECamZoomModelStateZoomTo
|
|
61 |
};
|
|
62 |
|
|
63 |
/* Moved to CamSettingsInternal.hrh
|
|
64 |
// Used to represent the current zoom mode used with the Engine
|
|
65 |
enum TCamZoomMode
|
|
66 |
{
|
|
67 |
ECamZoomModeUndefined,
|
|
68 |
ECamZoomModeOptical,
|
|
69 |
ECamZoomModeDigital,
|
|
70 |
ECamZoomModeExtended
|
|
71 |
}; */
|
|
72 |
|
|
73 |
// Used to describe the current zoom mode boundary.
|
|
74 |
enum TCamZoomBoundary
|
|
75 |
{
|
|
76 |
ECamZoomBoundaryUndefined, // Not checked yet for current zoom step
|
|
77 |
ECamZoomBoundaryNone, // Checked, but not at a boundary
|
|
78 |
ECamZoomBoundaryOptDig, // Checked, and at Optical/Digital boundary
|
|
79 |
ECamZoomBoundaryDigExt // Checked, and at Digital/Extended boundary
|
|
80 |
};
|
|
81 |
|
|
82 |
// PauseState represents handling of pausing zooming in at
|
|
83 |
// zoom mode boundarys (between optical/digital and digital/extended)
|
|
84 |
enum TPauseState
|
|
85 |
{
|
|
86 |
EPauseStateNone, // Not at a boundary
|
|
87 |
EPauseStatePaused, // Just hit a boundary, all zoom-in events ignored until released
|
|
88 |
EPauseStateReleased // Just released zoom key, allow next zoom
|
|
89 |
};
|
|
90 |
|
|
91 |
// =========================================================================
|
|
92 |
// Methods
|
|
93 |
|
|
94 |
// -------------------------------------------------------------------------
|
|
95 |
// Constructors and destructor
|
|
96 |
public:
|
|
97 |
|
|
98 |
/**
|
|
99 |
* Two-phased constructor.
|
|
100 |
*/
|
|
101 |
static CCamZoomModel* NewL( CCamAppController& aController, CCamZoomPane* aZoomPane );
|
|
102 |
|
|
103 |
/**
|
|
104 |
* Destructor.
|
|
105 |
*/
|
|
106 |
virtual ~CCamZoomModel();
|
|
107 |
|
|
108 |
// -------------------------------------------------------------------------
|
|
109 |
// From CCamAppControllerBase
|
|
110 |
public:
|
|
111 |
|
|
112 |
/**
|
|
113 |
* Handle controller event.
|
|
114 |
* @since 3.0
|
|
115 |
* @param aEvent the controller event that has occurred
|
|
116 |
* @param aError any reported error
|
|
117 |
*/
|
|
118 |
virtual void HandleControllerEventL( TCamControllerEvent aEvent,
|
|
119 |
TInt aError );
|
|
120 |
|
|
121 |
|
|
122 |
|
|
123 |
|
|
124 |
// -------------------------------------------------------------------------
|
|
125 |
// New functions
|
|
126 |
public:
|
|
127 |
|
|
128 |
/**
|
|
129 |
* Attempts to zoom in one step, if possible.
|
|
130 |
* Zooming will continue until StopZoom() is called.
|
|
131 |
* @since 3.0
|
|
132 |
*/
|
|
133 |
void ZoomIn( TBool aOneClick = EFalse );
|
|
134 |
|
|
135 |
/**
|
|
136 |
* Attempts to zoom out one step, if possible.
|
|
137 |
* Zooming will continue until StopZoom() is called.
|
|
138 |
* @since 3.0
|
|
139 |
*/
|
|
140 |
void ZoomOut( TBool aOneClick = EFalse );
|
|
141 |
|
|
142 |
/**
|
|
143 |
* Attempts to zoom to a specific point, if possible.
|
|
144 |
*
|
|
145 |
* @since 5.0
|
|
146 |
*/
|
|
147 |
void ZoomTo( TInt aValue );
|
|
148 |
|
|
149 |
/**
|
|
150 |
* Stops an ongoing zoom in/out operation
|
|
151 |
* @since 3.0
|
|
152 |
*/
|
|
153 |
void StopZoom();
|
|
154 |
|
|
155 |
/**
|
|
156 |
* Checks the current state of the Camera application, and adjusts the
|
|
157 |
* min/max range of the zoom pane accordingly.
|
|
158 |
* @since 3.0
|
|
159 |
*/
|
|
160 |
void RefreshSettings();
|
|
161 |
|
|
162 |
/**
|
|
163 |
* Timer callback, used during a zoom in/out to trigger repeat
|
|
164 |
* zoom steps while the key is held down.
|
|
165 |
* @param aObject Pointer to a CCamZoomModel object
|
|
166 |
* @return TInt KErrNone if ok
|
|
167 |
* @since 3.0
|
|
168 |
*/
|
|
169 |
static TInt ZoomTimerCallback( TAny* aObject );
|
|
170 |
|
|
171 |
/**
|
|
172 |
* Returns whether the zoom model is currently zooming in or out
|
|
173 |
* @since 3.0
|
|
174 |
* @return ETrue if zooming, else EFalse
|
|
175 |
*/
|
|
176 |
TBool IsCurrentlyZooming() const;
|
|
177 |
|
|
178 |
/**
|
|
179 |
* Returns zoom model state
|
|
180 |
* @since S60 v5.0
|
|
181 |
* @return TCamZoomModelState
|
|
182 |
*/
|
|
183 |
TCamZoomModelState ZoomingState();
|
|
184 |
|
|
185 |
/**
|
|
186 |
* Indicates that the zoom level should be reset to default
|
|
187 |
* when the engine is next prepared
|
|
188 |
* @since 2.8
|
|
189 |
* @param aReset ETrue if the zoom pane should be reset, else EFalse
|
|
190 |
*/
|
|
191 |
void ResetToDefaultAfterPrepare( TBool aReset );
|
|
192 |
|
|
193 |
/**
|
|
194 |
* Indicates whether or not the zoom level is waiting to be reset to default
|
|
195 |
* @since 3.0
|
|
196 |
* @return TBool ETrue if a reset is pending, othewise EFalse
|
|
197 |
*/
|
|
198 |
TBool IsResetPending() const;
|
|
199 |
|
|
200 |
/***
|
|
201 |
* Resets the zoom (digital, and, if available, optical) to 1x
|
|
202 |
* @since 3.0
|
|
203 |
*/
|
|
204 |
void ResetZoomTo1x();
|
|
205 |
|
|
206 |
/***
|
|
207 |
* Use an external zoom multiplier factor to zoom quickly
|
|
208 |
* with lesser number of transitions
|
|
209 |
* @since 5.1
|
|
210 |
*/
|
|
211 |
void SetZoomMultiplier( TInt aZoomStepMultiplier );
|
|
212 |
|
|
213 |
private:
|
|
214 |
|
|
215 |
/**
|
|
216 |
* Called by the timer callback function to perform
|
|
217 |
* the operation of one timer "tick". Will zoom in or out
|
|
218 |
* one step to continue the ongoing zoom operation.
|
|
219 |
* @since 3.0
|
|
220 |
*/
|
|
221 |
void ZoomTimerTick();
|
|
222 |
|
|
223 |
/**
|
|
224 |
* Starts the zoom timer if not already running.
|
|
225 |
* @since 3.0
|
|
226 |
*/
|
|
227 |
void StartZoomTimer();
|
|
228 |
|
|
229 |
/**
|
|
230 |
* Returns the maximum zoom step from the supplied step array.
|
|
231 |
* The returned step takes into account the currently active
|
|
232 |
* camera and capture mode.
|
|
233 |
* @param aStepArray The step array from the PSI
|
|
234 |
* @since 3.0
|
|
235 |
* @return The maximum step from the array.
|
|
236 |
*/
|
|
237 |
TInt MaxZoomStep( const TCamMaxZoomSteps& aStepArray ) const;
|
|
238 |
|
|
239 |
/***
|
|
240 |
* Checks the zoom mode is that expected. If not, will be set.
|
|
241 |
* @param aMode The zoom mode to check for
|
|
242 |
* @since 3.0
|
|
243 |
*/
|
|
244 |
void CheckZoomMode( TCamZoomMode aMode );
|
|
245 |
|
|
246 |
/***
|
|
247 |
* Reads the digital zoom setting and updates internal state
|
|
248 |
* @since 3.0
|
|
249 |
*/
|
|
250 |
void ReadDigitalZoomSetting();
|
|
251 |
|
|
252 |
/***
|
|
253 |
* Reads the optical zoom setting and updates internal state
|
|
254 |
* @since 3.0
|
|
255 |
*/
|
|
256 |
void ReadOpticalZoomSetting();
|
|
257 |
|
|
258 |
/***
|
|
259 |
* Checks that the current zoom levels for optical/digital zoom
|
|
260 |
* do not exceed current limits. If they do, the level is set
|
|
261 |
* to the available limit.
|
|
262 |
* @since 3.0
|
|
263 |
*/
|
|
264 |
void CheckZoomLimit();
|
|
265 |
|
|
266 |
/***
|
|
267 |
* Returns whether EXTENDED zoom is allowed based on
|
|
268 |
* settings for the current resolution, and user options.
|
|
269 |
* @since 3.0
|
|
270 |
* @returns ETrue if allowed, else EFalse
|
|
271 |
*/
|
|
272 |
TBool AllowExtZoom() const;
|
|
273 |
|
|
274 |
/***
|
|
275 |
* Returns whether OPTICAL zoom is allowed based on
|
|
276 |
* settings for the current resolution, and user options.
|
|
277 |
* @since 3.0
|
|
278 |
* @returns ETrue if allowed, else EFalse
|
|
279 |
*/
|
|
280 |
TBool AllowOptZoom() const;
|
|
281 |
|
|
282 |
/***
|
|
283 |
* Returns whether DIGITAL zoom is allowed based on
|
|
284 |
* settings for the current resolution, and user options.
|
|
285 |
* @since 3.0
|
|
286 |
* @returns ETrue if allowed, else EFalse
|
|
287 |
*/
|
|
288 |
TBool AllowDigZoom() const;
|
|
289 |
|
|
290 |
/***
|
|
291 |
* Returns whether zooming should be paused at the
|
|
292 |
* specified zoom boundary.
|
|
293 |
* @since 3.0
|
|
294 |
* @param aBoundary
|
|
295 |
* @returns ETrue if pause required, else EFalse
|
|
296 |
*/
|
|
297 |
TBool PauseAtBoundary( TCamZoomBoundary aBoundary ) const;
|
|
298 |
|
|
299 |
/***
|
|
300 |
* Checks whether doing the next zoom operation will move
|
|
301 |
* from one type of zoom to another.
|
|
302 |
*
|
|
303 |
* Will return any of:
|
|
304 |
* - ECamZoomBoundaryNone (not on a boundary)
|
|
305 |
* - ECamZoomBoundaryOptDig (on optical/digital boundary)
|
|
306 |
* - ECamZoomBoundaryDigExt (on digital/extended boundary)
|
|
307 |
*
|
|
308 |
* @since 3.0
|
|
309 |
* @returns The current zoom boundary state
|
|
310 |
*/
|
|
311 |
TCamZoomBoundary CheckBoundary() const;
|
|
312 |
|
|
313 |
/***
|
|
314 |
* Returns the current zoom type (Optical/Digital/Extended), based
|
|
315 |
* on the current zoom level. Optionally takes a parameter, to
|
|
316 |
* see what zoom type would be used if zoom level adjusted by
|
|
317 |
* the stepmodifier (positive or negative)
|
|
318 |
* @since 3.0
|
|
319 |
* @param aStepModifier Value to add to current zoom
|
|
320 |
* @returns The zoom mode of current zoom value + step modifier
|
|
321 |
*/
|
|
322 |
TCamZoomMode CurrentZoomType( TInt aStepModifier = 0 ) const;
|
|
323 |
|
|
324 |
/***
|
|
325 |
* Returns the number of zoom steps that the next zoom will jump.
|
|
326 |
* @since 3.0
|
|
327 |
* @returns The number of zoom steps to jump.
|
|
328 |
*/
|
|
329 |
TInt ZoomStepsToJump() const;
|
|
330 |
|
|
331 |
/***
|
|
332 |
* Returns (via references) how the zoom steps should be split up
|
|
333 |
* between the optical, digital and extended zoom modes.
|
|
334 |
* @since 3.0
|
|
335 |
* @param aOpt The optical steps to move.
|
|
336 |
* @param aDig The digital steps to move.
|
|
337 |
* @param aExt The extended steps to move.
|
|
338 |
*/
|
|
339 |
void ZoomStepsToJump( TInt& aOpt, TInt& aDig, TInt& aExt ) const;
|
|
340 |
|
|
341 |
/**
|
|
342 |
* Returns the current combined (optical + digital) zoom
|
|
343 |
* for the current zoom model state.
|
|
344 |
* @since 3.0
|
|
345 |
* @returns The current combined zoom
|
|
346 |
*/
|
|
347 |
TInt CurrentZoom() const;
|
|
348 |
|
|
349 |
/**
|
|
350 |
* Read the current resolution id.
|
|
351 |
*
|
|
352 |
*/
|
|
353 |
void ReadCurrentResolution();
|
|
354 |
|
|
355 |
// -------------------------------------------------------------------------
|
|
356 |
// Private constructors
|
|
357 |
private:
|
|
358 |
|
|
359 |
/**
|
|
360 |
* C++ default constructor.
|
|
361 |
*/
|
|
362 |
CCamZoomModel( CCamAppController& aController, CCamZoomPane* aPane );
|
|
363 |
|
|
364 |
/**
|
|
365 |
* By default Symbian 2nd phase constructor is private.
|
|
366 |
*/
|
|
367 |
void ConstructL();
|
|
368 |
|
|
369 |
// =========================================================================
|
|
370 |
// Data
|
|
371 |
private:
|
|
372 |
|
|
373 |
// Arrays from the PSI, describing maximum zoom steps for
|
|
374 |
// different zoom modes and different resolutions and media
|
|
375 |
TCamMaxZoomSteps iOptZoomSteps; // Optical zoom steps
|
|
376 |
TCamMaxZoomSteps iDigZoomSteps; // Standard digital zoom steps
|
|
377 |
TCamMaxZoomSteps iExtZoomSteps; // Extended digital zoom steps
|
|
378 |
|
|
379 |
// These values are the maximum zoom steps for different zoom modes.
|
|
380 |
// Will be updated when RefreshSettings() is called.
|
|
381 |
TInt iMaxZoomStepOpt; // Max Optical step
|
|
382 |
TInt iMaxZoomStepDig; // Max Digital step
|
|
383 |
TInt iMaxZoomStepExt; // Max Extended step
|
|
384 |
|
|
385 |
// Zoom setting: Allow digital and/or extended, where to pause.
|
|
386 |
TCamSettingsDigitalZoom iZoomSetting;
|
|
387 |
|
|
388 |
// Whether to allow Optical zoom during video
|
|
389 |
TBool iAllowOptZoom;
|
|
390 |
|
|
391 |
// The current optical and digital zoom steps
|
|
392 |
TInt iCurZoomStepOptical;
|
|
393 |
TInt iCurZoomStepDigital;
|
|
394 |
|
|
395 |
// Max allowed zoom step (taking into account optical, digital and extended)
|
|
396 |
TInt iMaxZoomStep;
|
|
397 |
|
|
398 |
// Zoom step/jump multiplier for skipping some zoom levels
|
|
399 |
// (for quick zooming to max and min zoom levels)
|
|
400 |
TInt iZoomStepMultiplier;
|
|
401 |
|
|
402 |
// Stores the current state of the model, and the last-notified
|
|
403 |
// engine state.
|
|
404 |
TCamZoomModelState iState;
|
|
405 |
// TCamEngineState iEngineState;
|
|
406 |
TUint iCameraState;
|
|
407 |
|
|
408 |
// Stores the latest video or image resolution id.
|
|
409 |
TInt iCurrentResolution;
|
|
410 |
|
|
411 |
// Reference to the controller used for setting the zoom step and mode.
|
|
412 |
CCamAppController& iController;
|
|
413 |
|
|
414 |
// Update manager is used to minimize amount of updates sent to driver.
|
|
415 |
CCamZoomUpdateManager* iCamZoomUpdateManager;
|
|
416 |
|
|
417 |
// Timer for zooming smoothly
|
|
418 |
CPeriodic* iZoomTimer;
|
|
419 |
CCamZoomPane* iPane;
|
|
420 |
|
|
421 |
// Keeps track of the current zoom mode
|
|
422 |
TCamZoomMode iZoomMode;
|
|
423 |
|
|
424 |
// Stores a look-and-feel structure for the zoom bar.
|
|
425 |
TCamZoomLAF iZoomLAF;
|
|
426 |
|
|
427 |
// The current pause state (none/paused/released)
|
|
428 |
TPauseState iPauseState;
|
|
429 |
|
|
430 |
// Whether the camera app is currently recording video
|
|
431 |
// Used to identify when we *stop* recording
|
|
432 |
TBool iRecordingVideo;
|
|
433 |
|
|
434 |
// Whether or not the zoompane should reset to default value on next prepare
|
|
435 |
TBool iResetPending;
|
|
436 |
|
|
437 |
// =========================================================================
|
|
438 |
};
|
|
439 |
|
|
440 |
#endif // CAMZOOMMODEL_H
|
|
441 |
|
|
442 |
// End of File
|