54
|
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: Camera Zoom Pane; shows the zoom level graphically*
|
|
15 |
*/
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
// INCLUDE FILES
|
|
20 |
#include <e32base.h>
|
|
21 |
#include <e32std.h>
|
|
22 |
#include <coemain.h>
|
|
23 |
#include <eikenv.h>
|
|
24 |
#include <cameraapp.mbg>
|
|
25 |
#include <eikappui.h> // For CCoeAppUiBase
|
|
26 |
#include <eikapp.h> // For CEikApplication
|
|
27 |
#include <barsread.h> // resource reader
|
|
28 |
#include <AknIconUtils.h>
|
|
29 |
#include <centralrepository.h>
|
|
30 |
#include <layoutmetadata.cdl.h>
|
|
31 |
#include <aknlayoutscalable_apps.cdl.h>
|
|
32 |
#include <touchfeedback.h>
|
|
33 |
#include <cameraapp.rsg>
|
|
34 |
#include <vgacamsettings.rsg>
|
|
35 |
#include "CameraUiConfigManager.h"
|
|
36 |
#include "CamPanic.h" // Panic codes
|
|
37 |
#include "CamUtility.h"
|
|
38 |
#include "CamZoomPane.h"
|
|
39 |
#include "CamZoomModel.h"
|
|
40 |
#include "CamAppUi.h"
|
|
41 |
#include "CamBmpRotatorAo.h"
|
|
42 |
#include "CameraappPrivateCRKeys.h"
|
|
43 |
#include "CamTimer.h"
|
|
44 |
|
|
45 |
|
|
46 |
// CONSTANTS
|
|
47 |
const TInt KDivisorFactor = 10000; // integer scaling factor to avoid the
|
|
48 |
// use of floating point arithmetic
|
|
49 |
const TInt KTouchAreaExpansion = 35; // Pixels to grow touchable area
|
|
50 |
const TInt KFastZoomMultiplier = 4; // Multiplier to skip some zoom levels
|
|
51 |
// to make zooming faster. Used with double tap.
|
|
52 |
|
|
53 |
// ============================ MEMBER FUNCTIONS ===============================
|
|
54 |
|
|
55 |
// -----------------------------------------------------------------------------
|
|
56 |
// CCamZoomPane::CCamZoomPane
|
|
57 |
// C++ default constructor can NOT contain any code, that
|
|
58 |
// might leave.
|
|
59 |
// -----------------------------------------------------------------------------
|
|
60 |
//
|
|
61 |
CCamZoomPane::CCamZoomPane( CCamAppController& aController, TBool aOverlayViewFinder )
|
|
62 |
: iController( aController ),
|
|
63 |
iOverlayViewFinder( aOverlayViewFinder )
|
|
64 |
{
|
|
65 |
}
|
|
66 |
|
|
67 |
// -----------------------------------------------------------------------------
|
|
68 |
// CCamZoomPane::ConstructL
|
|
69 |
// Symbian 2nd phase constructor can leave.
|
|
70 |
// -----------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
void CCamZoomPane::ConstructL()
|
|
73 |
{
|
|
74 |
PRINT( _L( "Camera => CCamZoomPane::ConstructL " ) );
|
|
75 |
// Load the zoom pane orientation value from the Central Repository
|
|
76 |
CRepository* repository = CRepository::NewL( KCRUidCameraappSettings );
|
|
77 |
TInt val = 0;
|
|
78 |
TInt err = repository->Get( KCamCrZoomPaneOrientation, val );
|
|
79 |
|
|
80 |
// If there is an error then assume standard (vertical) orientation
|
|
81 |
if ( err != KErrNone )
|
|
82 |
{
|
|
83 |
iOrientation = EZPOrientationVertical;
|
|
84 |
}
|
|
85 |
else
|
|
86 |
{
|
|
87 |
iOrientation = static_cast<TZPOrientation>( val );
|
|
88 |
}
|
|
89 |
#if !( defined(__WINS__) || defined(__WINSCW__) )
|
|
90 |
// Get Central Repository key indicating if product uses volume keys for zoom
|
|
91 |
err = repository->Get( KCamCrZoomUsingVolumeKeys, val );
|
|
92 |
|
|
93 |
// If there is an error then assume volume keys not used
|
|
94 |
if ( err != KErrNone )
|
|
95 |
{
|
|
96 |
iZoomUsingVolumeKeys = EFalse;
|
|
97 |
}
|
|
98 |
else
|
|
99 |
{
|
|
100 |
iZoomUsingVolumeKeys = val;
|
|
101 |
}
|
|
102 |
|
|
103 |
iZoomUsingVolumeKeys = EFalse;
|
|
104 |
|
|
105 |
// Get Central Repository key indicating if product uses navi-keys for zoom
|
|
106 |
err = repository->Get( KCamCrZoomUsingNaviKeys, val );
|
|
107 |
|
|
108 |
// If there is an error then assume navi-keys not used
|
|
109 |
if ( err != KErrNone )
|
|
110 |
{
|
|
111 |
iZoomUsingNaviKeys = EFalse;
|
|
112 |
}
|
|
113 |
else
|
|
114 |
{
|
|
115 |
iZoomUsingNaviKeys = val;
|
|
116 |
}
|
|
117 |
#else
|
|
118 |
iZoomUsingVolumeKeys = EFalse;
|
|
119 |
iZoomUsingNaviKeys = ETrue;
|
|
120 |
#endif // !( defined(__WINS__) || defined(__WINSCW__) )
|
|
121 |
|
|
122 |
delete repository;
|
|
123 |
repository = NULL;
|
|
124 |
|
|
125 |
// Find the name and path of the MBM file for zoom pane bitmaps
|
|
126 |
TFileName resFileName;
|
|
127 |
CamUtility::ResourceFileName( resFileName );
|
|
128 |
TPtrC resname = resFileName;
|
|
129 |
|
|
130 |
// Create component bitmaps
|
|
131 |
AknIconUtils::CreateIconL( iIconZoomTop[0],
|
|
132 |
iIconZoomTop[1],
|
|
133 |
resname,
|
|
134 |
EMbmCameraappQgn_indi_cam4_zoom_top,
|
|
135 |
EMbmCameraappQgn_indi_cam4_zoom_top_mask );
|
|
136 |
|
|
137 |
AknIconUtils::CreateIconL( iIconZoomMiddle[0],
|
|
138 |
iIconZoomMiddle[1],
|
|
139 |
resname,
|
|
140 |
EMbmCameraappQgn_indi_cam4_zoom_middle,
|
|
141 |
EMbmCameraappQgn_indi_cam4_zoom_middle_mask );
|
|
142 |
|
|
143 |
AknIconUtils::CreateIconL( iIconZoomBottom[0],
|
|
144 |
iIconZoomBottom[1],
|
|
145 |
resname,
|
|
146 |
EMbmCameraappQgn_indi_cam4_zoom_bottom,
|
|
147 |
EMbmCameraappQgn_indi_cam4_zoom_bottom_mask );
|
|
148 |
|
|
149 |
AknIconUtils::CreateIconL( iIconZoomMarker[0],
|
|
150 |
iIconZoomMarker[1],
|
|
151 |
resname,
|
|
152 |
EMbmCameraappQgn_indi_cam4_zoom_marker,
|
|
153 |
EMbmCameraappQgn_indi_cam4_zoom_marker_mask );
|
|
154 |
|
|
155 |
AknIconUtils::CreateIconL( iIconZoomMarkerGray[0],
|
|
156 |
iIconZoomMarkerGray[1],
|
|
157 |
resname,
|
|
158 |
EMbmCameraappQgn_indi_cam4_zoom_marker_selected,
|
|
159 |
EMbmCameraappQgn_indi_cam4_zoom_marker_selected_mask );
|
|
160 |
|
|
161 |
AknIconUtils::CreateIconL( iIconZoomMin[0],
|
|
162 |
iIconZoomMin[1],
|
|
163 |
resname,
|
|
164 |
EMbmCameraappQgn_indi_cam4_zoom_min,
|
|
165 |
EMbmCameraappQgn_indi_cam4_zoom_min_mask );
|
|
166 |
|
|
167 |
AknIconUtils::CreateIconL( iIconZoomMax[0],
|
|
168 |
iIconZoomMax[1],
|
|
169 |
resname,
|
|
170 |
EMbmCameraappQgn_indi_cam4_zoom_max,
|
|
171 |
EMbmCameraappQgn_indi_cam4_zoom_max_mask );
|
|
172 |
|
|
173 |
SizeChanged(); // Initialize layouts and set sizes
|
|
174 |
CamUtility::SetAlphaL( iIconZoomTop[0], iIconZoomTop[1] );
|
|
175 |
CamUtility::SetAlphaL( iIconZoomMiddle[0], iIconZoomMiddle[1] );
|
|
176 |
CamUtility::SetAlphaL( iIconZoomBottom[0], iIconZoomBottom[1] );
|
|
177 |
CamUtility::SetAlphaL( iIconZoomMarker[0], iIconZoomMarker[1] );
|
|
178 |
CamUtility::SetAlphaL( iIconZoomMarkerGray[0], iIconZoomMarkerGray[1] );
|
|
179 |
CamUtility::SetAlphaL( iIconZoomMin[0], iIconZoomMin[1] );
|
|
180 |
CamUtility::SetAlphaL( iIconZoomMax[0], iIconZoomMax[1] );
|
|
181 |
iIconZoomMarkerCurrent = iIconZoomMarker[0];
|
|
182 |
|
|
183 |
// Retrieve product-specific information about zoom support
|
|
184 |
CamUtility::GetPsiInt( ECamPsiVideoZoomSupport, iZoomSupport );
|
|
185 |
|
|
186 |
// Retrieve the timing and step values for each of the zoom bar
|
|
187 |
// segments/modes eg Optical/Digital/Extended
|
|
188 |
TPckgBuf <TCamZoomLAF> pckg;
|
|
189 |
CamUtility::GetPsiAnyL( ECamPsiZoomBarLAF, &pckg);
|
|
190 |
iZoomLAF = pckg();
|
|
191 |
|
|
192 |
// Register for notification of controller events
|
|
193 |
iController.AddControllerObserverL( this );
|
|
194 |
|
|
195 |
iModel = CCamZoomModel::NewL( iController, this );
|
|
196 |
iFeedback = MTouchFeedback::Instance();
|
|
197 |
|
|
198 |
PRINT( _L( "Camera <= CCamZoomPane::ConstructL " ) );
|
|
199 |
}
|
|
200 |
|
|
201 |
// -----------------------------------------------------------------------------
|
|
202 |
// CCamZoomPane::LoadResourceDataL()
|
|
203 |
// Reads in all information needed from resources
|
|
204 |
// -----------------------------------------------------------------------------
|
|
205 |
//
|
|
206 |
void CCamZoomPane::LoadResourceDataL()
|
|
207 |
{
|
|
208 |
PRINT( _L( "Camera => CCamZoomPane::LoadResourceDataL " ) );
|
|
209 |
ReadLayoutL();
|
|
210 |
PRINT( _L( "Camera <= CCamZoomPane::LoadResourceDataL " ) );
|
|
211 |
}
|
|
212 |
|
|
213 |
// -----------------------------------------------------------------------------
|
|
214 |
// CCamZoomPane::UnloadResourceData()
|
|
215 |
// Frees all dynamic resources allocated in LoadResourceDataL
|
|
216 |
// -----------------------------------------------------------------------------
|
|
217 |
//
|
|
218 |
void CCamZoomPane::UnloadResourceData()
|
|
219 |
{
|
|
220 |
PRINT( _L( "Camera => CCamZoomPane::UnloadResourceData " ) );
|
|
221 |
PRINT( _L( "Camera <= CCamZoomPane::UnloadResourceData " ) );
|
|
222 |
}
|
|
223 |
|
|
224 |
// -----------------------------------------------------------------------------
|
|
225 |
// CCamZoomPane::ReloadResourceDataL()
|
|
226 |
// Refreshes all resource-based information stored in the class
|
|
227 |
// -----------------------------------------------------------------------------
|
|
228 |
//
|
|
229 |
void CCamZoomPane::ReloadResourceDataL()
|
|
230 |
{
|
|
231 |
PRINT( _L( "Camera => CCamZoomPane::ReloadResourceDataL " ) );
|
|
232 |
UnloadResourceData();
|
|
233 |
LoadResourceDataL();
|
|
234 |
PRINT( _L( "Camera <= CCamZoomPane::ReloadResourceDataL " ) );
|
|
235 |
}
|
|
236 |
|
|
237 |
// -----------------------------------------------------------------------------
|
|
238 |
// CCamZoomPane::NewL
|
|
239 |
// Two-phased constructor.
|
|
240 |
// -----------------------------------------------------------------------------
|
|
241 |
//
|
|
242 |
CCamZoomPane* CCamZoomPane::NewL( CCamAppController& aController,
|
|
243 |
TBool aOverlayViewFinder )
|
|
244 |
{
|
|
245 |
PRINT( _L( "Camera => CCamZoomPane::NewL " ) );
|
|
246 |
CCamZoomPane* self = new( ELeave ) CCamZoomPane ( aController, aOverlayViewFinder );
|
|
247 |
CleanupStack::PushL( self );
|
|
248 |
self->ConstructL();
|
|
249 |
CleanupStack::Pop( self );
|
|
250 |
PRINT( _L( "Camera <= CCamZoomPane::NewL " ) );
|
|
251 |
return self;
|
|
252 |
}
|
|
253 |
|
|
254 |
// -----------------------------------------------------------------------------
|
|
255 |
// CCamZoomPane::~CCamZoomPane
|
|
256 |
// Destructor.
|
|
257 |
// -----------------------------------------------------------------------------
|
|
258 |
//
|
|
259 |
CCamZoomPane::~CCamZoomPane()
|
|
260 |
{
|
|
261 |
PRINT( _L("Camera => ~CCamZoomPane" ))
|
|
262 |
iController.RemoveControllerObserver( this );
|
|
263 |
|
|
264 |
delete iIconZoomTop[0];
|
|
265 |
delete iIconZoomMiddle[0];
|
|
266 |
delete iIconZoomBottom[0];
|
|
267 |
delete iIconZoomMarker[0];
|
|
268 |
delete iIconZoomMarkerGray[0];
|
|
269 |
delete iIconZoomMin[0];
|
|
270 |
delete iIconZoomMax[0];
|
|
271 |
delete iIconZoomTop[1];
|
|
272 |
delete iIconZoomMiddle[1];
|
|
273 |
delete iIconZoomBottom[1];
|
|
274 |
delete iIconZoomMarker[1];
|
|
275 |
delete iIconZoomMarkerGray[1];
|
|
276 |
delete iIconZoomMin[1];
|
|
277 |
delete iIconZoomMax[1];
|
|
278 |
|
|
279 |
delete iModel;
|
|
280 |
|
|
281 |
if ( iRotatorAo &&
|
|
282 |
iRotatorAo->IsActive() )
|
|
283 |
{
|
|
284 |
iRotatorAo->Cancel();
|
|
285 |
}
|
|
286 |
delete iRotatorAo;
|
|
287 |
|
|
288 |
|
|
289 |
iZoomInKeys.Close();
|
|
290 |
iZoomOutKeys.Close();
|
|
291 |
|
|
292 |
PRINT( _L("Camera <= ~CCamZoomPane" ))
|
|
293 |
}
|
|
294 |
|
|
295 |
// -----------------------------------------------------------------------------
|
|
296 |
// CCamZoomPane::Draw
|
|
297 |
// Draws the zoom pane
|
|
298 |
// -----------------------------------------------------------------------------
|
|
299 |
//
|
|
300 |
void CCamZoomPane::Draw( CBitmapContext& aGc ) const
|
|
301 |
{
|
|
302 |
PRINT( _L( "Camera => CCamZoomPane::Draw " ) );
|
|
303 |
if ( !iMaxZoom )
|
|
304 |
{
|
|
305 |
PRINT( _L( "Camera <= CCamZoomPane::Draw not set up yet" ) );
|
|
306 |
return; // Not set up yet
|
|
307 |
}
|
|
308 |
|
|
309 |
if ( !iOverlayViewFinder )
|
|
310 |
{
|
|
311 |
aGc.Clear( iZoomPaneRect );
|
|
312 |
}
|
|
313 |
|
|
314 |
DrawPlusMinus( aGc );
|
|
315 |
DrawShaft( aGc );
|
|
316 |
DrawThumb( aGc );
|
|
317 |
PRINT( _L( "Camera <= CCamZoomPane::Draw " ) );
|
|
318 |
}
|
|
319 |
|
|
320 |
// -----------------------------------------------------------------------------
|
|
321 |
// CCamZoomPane::DrawPlusMinus
|
|
322 |
// Draws the plus and minus icons
|
|
323 |
// -----------------------------------------------------------------------------
|
|
324 |
//
|
|
325 |
void CCamZoomPane::DrawPlusMinus( CBitmapContext& aGc ) const
|
|
326 |
{
|
|
327 |
PRINT( _L( "Camera => CCamZoomPane::DrawPlusMinus " ) );
|
|
328 |
aGc.BitBlt( iPlusPoint, iIconZoomMax[0] );
|
|
329 |
aGc.BitBlt( iMinusPoint, iIconZoomMin[0] );
|
|
330 |
PRINT( _L( "Camera <= CCamZoomPane::DrawPlusMinus " ) );
|
|
331 |
}
|
|
332 |
|
|
333 |
// -----------------------------------------------------------------------------
|
|
334 |
// CCamZoomPane::DrawShaft
|
|
335 |
// Draws the shaft of the zoom pane
|
|
336 |
// -----------------------------------------------------------------------------
|
|
337 |
//
|
|
338 |
void CCamZoomPane::DrawShaft( CBitmapContext& aGc ) const
|
|
339 |
{
|
|
340 |
PRINT( _L( "Camera => CCamZoomPane::DrawShaft " ) );
|
|
341 |
aGc.BitBlt( iTopPoint, iIconZoomTop[0] );
|
|
342 |
aGc.BitBlt( iMiddlePoint, iIconZoomMiddle[0] );
|
|
343 |
aGc.BitBlt( iBottomPoint, iIconZoomBottom[0] );
|
|
344 |
PRINT( _L( "Camera <= CCamZoomPane::DrawShaft " ) );
|
|
345 |
}
|
|
346 |
|
|
347 |
// -----------------------------------------------------------------------------
|
|
348 |
// CCamZoomPane::SetPoint
|
|
349 |
// Sets the value of a point based on another point and an (optional) modifier value.
|
|
350 |
// This was added to simplify the bar drawing code, so the changes based on orientation
|
|
351 |
// are (as much as possible) contained in this function
|
|
352 |
// -----------------------------------------------------------------------------
|
|
353 |
//
|
|
354 |
void
|
|
355 |
CCamZoomPane::SetPoint( TPoint& aPoint,
|
|
356 |
const TPoint& aOffset,
|
|
357 |
TInt aAdditional ) const
|
|
358 |
{
|
|
359 |
PRINT( _L( "Camera => CCamZoomPane::SetPoint " ) );
|
|
360 |
if ( PaneOrientation() == EZPOrientationVertical )
|
|
361 |
{
|
|
362 |
aPoint.iY = aOffset.iY + aAdditional;
|
|
363 |
}
|
|
364 |
else
|
|
365 |
{
|
|
366 |
aPoint.iX = aOffset.iX - aAdditional;
|
|
367 |
}
|
|
368 |
PRINT( _L( "Camera <= CCamZoomPane::SetPoint " ) );
|
|
369 |
}
|
|
370 |
|
|
371 |
// -----------------------------------------------------------------------------
|
|
372 |
// CCamZoomPane::PaneOrientation
|
|
373 |
// Returns the current zoom pane orientation (taking into account whether this
|
|
374 |
// should be forced or not if on secondary camera)
|
|
375 |
// -----------------------------------------------------------------------------
|
|
376 |
//
|
|
377 |
CCamZoomPane::TZPOrientation CCamZoomPane::PaneOrientation() const
|
|
378 |
{
|
|
379 |
PRINT( _L( "Camera => CCamZoomPane::PaneOrientation " ) );
|
|
380 |
if ( iController.ActiveCamera() == ECamActiveCameraSecondary )
|
|
381 |
{
|
|
382 |
PRINT( _L( "Camera <= CCamZoomPane::PaneOrientation EZPOrientationVertical" ) );
|
|
383 |
return EZPOrientationVertical;
|
|
384 |
}
|
|
385 |
else
|
|
386 |
{
|
|
387 |
PRINT( _L( "Camera <= CCamZoomPane::PaneOrientation iOrientation" ) );
|
|
388 |
return iOrientation;
|
|
389 |
}
|
|
390 |
}
|
|
391 |
|
|
392 |
// -----------------------------------------------------------------------------
|
|
393 |
// CCamZoomPane::DrawThumb
|
|
394 |
// Draws the thumb of the zoom pane
|
|
395 |
// -----------------------------------------------------------------------------
|
|
396 |
//
|
|
397 |
void CCamZoomPane::DrawThumb( CBitmapContext& aGc ) const
|
|
398 |
{
|
|
399 |
PRINT( _L( "Camera => CCamZoomPane::DrawThumb " ) );
|
|
400 |
TPoint newThumbPos;
|
|
401 |
// Knob bitmap has an empty area on the edge, thus it starts upper than top
|
|
402 |
// of zoom slider
|
|
403 |
// topPointY is iTl.iY of knob bitmap when maximum zoom is used.
|
|
404 |
newThumbPos.iX = iZoomPaneRect.iTl.iX;
|
|
405 |
|
|
406 |
TInt pixelsPerStep = ( iMaxOffset * KDivisorFactor ) / (iMaxZoom+1);
|
|
407 |
TInt pixelsFromBase;
|
|
408 |
pixelsFromBase = ( iTrgZoom * pixelsPerStep );
|
|
409 |
newThumbPos.iY = iTopPoint.iY + iMaxOffset -
|
|
410 |
(pixelsFromBase + pixelsPerStep/2 +
|
|
411 |
iIconZoomMarker[0]->SizeInPixels().iHeight *
|
|
412 |
KDivisorFactor / 2) / KDivisorFactor;
|
|
413 |
|
|
414 |
aGc.BitBlt( newThumbPos, iIconZoomMarkerCurrent );
|
|
415 |
PRINT( _L( "Camera <= CCamZoomPane::DrawThumb " ) );
|
|
416 |
}
|
|
417 |
|
|
418 |
// -----------------------------------------------------------------------------
|
|
419 |
// CCamZoomPane::SetRect
|
|
420 |
// Sets the rect that zoom pane is drawn into
|
|
421 |
// -----------------------------------------------------------------------------
|
|
422 |
//
|
|
423 |
void CCamZoomPane::SetRect( TRect aRect )
|
|
424 |
{
|
|
425 |
PRINT( _L( "Camera => CCamZoomPane::SetRect " ) );
|
|
426 |
iZoomPaneRect = aRect;
|
|
427 |
PRINT( _L( "Camera <= CCamZoomPane::SetRect " ) );
|
|
428 |
}
|
|
429 |
|
|
430 |
// -----------------------------------------------------------------------------
|
|
431 |
// CCamZoomPane::SetZoomRange
|
|
432 |
// Specifies the range of values zoom supports
|
|
433 |
// aMax should always be more than aMin.
|
|
434 |
// -----------------------------------------------------------------------------
|
|
435 |
//
|
|
436 |
TInt CCamZoomPane::SetZoomRange( TInt aMin, TInt aMax )
|
|
437 |
{
|
|
438 |
PRINT( _L( "Camera => CCamZoomPane::SetZoomRange " ) );
|
|
439 |
// The minimum value should always be less than the max.
|
|
440 |
if ( aMin >= aMax ||
|
|
441 |
aMin < 0 )
|
|
442 |
{
|
|
443 |
PRINT( _L( "Camera <= CCamZoomPane::SetZoomRange KErrArgument" ) );
|
|
444 |
return KErrArgument;
|
|
445 |
}
|
|
446 |
|
|
447 |
iMinZoom = aMin;
|
|
448 |
iMaxZoom = aMax;
|
|
449 |
PRINT( _L( "Camera <= CCamZoomPane::SetZoomRange " ) );
|
|
450 |
return KErrNone;
|
|
451 |
}
|
|
452 |
|
|
453 |
// -----------------------------------------------------------------------------
|
|
454 |
// CCamZoomPane::SetZoomSteps
|
|
455 |
// Sets the number of steps allowed in each category
|
|
456 |
// -----------------------------------------------------------------------------
|
|
457 |
//
|
|
458 |
void CCamZoomPane::SetZoomSteps( TInt aOptSteps, TInt aStdSteps, TInt aExtSteps )
|
|
459 |
{
|
|
460 |
PRINT( _L( "Camera => CCamZoomPane::SetZoomSteps " ) );
|
|
461 |
ASSERT( aOptSteps >= 0 && aStdSteps >= 0 && aExtSteps >= 0 );
|
|
462 |
|
|
463 |
iOptSteps = aOptSteps;
|
|
464 |
iStdSteps = aStdSteps;
|
|
465 |
iExtSteps = aExtSteps;
|
|
466 |
PRINT( _L( "Camera <= CCamZoomPane::SetZoomSteps " ) );
|
|
467 |
}
|
|
468 |
|
|
469 |
// -----------------------------------------------------------------------------
|
|
470 |
// CCamZoomPane::SetZoomValue
|
|
471 |
// Specifies the current level of Zoom.
|
|
472 |
// -----------------------------------------------------------------------------
|
|
473 |
//
|
|
474 |
TInt CCamZoomPane::SetZoomValue( TInt aZoom )
|
|
475 |
{
|
|
476 |
PRINT1( _L( "Camera => CCamZoomPane::SetZoomValue aZoom=%d" ), aZoom );
|
|
477 |
if ( iController.UiConfigManagerPtr()->IsExtendedDigitalZoomSupported() )
|
|
478 |
{
|
|
479 |
// this may happen if in the extended zoom range
|
|
480 |
// and we switch the extended range off - the
|
|
481 |
// zoom value in the engine will be greater than
|
|
482 |
// the max value allowed
|
|
483 |
if ( aZoom > iMaxZoom )
|
|
484 |
{
|
|
485 |
aZoom = iMaxZoom;
|
|
486 |
}
|
|
487 |
}
|
|
488 |
|
|
489 |
// Check supplied value is within valid range
|
|
490 |
if ( aZoom < iMinZoom || aZoom > iMaxZoom )
|
|
491 |
{
|
|
492 |
PRINT( _L( "Camera <= CCamZoomPane::SetZoomValue KErrArgument" ) );
|
|
493 |
return KErrArgument;
|
|
494 |
}
|
|
495 |
|
|
496 |
iCurZoom = aZoom;
|
|
497 |
iTrgZoom = aZoom;
|
|
498 |
|
|
499 |
if ( iVisible )
|
|
500 |
{
|
|
501 |
// force redraw of zoom pane
|
|
502 |
MakeVisible( ETrue, ETrue );
|
|
503 |
}
|
|
504 |
|
|
505 |
PRINT( _L( "Camera <= CCamZoomPane::SetZoomValue " ) );
|
|
506 |
return KErrNone;
|
|
507 |
}
|
|
508 |
|
|
509 |
// -----------------------------------------------------------------------------
|
|
510 |
// CCamZoomPane::ZoomValue
|
|
511 |
// Returns the current zoom value (as the ZoomPane knows it)
|
|
512 |
// -----------------------------------------------------------------------------
|
|
513 |
//
|
|
514 |
TInt CCamZoomPane::ZoomValue() const
|
|
515 |
{
|
|
516 |
PRINT( _L( "Camera => CCamZoomPane::ZoomValue " ) );
|
|
517 |
PRINT1( _L( "Camera <= CCamZoomPane::ZoomValue iCurZoom=%d" ), iCurZoom );
|
|
518 |
return iCurZoom;
|
|
519 |
}
|
|
520 |
|
|
521 |
// -----------------------------------------------------------------------------
|
|
522 |
// CCamZoomPane::IsZoomAtMinimum
|
|
523 |
// Returns whether the current zoom value is the minimum zoom
|
|
524 |
// -----------------------------------------------------------------------------
|
|
525 |
//
|
|
526 |
TBool CCamZoomPane::IsZoomAtMinimum() const
|
|
527 |
{
|
|
528 |
PRINT2(_L("Camera =><= CCamZoomPane::IsZoomAtMinimum iCurZoom = %d, iMinZoom = %d"), iCurZoom, iMinZoom);
|
|
529 |
return iCurZoom == iMinZoom;
|
|
530 |
}
|
|
531 |
|
|
532 |
// -----------------------------------------------------------------------------
|
|
533 |
// CCamZoomPane::IsZoomAtMaximum
|
|
534 |
// Returns whether the current zoom value is the maximum zoom
|
|
535 |
// -----------------------------------------------------------------------------
|
|
536 |
//
|
|
537 |
TBool CCamZoomPane::IsZoomAtMaximum() const
|
|
538 |
{
|
|
539 |
PRINT2(_L("Camera =><= CCamZoomPane::IsZoomAtMaximum iCurZoom = %d, iMaxZoom = %d"), iCurZoom, iMaxZoom);
|
|
540 |
return iCurZoom == iMaxZoom;
|
|
541 |
}
|
|
542 |
|
|
543 |
// -----------------------------------------------------------------------------
|
|
544 |
// CCamZoomPane::OkToShowPane
|
|
545 |
// Returns whether or not the Zoom Pane can currently be shown.
|
|
546 |
// -----------------------------------------------------------------------------
|
|
547 |
//
|
|
548 |
TBool CCamZoomPane::OkToShowPane() const
|
|
549 |
{
|
|
550 |
PRINT( _L( "Camera => CCamZoomPane::OkToShowPane " ) );
|
|
551 |
// Are we currently recording video?
|
|
552 |
if ( iRecordingVideo )
|
|
553 |
{
|
|
554 |
// Are we allowed to zoom when recording video?
|
|
555 |
if ( ( iZoomSupport & ECamZoomWhenRecord ) )
|
|
556 |
{
|
|
557 |
PRINT( _L( "Camera <= CCamZoomPane::OkToShowPane ETrue" ) );
|
|
558 |
return ETrue;
|
|
559 |
}
|
|
560 |
else // If not allowed, return false
|
|
561 |
{
|
|
562 |
PRINT( _L( "Camera <= CCamZoomPane::OkToShowPane EFalse" ) );
|
|
563 |
return EFalse;
|
|
564 |
}
|
|
565 |
}
|
|
566 |
|
|
567 |
// If a sequence capture is in progress
|
|
568 |
if ( iController.SequenceCaptureInProgress() )
|
|
569 |
{
|
|
570 |
PRINT( _L( "Camera <= CCamZoomPane::OkToShowPane EFalse" ) );
|
|
571 |
return EFalse;
|
|
572 |
}
|
|
573 |
|
|
574 |
PRINT( _L( "Camera <= CCamZoomPane::OkToShowPane ETrue" ) );
|
|
575 |
return ETrue;
|
|
576 |
}
|
|
577 |
|
|
578 |
// -----------------------------------------------------------------------------
|
|
579 |
// CCamZoomPane::HandleControllerEventL
|
|
580 |
// Handle controller events, specifically to find out if video is currently
|
|
581 |
// being recorded. Only called if Zooming while recording is NOT allowed
|
|
582 |
// -----------------------------------------------------------------------------
|
|
583 |
//
|
|
584 |
void CCamZoomPane::HandleControllerEventL( TCamControllerEvent aEvent,
|
|
585 |
TInt /*aError*/ )
|
|
586 |
{
|
|
587 |
PRINT( _L( "Camera => CCamZoomPane::HandleControllerEventL " ) );
|
|
588 |
switch ( aEvent )
|
|
589 |
{
|
|
590 |
case ECamEventOperationStateChanged:
|
|
591 |
{
|
|
592 |
iRecordingVideo = ECamControllerVideo == iController.CurrentMode()
|
|
593 |
&& ECamCapturing == iController.CurrentOperation();
|
|
594 |
break;
|
|
595 |
}
|
|
596 |
case ECamEventCameraChanged:
|
|
597 |
{
|
|
598 |
ReadLayoutL();
|
|
599 |
break;
|
|
600 |
}
|
|
601 |
case ECamEventCaptureComplete:
|
|
602 |
{
|
|
603 |
// Release knob if image is captured with HW button while zooming.
|
|
604 |
iIconZoomMarkerCurrent = iIconZoomMarker[0];
|
|
605 |
break;
|
|
606 |
}
|
|
607 |
default:
|
|
608 |
break;
|
|
609 |
}
|
|
610 |
PRINT( _L( "Camera <= CCamZoomPane::HandleControllerEventL " ) );
|
|
611 |
}
|
|
612 |
|
|
613 |
// -----------------------------------------------------------------------------
|
|
614 |
// CCamZoomPane::Rect
|
|
615 |
// Returns the zoom pane rect
|
|
616 |
// -----------------------------------------------------------------------------
|
|
617 |
//
|
|
618 |
TRect CCamZoomPane::Rect() const
|
|
619 |
{
|
|
620 |
PRINT( _L( "Camera =><= CCamZoomPane::Rect " ) );
|
|
621 |
return iZoomPaneRect;
|
|
622 |
}
|
|
623 |
|
|
624 |
// ---------------------------------------------------------
|
|
625 |
// CCamZoomPane::ReadLayoutL
|
|
626 |
// ---------------------------------------------------------
|
|
627 |
//
|
|
628 |
void CCamZoomPane::ReadLayoutL()
|
|
629 |
{
|
|
630 |
PRINT( _L( "Camera =><= CCamZoomPane::ReadLayoutL " ) );
|
|
631 |
|
|
632 |
if ( CamUtility::IsNhdDevice() )
|
|
633 |
{
|
|
634 |
TouchLayout();
|
|
635 |
}
|
|
636 |
else
|
|
637 |
{
|
|
638 |
NonTouchLayout();
|
|
639 |
}
|
|
640 |
}
|
|
641 |
|
|
642 |
// -----------------------------------------------------------------------------
|
|
643 |
// CCamZoomPane::IsVisible
|
|
644 |
// Is the zoom pane invisible
|
|
645 |
// -----------------------------------------------------------------------------
|
|
646 |
//
|
|
647 |
TBool CCamZoomPane::IsVisible() const
|
|
648 |
{
|
|
649 |
PRINT( _L( "Camera =><= CCamZoomPane::IsVisible " ) );
|
|
650 |
return iVisible;
|
|
651 |
}
|
|
652 |
|
|
653 |
// -----------------------------------------------------------------------------
|
|
654 |
// CCamZoomPane::MakeVisible
|
|
655 |
// Makes the zoom pane visible
|
|
656 |
// -----------------------------------------------------------------------------
|
|
657 |
//
|
|
658 |
void CCamZoomPane::MakeVisible( TBool aVisible, TBool aRedraw )
|
|
659 |
{
|
|
660 |
PRINT2( _L( "Camera => CCamZoomPane::MakeVisible aVisible=%d aRedraw=%d" ), aVisible, aRedraw );
|
|
661 |
iVisible = aVisible;
|
|
662 |
|
|
663 |
CCamAppUi* appUi = static_cast<CCamAppUi*>( CEikonEnv::Static()->AppUi() );
|
|
664 |
|
|
665 |
// No zoom in secondary camera view
|
|
666 |
if ( appUi && iController.ActiveCamera() == ECamActiveCameraPrimary )
|
|
667 |
{
|
|
668 |
if ( aVisible )
|
|
669 |
{
|
|
670 |
appUi->ShowZoomPane(aRedraw);
|
|
671 |
}
|
|
672 |
else
|
|
673 |
{
|
|
674 |
appUi->HideZoomPane(aRedraw);
|
|
675 |
iVisible = EFalse;
|
|
676 |
}
|
|
677 |
}
|
|
678 |
PRINT( _L( "Camera <= CCamZoomPane::MakeVisible " ) );
|
|
679 |
}
|
|
680 |
|
|
681 |
void CCamZoomPane::SetZoomKeys( const RArray<TInt>& aZoomIn,
|
|
682 |
const RArray<TInt>& aZoomOut )
|
|
683 |
{
|
|
684 |
PRINT( _L( "Camera => CCamZoomPane::SetZoomKeys CAMERAAPP_MULTIPLE_ZOOM_KEYS" ) );
|
|
685 |
iZoomInKeys.Reset();
|
|
686 |
ReadZoomKeys( aZoomIn, iZoomInKeys );
|
|
687 |
iZoomOutKeys.Reset();
|
|
688 |
ReadZoomKeys( aZoomOut, iZoomOutKeys );
|
|
689 |
PRINT( _L( "Camera <= CCamZoomPane::SetZoomKeys " ) );
|
|
690 |
}
|
|
691 |
|
|
692 |
// -----------------------------------------------------------------------------
|
|
693 |
// CCamZoomPane::ReadZoomKeys
|
|
694 |
// -----------------------------------------------------------------------------
|
|
695 |
//
|
|
696 |
void CCamZoomPane::ReadZoomKeys( const RArray<TInt>& aSource,
|
|
697 |
RArray<TInt>& aTarget )
|
|
698 |
{
|
|
699 |
PRINT( _L( "Camera => CCamZoomPane::ReadZoomKeys " ) );
|
|
700 |
for ( TInt i = 0; i < aSource.Count(); i++ )
|
|
701 |
{
|
|
702 |
// here we ignore the error
|
|
703 |
aTarget.Append( aSource[i] );
|
|
704 |
}
|
|
705 |
PRINT( _L( "Camera <= CCamZoomPane::ReadZoomKeys " ) );
|
|
706 |
}
|
|
707 |
|
|
708 |
// -----------------------------------------------------------------------------
|
|
709 |
// CCamZoomPane::CheckForZoomKey
|
|
710 |
// -----------------------------------------------------------------------------
|
|
711 |
//
|
|
712 |
TBool CCamZoomPane::CheckForZoomKey( const TKeyEvent& aKeyEvent,
|
|
713 |
const RArray<TInt>& aKeys )
|
|
714 |
{
|
|
715 |
PRINT( _L( "Camera =><= CCamZoomPane::CheckForZoomKey " ) );
|
|
716 |
return (KErrNotFound != aKeys.Find( aKeyEvent.iScanCode ));
|
|
717 |
}
|
|
718 |
|
|
719 |
|
|
720 |
// -----------------------------------------------------------------------------
|
|
721 |
// CCamZoomPane::OfferKeyEventL
|
|
722 |
// Handles key events for the zoom pane.
|
|
723 |
// -----------------------------------------------------------------------------
|
|
724 |
//
|
|
725 |
TKeyResponse CCamZoomPane::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
|
|
726 |
{
|
|
727 |
PRINT2( _L("Camera => CCamZoomPane::OfferKeyEventL (%d) (%d)"),aKeyEvent.iScanCode, aType )
|
|
728 |
TBool vertical = PaneOrientation() == EZPOrientationVertical;
|
|
729 |
|
|
730 |
|
|
731 |
TBool foundZoomInKey = CheckForZoomKey( aKeyEvent, iZoomInKeys );
|
|
732 |
TBool foundZoomOutKey = CheckForZoomKey( aKeyEvent, iZoomOutKeys );
|
|
733 |
|
|
734 |
if ( foundZoomInKey && vertical ||
|
|
735 |
foundZoomOutKey && !vertical )
|
|
736 |
{
|
|
737 |
// Block key events if touch is active
|
|
738 |
if ( iTouchActive )
|
|
739 |
{
|
|
740 |
return EKeyWasConsumed;
|
|
741 |
}
|
|
742 |
// Handle a zoom-in key as a valid event, and start zoom
|
|
743 |
else if ( aType == EEventKeyDown )
|
|
744 |
{
|
|
745 |
iModel->ZoomIn();
|
|
746 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyDown, zoom in"))
|
|
747 |
return EKeyWasConsumed;
|
|
748 |
}
|
|
749 |
// Handle an up zoom-in key as a valid event, only if currently
|
|
750 |
// zooming. Can get stray up events if user woke from standby
|
|
751 |
// with zoom key. This should filter these out.
|
|
752 |
else if ( aType == EEventKeyUp &&
|
|
753 |
IsCurrentlyZooming() )
|
|
754 |
{
|
|
755 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyUp, stop zoom 1"))
|
|
756 |
iModel->StopZoom();
|
|
757 |
return EKeyWasConsumed;
|
|
758 |
}
|
|
759 |
// Handle special zoom-in once request
|
|
760 |
else if ( aType == EEventUser &&
|
|
761 |
!IsCurrentlyZooming() )
|
|
762 |
{
|
|
763 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyUp, zoom in once"))
|
|
764 |
iModel->ZoomIn( ETrue );
|
|
765 |
return EKeyWasConsumed;
|
|
766 |
}
|
|
767 |
// Repeat "key" events are consumed (to keep the bar visible) but
|
|
768 |
// no need to do anything with it as zooming is timer (not key event) based
|
|
769 |
else if ( aType == EEventKey &&
|
|
770 |
aKeyEvent.iRepeats > 0 )
|
|
771 |
{
|
|
772 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKey repeated 1"))
|
|
773 |
// Do nothing with it, but consume it
|
|
774 |
return EKeyWasConsumed;
|
|
775 |
}
|
|
776 |
else
|
|
777 |
{
|
|
778 |
// empty statement to remove Lint error.
|
|
779 |
}
|
|
780 |
|
|
781 |
}
|
|
782 |
// If the orientation of the zoom pane changes, the keys to zoom in/out
|
|
783 |
// need to switch to move in the correct direction on the zoom pane.
|
|
784 |
else if ( foundZoomOutKey && vertical ||
|
|
785 |
foundZoomInKey && !vertical )
|
|
786 |
{
|
|
787 |
// Handle a zoom-out key as a valid event, and start zoom
|
|
788 |
if ( aType == EEventKeyDown )
|
|
789 |
{
|
|
790 |
iModel->ZoomOut();
|
|
791 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyDown, zoom out"))
|
|
792 |
return EKeyWasConsumed;
|
|
793 |
}
|
|
794 |
// Handle an up zoom-out key as a valid event, only if currently
|
|
795 |
// zooming. Can get stray up events if user woke from standby
|
|
796 |
// with zoom key. This should filter these out.
|
|
797 |
else if ( aType == EEventKeyUp &&
|
|
798 |
IsCurrentlyZooming() )
|
|
799 |
{
|
|
800 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyUp, calling StopZoom"))
|
|
801 |
iModel->StopZoom();
|
|
802 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyUp, stop zoom 2"))
|
|
803 |
return EKeyWasConsumed;
|
|
804 |
}
|
|
805 |
// Handle special zoom-out once request
|
|
806 |
else if ( aType == EEventUser &&
|
|
807 |
!IsCurrentlyZooming() )
|
|
808 |
{
|
|
809 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKeyUp, zoom out once"))
|
|
810 |
iModel->ZoomOut( ETrue );
|
|
811 |
return EKeyWasConsumed;
|
|
812 |
}
|
|
813 |
// Repeat "key" events are consumed (to keep the bar visible) but
|
|
814 |
// no need to do anything with it as zooming is timer (not key event) based
|
|
815 |
else if ( aType == EEventKey &&
|
|
816 |
aKeyEvent.iRepeats > 0 )
|
|
817 |
{
|
|
818 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKey repeated 2"))
|
|
819 |
// Do nothing with it, but consume it
|
|
820 |
return EKeyWasConsumed;
|
|
821 |
}
|
|
822 |
else
|
|
823 |
{
|
|
824 |
// empty statement to remove Lint error.
|
|
825 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKey empty statement!"))
|
|
826 |
}
|
|
827 |
|
|
828 |
}
|
|
829 |
// otherwise, do nothing
|
|
830 |
else
|
|
831 |
{
|
|
832 |
// empty statement to remove Lint error.
|
|
833 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL EEventKey empty statement!!"))
|
|
834 |
}
|
|
835 |
PRINT( _L("Camera <= CCamZoomPane::OfferKeyEventL not consumed"))
|
|
836 |
return EKeyWasNotConsumed;
|
|
837 |
}
|
|
838 |
|
|
839 |
// -----------------------------------------------------------------------------
|
|
840 |
// CCamZoomPane::HandleForegroundEvent
|
|
841 |
// Performs required actions on gaining/losing foreground
|
|
842 |
// -----------------------------------------------------------------------------
|
|
843 |
//
|
|
844 |
void CCamZoomPane::HandleForegroundEvent( TBool aForeground )
|
|
845 |
{
|
|
846 |
PRINT( _L( "Camera => CCamZoomPane::HandleForegroundEvent " ) );
|
|
847 |
if ( !aForeground )
|
|
848 |
{
|
|
849 |
// Ensure any ongoing zoom is stopped
|
|
850 |
PRINT( _L( "Camera <> CCamZoomPane::HandleForegroundEvent calling StopZoom" ) );
|
|
851 |
iModel->StopZoom();
|
|
852 |
}
|
|
853 |
PRINT( _L( "Camera <= CCamZoomPane::HandleForegroundEvent " ) );
|
|
854 |
}
|
|
855 |
|
|
856 |
// -----------------------------------------------------------------------------
|
|
857 |
// CCamZoomPane::IsCurrentlyZooming
|
|
858 |
// Returns ETrue if the zoom model is currently zooming in/out,
|
|
859 |
// else returns EFalse
|
|
860 |
// -----------------------------------------------------------------------------
|
|
861 |
//
|
|
862 |
TBool CCamZoomPane::IsCurrentlyZooming() const
|
|
863 |
{
|
|
864 |
PRINT( _L( "Camera =><= CCamZoomPane::IsCurrentlyZooming " ) );
|
|
865 |
return iModel->IsCurrentlyZooming();
|
|
866 |
}
|
|
867 |
|
|
868 |
// -----------------------------------------------------------------------------
|
|
869 |
// CCamZoomPane::ResetToDefaultAfterPrepare
|
|
870 |
// Sets the zoompane to reset the zoom level to default values
|
|
871 |
// next time the engine is prepared
|
|
872 |
// -----------------------------------------------------------------------------
|
|
873 |
//
|
|
874 |
void CCamZoomPane::ResetToDefaultAfterPrepare( TBool aReset )
|
|
875 |
{
|
|
876 |
PRINT( _L( "Camera =><= CCamZoomPane::ResetToDefaultAfterPrepare " ) );
|
|
877 |
iModel->ResetToDefaultAfterPrepare( aReset );
|
|
878 |
}
|
|
879 |
|
|
880 |
// -----------------------------------------------------------------------------
|
|
881 |
// CCamZoomPane::IsResetPending
|
|
882 |
// Whether or not the zoom level is waiting to be reset to default
|
|
883 |
// -----------------------------------------------------------------------------
|
|
884 |
//
|
|
885 |
TBool CCamZoomPane::IsResetPending() const
|
|
886 |
{
|
|
887 |
PRINT( _L( "Camera =><= CCamZoomPane::IsResetPending " ) );
|
|
888 |
return iModel->IsResetPending();
|
|
889 |
}
|
|
890 |
|
|
891 |
// -----------------------------------------------------------------------------
|
|
892 |
// CCamZoomPane::StopZoom
|
|
893 |
// Stops zoom actions
|
|
894 |
// -----------------------------------------------------------------------------
|
|
895 |
//
|
|
896 |
void CCamZoomPane::StopZoom()
|
|
897 |
{
|
|
898 |
PRINT( _L( "Camera => CCamZoomPane::StopZoom " ) );
|
|
899 |
iModel->StopZoom();
|
|
900 |
PRINT( _L( "Camera <= CCamZoomPane::StopZoom " ) );
|
|
901 |
}
|
|
902 |
|
|
903 |
// -----------------------------------------------------------------------------
|
|
904 |
// CCamZoomPane::ResetZoomTo1x
|
|
905 |
// Resets the zoom level to 1x.
|
|
906 |
// -----------------------------------------------------------------------------
|
|
907 |
//
|
|
908 |
void CCamZoomPane::ResetZoomTo1x()
|
|
909 |
{
|
|
910 |
PRINT( _L( "Camera => CCamZoomPane::ResetZoomTo1x " ) );
|
|
911 |
iModel->ResetZoomTo1x();
|
|
912 |
PRINT( _L( "Camera <= CCamZoomPane::ResetZoomTo1x " ) );
|
|
913 |
}
|
|
914 |
|
|
915 |
// -----------------------------------------------------------------------------
|
|
916 |
// CCamZoomPane::StartTouchZoomL
|
|
917 |
// -----------------------------------------------------------------------------
|
|
918 |
//
|
|
919 |
TBool CCamZoomPane::StartTouchZoomL( TInt aPointer )
|
|
920 |
{
|
|
921 |
PRINT( _L( "Camera => CCamZoomPane::StartTouchZoomL" ) );
|
|
922 |
|
|
923 |
// Block key events
|
|
924 |
iTouchActive = ETrue;
|
|
925 |
if ( !iMaxZoom ) // Avoid division by zero
|
|
926 |
{
|
|
927 |
return EFalse;
|
|
928 |
}
|
|
929 |
TInt pixelsPerStep = ( iMaxOffset * KDivisorFactor ) / (iMaxZoom+1);
|
|
930 |
|
|
931 |
PRINT1( _L( "Camera <> CCamZoomPane::StartTouchZoomL (iMaxZoom) %d" ), iMaxZoom );
|
|
932 |
PRINT1( _L( "Camera <> CCamZoomPane::StartTouchZoomL (iMinZoom) %d" ), iMinZoom );
|
|
933 |
PRINT1( _L( "Camera <> CCamZoomPane::StartTouchZoomL (pixelsPerStep) %d" ), pixelsPerStep );
|
|
934 |
|
|
935 |
// New zoom according to touched point
|
|
936 |
TInt base = iSliderParentRect.iBr.iY - aPointer;
|
|
937 |
PRINT1( _L( "Camera <> CCamZoomPane::StartTouchZoomL (base) %d" ), base );
|
|
938 |
|
|
939 |
// Target zoom level
|
|
940 |
iTrgZoom = base * KDivisorFactor / pixelsPerStep;
|
|
941 |
iTrgZoom = ( iTrgZoom < iMinZoom )? iMinZoom:iTrgZoom;
|
|
942 |
iTrgZoom = ( iTrgZoom > iMaxZoom )? iMaxZoom:iTrgZoom;
|
|
943 |
PRINT1( _L( "Camera <> CCamZoomPane::StartTouchZoomL (iTrgZoom) %d" ), iTrgZoom );
|
|
944 |
|
|
945 |
// Only update zoom when necessary
|
|
946 |
if ( Abs( aPointer - iPointerPrevi ) >= pixelsPerStep / KDivisorFactor &&
|
|
947 |
iTrgZoom != iCurZoom )
|
|
948 |
{
|
|
949 |
PRINT( _L( "Camera <> CCamZoomPane::StartTouchZoomL ZoomTo" ) );
|
|
950 |
iModel->ZoomTo( iTrgZoom );
|
|
951 |
iPointerPrevi = aPointer;
|
|
952 |
PRINT( _L( "Camera <= CCamZoomPane::StartTouchZoomL ETrue" ) );
|
|
953 |
return ETrue;
|
|
954 |
}
|
|
955 |
|
|
956 |
// Pointer didn't move, so we don't need to update anything
|
|
957 |
PRINT( _L( "Camera <= CCamZoomPane::StartTouchZoomL EFalse" ) );
|
|
958 |
return EFalse;
|
|
959 |
}
|
|
960 |
|
|
961 |
// -----------------------------------------------------------------------------
|
|
962 |
// CCamZoomPane::HandlePointerEventL
|
|
963 |
// -----------------------------------------------------------------------------
|
|
964 |
//
|
|
965 |
TBool CCamZoomPane::HandlePointerEventL( const TPointerEvent& aPointerEvent )
|
|
966 |
{
|
|
967 |
PRINT( _L( "Camera => CCamZoomPane::HandlePointerEventL" ) );
|
|
968 |
|
|
969 |
if ( PaneOrientation() != EZPOrientationVertical )
|
|
970 |
{
|
|
971 |
PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (orientation)" ) );
|
|
972 |
return EFalse; // EZPOrientationHorizontal not supported
|
|
973 |
}
|
|
974 |
|
|
975 |
TRect tchZoomArea = iSliderParentRect;
|
|
976 |
tchZoomArea.Grow( KTouchAreaExpansion, KTouchAreaExpansion );
|
|
977 |
TPointerEvent::TType type = aPointerEvent.iType;
|
|
978 |
|
|
979 |
// Only make the pane appear on first touch
|
|
980 |
if( !IsVisible() &&
|
|
981 |
type == TPointerEvent::EButton1Down )
|
|
982 |
{
|
|
983 |
Touchfeedback();
|
|
984 |
StopZoom();
|
|
985 |
MakeVisible( ETrue, ETrue );
|
|
986 |
PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (first touch)" ) );
|
|
987 |
return ETrue;
|
|
988 |
}
|
|
989 |
|
|
990 |
// At this point, the zoom pane should have already been visible
|
|
991 |
// so we activate touch zoom if the pointer is on the zoom pane
|
|
992 |
if ( IsVisible() &&
|
|
993 |
tchZoomArea.Contains( aPointerEvent.iPosition ) &&
|
|
994 |
type == TPointerEvent::EButton1Down )
|
|
995 |
{
|
|
996 |
Touchfeedback();
|
|
997 |
// Change zoom thumb to non-dimmed
|
|
998 |
iIconZoomMarkerCurrent = iIconZoomMarkerGray[0]; // Dimmed knob
|
|
999 |
// Force redraw of zoom pane, so knob will be dimmed
|
|
1000 |
TBool ret = ETrue;
|
|
1001 |
// Update zoom position, if necessary
|
|
1002 |
StartTouchZoomL( aPointerEvent.iPosition.iY );
|
|
1003 |
PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (touch active)" ) );
|
|
1004 |
return ret;
|
|
1005 |
}
|
|
1006 |
|
|
1007 |
// If the zoom panel is visible, but the touch event is not in the
|
|
1008 |
// zoom area, then make the zoom pane disappear.
|
|
1009 |
if ( IsVisible() &&
|
|
1010 |
!tchZoomArea.Contains( aPointerEvent.iPosition ) &&
|
|
1011 |
type == TPointerEvent::EButton1Down )
|
|
1012 |
{
|
|
1013 |
Touchfeedback();
|
|
1014 |
// Cancel zoom if user is pushing the volume key
|
|
1015 |
StopZoom();
|
|
1016 |
// Hide zoom pane
|
|
1017 |
MakeVisible( EFalse, ETrue );
|
|
1018 |
PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (make disappear)" ) );
|
|
1019 |
// return EFalse so the calling component doesn't reactivate the zoom pane
|
|
1020 |
return EFalse;
|
|
1021 |
}
|
|
1022 |
|
|
1023 |
// Only allow drag if the zoom is already active
|
|
1024 |
if ( type == TPointerEvent::EDrag &&
|
|
1025 |
tchZoomArea.Contains( aPointerEvent.iPosition ) &&
|
|
1026 |
iTouchActive )
|
|
1027 |
{
|
|
1028 |
TBool ret = StartTouchZoomL( aPointerEvent.iPosition.iY );
|
|
1029 |
PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (dragging)" ) );
|
|
1030 |
return ret;
|
|
1031 |
}
|
|
1032 |
|
|
1033 |
// Clean up when the touch events are stopped
|
|
1034 |
if ( type == TPointerEvent::EButton1Up ||
|
|
1035 |
(type == TPointerEvent::EDrag &&
|
|
1036 |
!tchZoomArea.Contains( aPointerEvent.iPosition )))
|
|
1037 |
{
|
|
1038 |
// don't do anything for stray touches
|
|
1039 |
if ( iTouchActive )
|
|
1040 |
{
|
|
1041 |
// Key events are no longer blocked
|
|
1042 |
iTouchActive = EFalse;
|
|
1043 |
// Change zoom thumb to non-dimmed
|
|
1044 |
iIconZoomMarkerCurrent = iIconZoomMarker[0];
|
|
1045 |
// force redraw of zoom pane, so knob is not dimmed anymore
|
|
1046 |
MakeVisible( ETrue, ETrue );
|
|
1047 |
PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (touch stopped)" ) );
|
|
1048 |
return ETrue;
|
|
1049 |
}
|
|
1050 |
|
|
1051 |
PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (touch not active)" ) );
|
|
1052 |
return EFalse;
|
|
1053 |
}
|
|
1054 |
|
|
1055 |
PRINT( _L( "Camera <= CCamZoomPane::HandlePointerEventL (not handled)" ) );
|
|
1056 |
return EFalse;
|
|
1057 |
}
|
|
1058 |
|
|
1059 |
// ---------------------------------------------------------
|
|
1060 |
// CCamZoomPane::SizeChanged
|
|
1061 |
// Called when the view size is changed
|
|
1062 |
// ---------------------------------------------------------
|
|
1063 |
//
|
|
1064 |
void CCamZoomPane::SizeChanged()
|
|
1065 |
{
|
|
1066 |
PRINT( _L( "Camera => CCamZoomPane::SizeChanged" ) );
|
|
1067 |
if ( CamUtility::IsNhdDevice() )
|
|
1068 |
{
|
|
1069 |
TouchLayout();
|
|
1070 |
}
|
|
1071 |
else
|
|
1072 |
{
|
|
1073 |
NonTouchLayout();
|
|
1074 |
}
|
|
1075 |
|
|
1076 |
PRINT( _L( "Camera <= CCamZoomPane::SizeChanged" ) );
|
|
1077 |
}
|
|
1078 |
|
|
1079 |
// ---------------------------------------------------------
|
|
1080 |
// CCamZoomPane::TouchLayout
|
|
1081 |
// ---------------------------------------------------------
|
|
1082 |
void CCamZoomPane::TouchLayout()
|
|
1083 |
{
|
|
1084 |
PRINT( _L( "Camera => CCamZoomPane::TouchLayout()" ) );
|
|
1085 |
TRect mainPaneRect;
|
|
1086 |
iMaxOffset = 0;
|
|
1087 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow,
|
|
1088 |
mainPaneRect );
|
|
1089 |
mainPaneRect.Move( -mainPaneRect.iTl );
|
|
1090 |
|
|
1091 |
TInt variant = Layout_Meta_Data::IsLandscapeOrientation();
|
|
1092 |
TAknWindowComponentLayout l = AknLayoutScalable_Apps::cam4_zoom_pane(variant);
|
|
1093 |
|
|
1094 |
TAknLayoutRect area;
|
|
1095 |
area.LayoutRect( mainPaneRect, l.LayoutLine() );
|
|
1096 |
iZoomPaneRect = area.Rect();
|
|
1097 |
|
|
1098 |
l = AknLayoutScalable_Apps::cam4_zoom_cont_pane(variant);
|
|
1099 |
area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
|
|
1100 |
iSliderParentRect = area.Rect();
|
|
1101 |
|
|
1102 |
l = AknLayoutScalable_Apps::cam4_zoom_pane_g1(variant); // +
|
|
1103 |
area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
|
|
1104 |
AknIconUtils::SetSize( iIconZoomMax[0], area.Rect().Size(),
|
|
1105 |
EAspectRatioNotPreserved );
|
|
1106 |
iPlusPoint = area.Rect().iTl;
|
|
1107 |
|
|
1108 |
l = AknLayoutScalable_Apps::cam4_zoom_pane_g2(variant); // -
|
|
1109 |
area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
|
|
1110 |
AknIconUtils::SetSize( iIconZoomMin[0], area.Rect().Size(),
|
|
1111 |
EAspectRatioNotPreserved );
|
|
1112 |
iMinusPoint = area.Rect().iTl;
|
|
1113 |
|
|
1114 |
l = AknLayoutScalable_Apps::cam4_zoom_cont_pane_g1(variant); // Top
|
|
1115 |
area.LayoutRect( iSliderParentRect, l.LayoutLine() );
|
|
1116 |
AknIconUtils::SetSize( iIconZoomTop[0], area.Rect().Size(),
|
|
1117 |
EAspectRatioNotPreserved );
|
|
1118 |
iTopPoint = area.Rect().iTl;
|
|
1119 |
iMaxOffset += area.Rect().Height();
|
|
1120 |
|
|
1121 |
l = AknLayoutScalable_Apps::cam4_zoom_cont_pane_g3(variant); // Middle
|
|
1122 |
area.LayoutRect( iSliderParentRect, l.LayoutLine() );
|
|
1123 |
iIconZoomMiddle[0]->Resize( area.Rect().Size());
|
|
1124 |
AknIconUtils::SetSize( iIconZoomMiddle[0], area.Rect().Size(),
|
|
1125 |
EAspectRatioNotPreserved );
|
|
1126 |
iMiddlePoint = area.Rect().iTl;
|
|
1127 |
iMaxOffset += area.Rect().Height();
|
|
1128 |
|
|
1129 |
l = AknLayoutScalable_Apps::cam4_zoom_cont_pane_g2(variant); // Bottom
|
|
1130 |
area.LayoutRect( iSliderParentRect, l.LayoutLine() );
|
|
1131 |
AknIconUtils::SetSize( iIconZoomBottom[0], area.Rect().Size(),
|
|
1132 |
EAspectRatioNotPreserved );
|
|
1133 |
iBottomPoint = area.Rect().iTl;
|
|
1134 |
TRect bottomRect = area.Rect();
|
|
1135 |
iMaxOffset += area.Rect().Height();
|
|
1136 |
|
|
1137 |
l = AknLayoutScalable_Apps::cam4_zoom_pane_g3(variant); // Knob
|
|
1138 |
area.LayoutRect(iSliderParentRect, l.LayoutLine() );
|
|
1139 |
TRect adj = iZoomPaneRect;
|
|
1140 |
adj.SetHeight( area.Rect().Height() );
|
|
1141 |
adj.Move( bottomRect.Center() - adj.Center() );
|
|
1142 |
AknIconUtils::SetSize( iIconZoomMarker[0], adj.Size() );
|
|
1143 |
AknIconUtils::SetSize( iIconZoomMarkerGray[0], adj.Size() );
|
|
1144 |
|
|
1145 |
}
|
|
1146 |
|
|
1147 |
// ---------------------------------------------------------
|
|
1148 |
// CCamZoomPane::NonTouchLayout
|
|
1149 |
// ---------------------------------------------------------
|
|
1150 |
void CCamZoomPane::NonTouchLayout()
|
|
1151 |
{
|
|
1152 |
TRect mainPaneRect;
|
|
1153 |
iMaxOffset = 0;
|
|
1154 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EApplicationWindow,
|
|
1155 |
mainPaneRect );
|
|
1156 |
mainPaneRect.Move( -mainPaneRect.iTl );
|
|
1157 |
|
|
1158 |
TInt variant = Layout_Meta_Data::IsLandscapeOrientation();
|
|
1159 |
|
|
1160 |
TAknWindowComponentLayout l = AknLayoutScalable_Apps::cam6_zoom_pane(variant);
|
|
1161 |
|
|
1162 |
TAknLayoutRect area;
|
|
1163 |
area.LayoutRect( mainPaneRect, l.LayoutLine() );
|
|
1164 |
iZoomPaneRect = area.Rect();
|
|
1165 |
|
|
1166 |
l = AknLayoutScalable_Apps::cam6_zoom_cont_pane(variant);
|
|
1167 |
area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
|
|
1168 |
iSliderParentRect = area.Rect();
|
|
1169 |
|
|
1170 |
l = AknLayoutScalable_Apps::cam6_zoom_pane_g1(variant); // +
|
|
1171 |
area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
|
|
1172 |
AknIconUtils::SetSize( iIconZoomMax[0], area.Rect().Size(),
|
|
1173 |
EAspectRatioNotPreserved );
|
|
1174 |
iPlusPoint = area.Rect().iTl;
|
|
1175 |
|
|
1176 |
l = AknLayoutScalable_Apps::cam6_zoom_pane_g2(variant); // -
|
|
1177 |
area.LayoutRect( iZoomPaneRect, l.LayoutLine() );
|
|
1178 |
AknIconUtils::SetSize( iIconZoomMin[0], area.Rect().Size(),
|
|
1179 |
EAspectRatioNotPreserved );
|
|
1180 |
iMinusPoint = area.Rect().iTl;
|
|
1181 |
|
|
1182 |
l = AknLayoutScalable_Apps::cam6_zoom_cont_pane_g1(variant); // Top
|
|
1183 |
area.LayoutRect( iSliderParentRect, l.LayoutLine() );
|
|
1184 |
AknIconUtils::SetSize( iIconZoomTop[0], area.Rect().Size(),
|
|
1185 |
EAspectRatioNotPreserved );
|
|
1186 |
iTopPoint = area.Rect().iTl;
|
|
1187 |
iMaxOffset += area.Rect().Height();
|
|
1188 |
|
|
1189 |
l = AknLayoutScalable_Apps::cam6_zoom_cont_pane_g3(variant); // Middle
|
|
1190 |
area.LayoutRect( iSliderParentRect, l.LayoutLine() );
|
|
1191 |
iIconZoomMiddle[0]->Resize( area.Rect().Size());
|
|
1192 |
AknIconUtils::SetSize( iIconZoomMiddle[0], area.Rect().Size(),
|
|
1193 |
EAspectRatioNotPreserved );
|
|
1194 |
iMiddlePoint = area.Rect().iTl;
|
|
1195 |
iMaxOffset += area.Rect().Height();
|
|
1196 |
|
|
1197 |
l = AknLayoutScalable_Apps::cam6_zoom_cont_pane_g2(variant); // Bottom
|
|
1198 |
area.LayoutRect( iSliderParentRect, l.LayoutLine() );
|
|
1199 |
AknIconUtils::SetSize( iIconZoomBottom[0], area.Rect().Size(),
|
|
1200 |
EAspectRatioNotPreserved );
|
|
1201 |
iBottomPoint = area.Rect().iTl;
|
|
1202 |
TRect bottomRect = area.Rect();
|
|
1203 |
iMaxOffset += area.Rect().Height();
|
|
1204 |
|
|
1205 |
l = AknLayoutScalable_Apps::cam6_zoom_pane_g3(variant); // Knob
|
|
1206 |
area.LayoutRect(iSliderParentRect, l.LayoutLine() );
|
|
1207 |
iZoomPaneRect.iTl.iX += area.Rect().Width()/2;
|
|
1208 |
AknIconUtils::SetSize( iIconZoomMarker[0], area.Rect().Size() );
|
|
1209 |
AknIconUtils::SetSize( iIconZoomMarkerGray[0], area.Rect().Size() );
|
|
1210 |
}
|
|
1211 |
|
|
1212 |
// ---------------------------------------------------------
|
|
1213 |
// CCamZoomPane::Touchfeedback
|
|
1214 |
// ---------------------------------------------------------
|
|
1215 |
//
|
|
1216 |
void CCamZoomPane::Touchfeedback()
|
|
1217 |
{
|
|
1218 |
PRINT( _L( "Camera => CCamZoomPane::Touchfeedback" ) );
|
|
1219 |
if ( iFeedback )
|
|
1220 |
{
|
|
1221 |
iFeedback->InstantFeedback( iRecordingVideo?
|
|
1222 |
ETouchFeedbackNone : ETouchFeedbackBasic );
|
|
1223 |
}
|
|
1224 |
PRINT( _L( "Camera <= CCamZoomPane::Touchfeedback" ) );
|
|
1225 |
}
|
|
1226 |
|
|
1227 |
// -----------------------------------------------------------------------------
|
|
1228 |
// CCamZoomPane::ZoomToMinimum
|
|
1229 |
// Zooms out to min zoom level. Should be stopped by StopZoom(), if needed
|
|
1230 |
// -----------------------------------------------------------------------------
|
|
1231 |
//
|
|
1232 |
void CCamZoomPane::ZoomToMinimum()
|
|
1233 |
{
|
|
1234 |
iModel->SetZoomMultiplier( KFastZoomMultiplier );
|
|
1235 |
iModel->ZoomOut();
|
|
1236 |
}
|
|
1237 |
|
|
1238 |
// -----------------------------------------------------------------------------
|
|
1239 |
// CCamZoomPane::ZoomToMaximum
|
|
1240 |
// Zooms in to max zoom level. Should be stopped by StopZoom(), if needed
|
|
1241 |
// -----------------------------------------------------------------------------
|
|
1242 |
//
|
|
1243 |
void CCamZoomPane::ZoomToMaximum()
|
|
1244 |
{
|
|
1245 |
iModel->SetZoomMultiplier( KFastZoomMultiplier );
|
|
1246 |
iModel->ZoomIn();
|
|
1247 |
}
|
|
1248 |
|
|
1249 |
// End of File
|