1 /* |
|
2 * Copyright (c) 2007-2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Class for Camera Zoom Pane* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 #ifndef CAMZOOMPANE_H |
|
20 #define CAMZOOMPANE_H |
|
21 |
|
22 // INCLUDES |
|
23 #include <coecntrl.h> |
|
24 #include <eiklabel.h> |
|
25 #include <AknUtils.h> // for TAknLayout |
|
26 #include "CamPSI.h" // For Product Specific Information |
|
27 #include "CamAppController.h" // For controller definition |
|
28 #include "CamSettings.hrh" // For TCamPhotoSizeId |
|
29 #include "CamSettingsInternal.hrh" |
|
30 #include "CamResourceLoader.h" |
|
31 #include "CamZoomModel.h" |
|
32 #include "CamBmpRotatorAo.h" |
|
33 |
|
34 // CONSTANTS |
|
35 |
|
36 // MACROS |
|
37 |
|
38 // DATA TYPES |
|
39 |
|
40 // FUNCTION PROTOTYPES |
|
41 |
|
42 // FORWARD DECLARATIONS |
|
43 class CCamRemConObserver; |
|
44 class MTouchFeedback; |
|
45 |
|
46 // CLASS DECLARATION |
|
47 |
|
48 /** |
|
49 * Class for showing the current zoom level in a side pane. |
|
50 * |
|
51 * @since 2.8 |
|
52 */ |
|
53 class CCamZoomPane : public CBase, |
|
54 public MCamControllerObserver, |
|
55 public MCamResourceLoader |
|
56 { |
|
57 // Private data type used internally by the zoom pane |
|
58 // to store the orientation it should be drawn |
|
59 enum TZPOrientation |
|
60 { |
|
61 EZPOrientationVertical = 0, |
|
62 EZPOrientationHorizontal = 1 |
|
63 }; |
|
64 |
|
65 public: // Constructors and destructor |
|
66 |
|
67 /** |
|
68 * Two-phased constructor. |
|
69 * @param aController handle to camera application controller |
|
70 * @param aOverlayViewFinder whether zoom pane is drawn over view finder |
|
71 */ |
|
72 static CCamZoomPane* NewL( CCamAppController& aController, |
|
73 TBool aOverlayViewFinder ); |
|
74 |
|
75 /** |
|
76 * Destructor. |
|
77 */ |
|
78 virtual ~CCamZoomPane(); |
|
79 |
|
80 public: // From MCamResourceLoader |
|
81 /** |
|
82 * From MCamResourceLoader |
|
83 * @since 3.0 |
|
84 */ |
|
85 void LoadResourceDataL(); |
|
86 |
|
87 /** |
|
88 * From MCamResourceLoader |
|
89 * @since 3.0 |
|
90 */ |
|
91 void UnloadResourceData(); |
|
92 |
|
93 /** |
|
94 * From MCamResourceLoader |
|
95 * @since 3.0 |
|
96 */ |
|
97 void ReloadResourceDataL(); |
|
98 |
|
99 public: // New functions |
|
100 /** |
|
101 * Sets the range of values to be represented on the Zoom Pane "shaft". |
|
102 * These values should be retrieved from the CCaeEngine |
|
103 * @since 2.8 |
|
104 * @param aMin The minimum supported value (typically zero) |
|
105 * @param aMax The maximum supported value (one or more) |
|
106 * @return KErrNone if parameters are valid, else KErrArgument |
|
107 */ |
|
108 TInt SetZoomRange( TInt aMin, TInt aMax ); |
|
109 |
|
110 /** |
|
111 * Sets the current zoom level. Must be within (inclusive) range passed |
|
112 * to the SetZoomRange function. |
|
113 * @since 2.8 |
|
114 * @param aZoom New zoom value to use. |
|
115 * @return KErrNone if parameter valid, else KErrArgument |
|
116 */ |
|
117 TInt SetZoomValue( TInt aZoom ); |
|
118 |
|
119 /** |
|
120 * Sets the keys to be intepreted as zoom keys |
|
121 * @since 3.0 |
|
122 * @param aZoomIn Zoom in key scancode |
|
123 * @param aZoomOut Zoom out key scancode |
|
124 */ |
|
125 void SetZoomKeys( const RArray<TInt>& aZoomIn, |
|
126 const RArray<TInt>& aZoomOut ); |
|
127 |
|
128 /** |
|
129 * Gets the current zoom step |
|
130 * @since 2.8 |
|
131 * @returns The current zoom step |
|
132 */ |
|
133 TInt ZoomValue() const; |
|
134 |
|
135 /** |
|
136 * Returns whether or not the Zoom Pane can currently be shown. |
|
137 * @since 2.8 |
|
138 * @return ETrue if the Zoom Pane is allowed to be shown, else EFalse |
|
139 */ |
|
140 TBool OkToShowPane() const; |
|
141 |
|
142 /** |
|
143 * Is the zoom pane is visible |
|
144 * @since 2.8 |
|
145 * @return ETrue if the zoom pane is visible |
|
146 */ |
|
147 TBool IsVisible() const; |
|
148 |
|
149 /** |
|
150 * Tells the zoom pane whether it is on display |
|
151 * @since 2.8 |
|
152 * @param aVisible ETrue to make the zoom pane invisible |
|
153 * @param aRedraw Whether to force a redraw event |
|
154 */ |
|
155 void MakeVisible( TBool aVisible, TBool aRedraw ); |
|
156 |
|
157 /** |
|
158 * Draws the zoom pane |
|
159 * @since 2.8 |
|
160 * @param aGc The graphics context to use for drawing |
|
161 */ |
|
162 void Draw( CBitmapContext& aGc ) const; |
|
163 |
|
164 /** |
|
165 * Set draw rect |
|
166 * @since 2.8 |
|
167 * @param aRect Rect zoom pane draws into |
|
168 */ |
|
169 void SetRect( TRect aRect ); |
|
170 |
|
171 /** |
|
172 * Handles zoom-key operation, passed in from the container. |
|
173 * @since 2.8 |
|
174 * @param aKeyEvent The key event |
|
175 * @param aType the key type |
|
176 * @return Whether this key event was consumed or not |
|
177 */ |
|
178 TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ); |
|
179 |
|
180 /** |
|
181 * Returns the zoom pane rect |
|
182 * @since 3.0 |
|
183 * @return the zoom pane rect |
|
184 */ |
|
185 TRect Rect() const; |
|
186 |
|
187 /** |
|
188 * Called when the parent gains or loses foreground |
|
189 * @param aForeground ETrue if gained foreground, else EFalse |
|
190 * @since 3.0 |
|
191 */ |
|
192 void HandleForegroundEvent( TBool aForeground ); |
|
193 |
|
194 /** |
|
195 * Sets the number of zoom steps for each type of zoom to be |
|
196 * reflected in the zoom pane shaft |
|
197 * @param aOptSteps The number of optical zoom steps |
|
198 * @param aStdSteps The number of digital zoom steps |
|
199 * @param aExtSteps The number of extended digital zoom steps |
|
200 * @since 3.0 |
|
201 */ |
|
202 void SetZoomSteps( TInt aOptSteps, TInt aStdSteps, TInt aExtSteps ); |
|
203 |
|
204 /** |
|
205 * Returns whether there is currently an ongoing zoom operation. |
|
206 * @since 3.0 |
|
207 * @return ETrue if zooming, else EFalse |
|
208 */ |
|
209 TBool IsCurrentlyZooming() const; |
|
210 |
|
211 /** |
|
212 * Indicates that the zoom level should be reset to default |
|
213 * when the engine is next prepared |
|
214 * @since 2.8 |
|
215 * @param aReset ETrue if the zoom pane should be reset, else EFalse |
|
216 */ |
|
217 void ResetToDefaultAfterPrepare( TBool aReset ); |
|
218 |
|
219 /** |
|
220 * Indicates whether or not the zoom level is waiting to be reset to default |
|
221 * @since 3.0 |
|
222 * @return TBool ETrue if a reset is pending, othewise EFalse |
|
223 */ |
|
224 TBool IsResetPending() const; |
|
225 |
|
226 /** |
|
227 * Sets a point position to be based on another point plus an optional offset. |
|
228 * Used for moving along the slider. Whether the X or Y part of the point |
|
229 * changes is dependent on the current orientation |
|
230 * @since 3.0 |
|
231 * @param aPoint This point will be overwritten with the new X/Y values |
|
232 * @param aOffset This is the basis for the new value for 'aPoint' |
|
233 * @param aAddditional This is an additional modification to 'aOffset' value |
|
234 */ |
|
235 void SetPoint( TPoint& aPoint, const TPoint& aOffset, TInt aAdditional = 0) const; |
|
236 |
|
237 /** |
|
238 * Returns whether the current zoom value is the minimum zoom |
|
239 * @since 3.1 |
|
240 * @return Whether the current zoom value is the minimum zoom |
|
241 */ |
|
242 TBool IsZoomAtMinimum() const; |
|
243 |
|
244 /** |
|
245 * Stops all zooming activity |
|
246 */ |
|
247 void StopZoom(); |
|
248 |
|
249 /*** |
|
250 * Resets the zoom (digital, and, if available, optical) to 1x |
|
251 * @since 3.0 |
|
252 */ |
|
253 void ResetZoomTo1x(); |
|
254 |
|
255 /*** |
|
256 * Handle pointer events |
|
257 * @since S60 v5.0 |
|
258 * @param TPointerEvent, pointer event |
|
259 * @return TBool, ETrue if the pointer event was used |
|
260 */ |
|
261 TBool HandlePointerEventL( const TPointerEvent& aPointerEvent ); |
|
262 |
|
263 /*** |
|
264 * Handle pointer events |
|
265 * @since S60 v5.0 |
|
266 * @param TInt, Pointer's Y-position |
|
267 * @return TBool, ETrue if the pointer event was used |
|
268 */ |
|
269 TBool StartTouchZoomL( TInt aPointer ); |
|
270 |
|
271 |
|
272 |
|
273 public: // Functions from base classes |
|
274 protected: // New functions |
|
275 protected: // Functions from CCoeControl |
|
276 |
|
277 /** |
|
278 * Handles events from the controller |
|
279 * @since 2.8 |
|
280 * @param aEvent The controller event that has occurred |
|
281 * @param aError An associated error code |
|
282 */ |
|
283 void HandleControllerEventL( TCamControllerEvent aEvent, TInt aError ); |
|
284 |
|
285 protected: // Functions from base classes |
|
286 private: |
|
287 |
|
288 /** |
|
289 * C++ default constructor. |
|
290 * since 2.8 |
|
291 * @param aRect parent rect |
|
292 * @param aController handle to camera application controller |
|
293 * @param aOverlayViewFinder whether zoom pane is drawn over view finder |
|
294 */ |
|
295 CCamZoomPane( CCamAppController& aController, |
|
296 TBool aOverlayViewFinder ); |
|
297 |
|
298 /** |
|
299 * By default Symbian 2nd phase constructor is private. |
|
300 */ |
|
301 void ConstructL(); |
|
302 |
|
303 /** |
|
304 * Reads layout information from a resource |
|
305 * @since 2.8 |
|
306 */ |
|
307 void ReadLayoutL(); |
|
308 |
|
309 /** |
|
310 * Updates Layout and size of control |
|
311 * @since S60 5.0 |
|
312 */ |
|
313 void SizeChanged(); |
|
314 |
|
315 /** |
|
316 * Draws the thumb on the zoom pane |
|
317 * @since 3.0 |
|
318 * @param aGc The graphics context to draw to |
|
319 */ |
|
320 void DrawThumb( CBitmapContext& aGc ) const; |
|
321 |
|
322 /** |
|
323 * Draws the shaft of the zoom pane |
|
324 * @since 3.0 |
|
325 * @param aGc The graphics context to draw to |
|
326 */ |
|
327 void DrawShaft( CBitmapContext& aGc ) const; |
|
328 |
|
329 /** |
|
330 * Draws the plus/minus icons for the zoom pane |
|
331 * @since 3.0 |
|
332 * @param aGc The graphics context to draw to |
|
333 */ |
|
334 void DrawPlusMinus( CBitmapContext& aGc ) const; |
|
335 |
|
336 /** |
|
337 * Returns the current Zoom Pane orientation based on stored |
|
338 * settings and whether the current camera supports horizontal zoom bar |
|
339 * @since 3.0 |
|
340 * @return The orientation (veritcal or horizontal) |
|
341 */ |
|
342 TZPOrientation PaneOrientation() const; |
|
343 |
|
344 /** |
|
345 * Read nontouch layout |
|
346 */ |
|
347 void TouchLayout(); |
|
348 |
|
349 /** |
|
350 * Read touch layout |
|
351 */ |
|
352 void NonTouchLayout(); |
|
353 |
|
354 /* |
|
355 * Reads zoom keys from the appropriate array |
|
356 */ |
|
357 void ReadZoomKeys( const RArray<TInt>& aSource, |
|
358 RArray<TInt>& aTarget ); |
|
359 /* |
|
360 * Checks for the zoom key with the mapped key's scan code |
|
361 */ |
|
362 TBool CheckForZoomKey( const TKeyEvent& aKeyEvent, |
|
363 const RArray<TInt>& aKeys ); |
|
364 |
|
365 /** |
|
366 * Touchfeedback |
|
367 * @since S60 v5.0 |
|
368 */ |
|
369 void Touchfeedback(); |
|
370 |
|
371 public: // Data |
|
372 |
|
373 protected: // Data |
|
374 |
|
375 private: // Data |
|
376 |
|
377 // The bitmaps for the graphical components. |
|
378 CFbsBitmap* iIconZoomTop[2]; |
|
379 CFbsBitmap* iIconZoomMiddle[2]; |
|
380 CFbsBitmap* iIconZoomBottom[2]; |
|
381 CFbsBitmap* iIconZoomMarker[2]; |
|
382 CFbsBitmap* iIconZoomMarkerGray[2]; |
|
383 CFbsBitmap* iIconZoomMin[2]; |
|
384 CFbsBitmap* iIconZoomMax[2]; |
|
385 CFbsBitmap* iIconZoomMarkerCurrent; |
|
386 |
|
387 TRect iZoomPaneRect; |
|
388 TRect iSliderParentRect; |
|
389 TPoint iPlusPoint; |
|
390 TPoint iMinusPoint; |
|
391 TPoint iTopPoint; |
|
392 TPoint iMiddlePoint; |
|
393 TPoint iBottomPoint; |
|
394 |
|
395 //Holds the maximum 'travel' of the thumb along the slider |
|
396 TInt iMaxOffset; |
|
397 |
|
398 // Minimum supported zoom level |
|
399 TInt iMinZoom; |
|
400 |
|
401 // Maximum supported zoom level |
|
402 TInt iMaxZoom; |
|
403 |
|
404 // Actual zoom level |
|
405 TInt iCurZoom; |
|
406 |
|
407 // Targeted zoom level to be indicated by the thumb |
|
408 TInt iTrgZoom; |
|
409 |
|
410 // Previous pointer Y-position |
|
411 TInt iPointerPrevi; |
|
412 |
|
413 // Whether we are currently recording video or not. |
|
414 TBool iRecordingVideo; |
|
415 |
|
416 // Reference to the Controller |
|
417 CCamAppController& iController; |
|
418 |
|
419 // Represents a bitmask of TCamVideoZoom for video zoom features |
|
420 TInt iZoomSupport; |
|
421 |
|
422 // Determine from PSI if zoom pane are overlaid on VF |
|
423 TBool iOverlayViewFinder; |
|
424 |
|
425 // is the zoom pane visible |
|
426 TBool iVisible; |
|
427 |
|
428 // Determine whether or not touch is active |
|
429 TBool iTouchActive; |
|
430 |
|
431 // The current engine state, updated if it changes |
|
432 TCamCameraState iCameraState; |
|
433 |
|
434 // The zoom model, owned by this control |
|
435 CCamZoomModel* iModel; |
|
436 |
|
437 // The number of key repeats received in a row. |
|
438 TInt iRepeatCounter; |
|
439 |
|
440 // The optical, digital and extended zoom steps to be shown on the zoom bar |
|
441 TInt iOptSteps; |
|
442 TInt iStdSteps; |
|
443 TInt iExtSteps; |
|
444 |
|
445 // Stores the look and feel info of the zoom bar |
|
446 TCamZoomLAF iZoomLAF; |
|
447 |
|
448 // Stores the orientation of the zoom pane (vertical or horizontal) |
|
449 // as read from the Central Repository |
|
450 TZPOrientation iOrientation; |
|
451 |
|
452 // Whether or not product uses volume keys for zoom |
|
453 TBool iZoomUsingVolumeKeys; |
|
454 |
|
455 // Whether or not product uses navi-key left and right for zoom |
|
456 TBool iZoomUsingNaviKeys; |
|
457 |
|
458 // Performs zoom frame/thumb bitmap rotation when needed |
|
459 CCamBmpRotatorAo* iRotatorAo; |
|
460 |
|
461 // Timer used to remove zoom pane after a short delay |
|
462 CCamTimer* iZoomTimer; |
|
463 MTouchFeedback* iFeedback; // Not own |
|
464 |
|
465 // observer to receive volume key presses |
|
466 CCamRemConObserver* iVolumeKeyObserver; |
|
467 |
|
468 RArray<TInt> iZoomInKeys; |
|
469 RArray<TInt> iZoomOutKeys; |
|
470 }; |
|
471 |
|
472 #endif // CAMZOOMPANE_H |
|
473 |
|
474 // End of File |
|