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: Class for showing quality slider* |
|
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 <AknsDrawUtils.h> |
|
30 #include <gscamerapluginrsc.rsg> |
|
31 #include <aknlayoutscalable_apps.cdl.h> |
|
32 #include "GSCamQualitySettingSlider.h" |
|
33 #include "CamPanic.h" // Panic codes |
|
34 #include "CamUtility.h" |
|
35 #include "CamPSI.h" |
|
36 |
|
37 #include "camconfiguration.h" |
|
38 |
|
39 // CONSTANTS |
|
40 |
|
41 const TInt KDivisorFactor = 1024; // Avoids using TReal maths, use factor of 2 |
|
42 |
|
43 const TInt KMinQuality = 0; |
|
44 const TInt KMaxBackCameraPhotoQuality = 4; // Can be 3 or 5 steps => 2 or 4 |
|
45 const TInt KMaxBackCameraVideoQuality = 4; |
|
46 |
|
47 // Image quality value indexes |
|
48 const TInt KImageQualityHigh = 0; |
|
49 const TInt KImageQualityMedium = 1; |
|
50 const TInt KImageQualityLow = 2; |
|
51 const TInt KImageQualityLower = 3; |
|
52 const TInt KImageQualityLowest = 4; |
|
53 |
|
54 // Video quality value indexes |
|
55 const TInt KVideoQualityTVHigh = 0; |
|
56 const TInt KVideoQualityWide = 1; |
|
57 const TInt KVideoQualityEmailHigh = 2; |
|
58 const TInt KVideoQualityEmailNormal = 3; |
|
59 const TInt KVideoQualitySharing = 4; |
|
60 |
|
61 // Video quality type indexes |
|
62 const TInt KVideoQualityTVHighType = 5; |
|
63 const TInt KVideoQualityWideType = 6; |
|
64 const TInt KVideoQualityEmailHighType = 7; |
|
65 const TInt KVideoQualityEmailNormalType = 8; |
|
66 const TInt KVideoQualitySharingType = 9; |
|
67 |
|
68 // ============================ MEMBER FUNCTIONS =============================== |
|
69 |
|
70 // --------------------------------------------------------- |
|
71 // CCamSliderLegend::~CCamSliderLegend |
|
72 // destructor |
|
73 // --------------------------------------------------------- |
|
74 // |
|
75 CCamSliderLegend::~CCamSliderLegend() |
|
76 { |
|
77 delete iText; |
|
78 delete iBitmap; |
|
79 delete iMask; |
|
80 } |
|
81 |
|
82 // --------------------------------------------------------- |
|
83 // CCamSliderLegend::Draw |
|
84 // Draws the legend |
|
85 // --------------------------------------------------------- |
|
86 // |
|
87 void CCamSliderLegend::Draw( CWindowGc& aGc ) const |
|
88 { |
|
89 if ( iItem == ECamSliderLegendItemText ) |
|
90 { |
|
91 TRgb color; |
|
92 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
93 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, |
|
94 EAknsCIQsnTextColorsCG6 ); |
|
95 |
|
96 iPosition.DrawText( aGc, iText->Des(), ETrue, color ); |
|
97 } |
|
98 else |
|
99 { |
|
100 iIconRect.DrawImage( aGc, iBitmap, iMask ); |
|
101 } |
|
102 } |
|
103 |
|
104 // --------------------------------------------------------- |
|
105 // CCamSliderLegend::Rect |
|
106 // Returns the legend rect |
|
107 // --------------------------------------------------------- |
|
108 // |
|
109 TRect CCamSliderLegend::Rect() const |
|
110 { |
|
111 if ( iItem == ECamSliderLegendItemText ) |
|
112 { |
|
113 return iPosition.TextRect(); |
|
114 } |
|
115 else |
|
116 { |
|
117 return iIconRect.Rect(); |
|
118 } |
|
119 } |
|
120 |
|
121 |
|
122 // --------------------------------------------------------- |
|
123 // CCamSliderLegend::ConstructL |
|
124 // Constructs the layout entry |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 void CCamSliderLegend::ConstructL( const TAknLayoutRect& aLayoutRect, |
|
128 TInt aBitmap, TInt aMask ) |
|
129 { |
|
130 TFileName resFileName; |
|
131 CamUtility::ResourceFileName( resFileName ); |
|
132 TPtrC resname = resFileName; |
|
133 |
|
134 iItem = ECamSliderLegendItemIcon; |
|
135 iIconRect = aLayoutRect; |
|
136 |
|
137 AknIconUtils::CreateIconL( iBitmap, iMask, resname, aBitmap, aMask ); |
|
138 AknIconUtils::SetSize( iBitmap, iIconRect.Rect().Size() ); |
|
139 } |
|
140 |
|
141 // ----------------------------------------------------------------------------- |
|
142 // CGSCamQualitySettingSlider::CGSCamQualitySettingSlider |
|
143 // C++ default constructor can NOT contain any code, that |
|
144 // might leave. |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 CGSCamQualitySettingSlider::CGSCamQualitySettingSlider( |
|
148 MCamSettingValueObserver* aObserver, TCamSettingItemIds aSettingType, |
|
149 TInt aSteps, CCamConfiguration* aConfiguration ) : |
|
150 iSettingObserver( aObserver ), iSettingType( aSettingType ), |
|
151 iSteps( aSteps ), iConfiguration ( aConfiguration ) |
|
152 { |
|
153 switch ( iSettingType ) |
|
154 { |
|
155 case ECamSettingItemPhotoQuality: |
|
156 { |
|
157 if( CamUtility::GetCommonPsiInt( |
|
158 ECamPsiNumberSupportedStillQualities, iMaxSliderValue) != |
|
159 KErrNone ) |
|
160 { |
|
161 iMaxSliderValue = KMaxBackCameraPhotoQuality; |
|
162 } |
|
163 iMinSliderValue = KMinQuality; |
|
164 iNumSliderValues = iMaxSliderValue + 1; |
|
165 } |
|
166 break; |
|
167 |
|
168 case ECamSettingItemVideoQuality: |
|
169 { |
|
170 if( CamUtility::GetCommonPsiInt( |
|
171 ECamPsiNumberSupportedVideoQualities, iMaxSliderValue) != |
|
172 KErrNone ) |
|
173 { |
|
174 iMaxSliderValue = KMaxBackCameraVideoQuality; |
|
175 } |
|
176 iMinSliderValue = KMinQuality; |
|
177 iNumSliderValues = iMaxSliderValue + 1; |
|
178 } |
|
179 break; |
|
180 default: |
|
181 { |
|
182 } |
|
183 break; |
|
184 } |
|
185 |
|
186 // Prefill iBitmapShafts and iBitmapShaftMasks with NULL |
|
187 for ( TInt i = 0; i <= BITMAP_SHAFT_MAX_DIVISIONS; i++) |
|
188 { |
|
189 iBitmapShafts[i] = static_cast<CFbsBitmap*>(NULL); |
|
190 iBitmapShaftsMasks[i] = static_cast<CFbsBitmap*>(NULL); |
|
191 } |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CGSCamQualitySettingSlider::ConstructL |
|
196 // Symbian 2nd phase constructor can leave. |
|
197 // ----------------------------------------------------------------------------- |
|
198 // |
|
199 void CGSCamQualitySettingSlider::ConstructL( const CCoeControl* aParent ) |
|
200 { |
|
201 __ASSERT_DEBUG( aParent!=NULL, CamPanic( ECamPanicNullPointer ) ); |
|
202 |
|
203 iParentControl = aParent; |
|
204 SetContainerWindowL( *iParentControl ); |
|
205 |
|
206 TFileName resFileName; |
|
207 CamUtility::ResourceFileName( resFileName ); |
|
208 TPtrC resname = resFileName; |
|
209 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
210 |
|
211 if ( IsThreeTicksSlider() ) |
|
212 { |
|
213 // Create component bitmaps |
|
214 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafNsliderCam4Image1, |
|
215 iBitmapShafts[KImageQualityHigh], |
|
216 iBitmapShaftsMasks[KImageQualityHigh], |
|
217 resname, |
|
218 EMbmCameraappQgn_graf_nslider_cam4_image_1, |
|
219 EMbmCameraappQgn_graf_nslider_cam4_image_1_mask ); |
|
220 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafNsliderCam4Image2, |
|
221 iBitmapShafts[KImageQualityMedium], |
|
222 iBitmapShaftsMasks[KImageQualityMedium], |
|
223 resname, |
|
224 EMbmCameraappQgn_graf_nslider_cam4_image_2, |
|
225 EMbmCameraappQgn_graf_nslider_cam4_image_2_mask ); |
|
226 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafNsliderCam4Image3, |
|
227 iBitmapShafts[KImageQualityLow], |
|
228 iBitmapShaftsMasks[KImageQualityLow], |
|
229 resname, |
|
230 EMbmCameraappQgn_graf_nslider_cam4_image_3, |
|
231 EMbmCameraappQgn_graf_nslider_cam4_image_3_mask ); |
|
232 } |
|
233 else // iSettingType == ECamSettingItemVideoQuality |
|
234 { |
|
235 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafNsliderCam4Video1, |
|
236 iBitmapShafts[KVideoQualityTVHigh], |
|
237 iBitmapShaftsMasks[KVideoQualityTVHigh], |
|
238 resname, |
|
239 EMbmCameraappQgn_graf_nslider_cam4_video_1, |
|
240 EMbmCameraappQgn_graf_nslider_cam4_video_1_mask ); |
|
241 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafNsliderCam4Video2, |
|
242 iBitmapShafts[KVideoQualityWide], |
|
243 iBitmapShaftsMasks[KVideoQualityWide], |
|
244 resname, |
|
245 EMbmCameraappQgn_graf_nslider_cam4_video_2, |
|
246 EMbmCameraappQgn_graf_nslider_cam4_video_2_mask ); |
|
247 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafNsliderCam4Video3, |
|
248 iBitmapShafts[KVideoQualityEmailHigh], |
|
249 iBitmapShaftsMasks[KVideoQualityEmailHigh], |
|
250 resname, |
|
251 EMbmCameraappQgn_graf_nslider_cam4_video_3, |
|
252 EMbmCameraappQgn_graf_nslider_cam4_video_3_mask ); |
|
253 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafNsliderCam4Video4, |
|
254 iBitmapShafts[KVideoQualityEmailNormal], |
|
255 iBitmapShaftsMasks[KVideoQualityEmailNormal], |
|
256 resname, |
|
257 EMbmCameraappQgn_graf_nslider_cam4_video_4, |
|
258 EMbmCameraappQgn_graf_nslider_cam4_video_4_mask ); |
|
259 AknsUtils::CreateIconL( skin, KAknsIIDQgnGrafNsliderCam4Video5, |
|
260 iBitmapShafts[KVideoQualitySharing], |
|
261 iBitmapShaftsMasks[KVideoQualitySharing], |
|
262 resname, |
|
263 EMbmCameraappQgn_graf_nslider_cam4_video_5, |
|
264 EMbmCameraappQgn_graf_nslider_cam4_video_5_mask ); |
|
265 } |
|
266 } |
|
267 |
|
268 // ----------------------------------------------------------------------------- |
|
269 // CGSCamQualitySettingSlider::NewL |
|
270 // Two-phased constructor. |
|
271 // ----------------------------------------------------------------------------- |
|
272 // |
|
273 CGSCamQualitySettingSlider* CGSCamQualitySettingSlider::NewL( |
|
274 const CCoeControl* aParent, |
|
275 MCamSettingValueObserver* aObserver, |
|
276 TCamSettingItemIds aSettingItem, |
|
277 TInt aSteps, |
|
278 CCamConfiguration* aConfiguration ) |
|
279 { |
|
280 CGSCamQualitySettingSlider* self = |
|
281 new( ELeave ) CGSCamQualitySettingSlider( aObserver, aSettingItem, |
|
282 aSteps, aConfiguration); |
|
283 CleanupStack::PushL( self ); |
|
284 self->ConstructL( aParent ); |
|
285 CleanupStack::Pop( self ); |
|
286 self->iConfiguration = aConfiguration; |
|
287 return self; |
|
288 } |
|
289 |
|
290 // ----------------------------------------------------------------------------- |
|
291 // CGSCamQualitySettingSlider::~CGSCamQualitySettingSlider |
|
292 // Destructor |
|
293 // ----------------------------------------------------------------------------- |
|
294 // |
|
295 CGSCamQualitySettingSlider::~CGSCamQualitySettingSlider() |
|
296 { |
|
297 for ( TInt i = 0; i <= BITMAP_SHAFT_MAX_DIVISIONS; i++) |
|
298 { |
|
299 delete iBitmapShafts[i]; |
|
300 delete iBitmapShaftsMasks[i]; |
|
301 } |
|
302 |
|
303 // Destroy legend strings |
|
304 iLegendArray.ResetAndDestroy(); |
|
305 } |
|
306 |
|
307 // ----------------------------------------------------------------------------- |
|
308 // CGSCamQualitySettingSlider::InitializeL |
|
309 // Sets up the slider with the initial value |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 void CGSCamQualitySettingSlider::InitializeL( TInt aValue, |
|
313 HBufC* aTopSubtitle, |
|
314 HBufC* aBottomSubtitle ) |
|
315 { |
|
316 // Check the initial value is valid. If no, leave. |
|
317 if ( aValue < iMinSliderValue || |
|
318 aValue > iMaxSliderValue ) |
|
319 { |
|
320 PRINT3( _L("Camera <> CGSCamQualitySettingSlider::InitializeL - illegal value: %d (min %d, max %d)" ), |
|
321 aValue, iMinSliderValue, iMaxSliderValue ); |
|
322 User::Leave( KErrArgument ); |
|
323 } |
|
324 |
|
325 iValue = aValue; |
|
326 iTopSubtitle = aTopSubtitle; |
|
327 iBottomSubtitle = aBottomSubtitle; |
|
328 } |
|
329 |
|
330 // ----------------------------------------------------------------------------- |
|
331 // CGSCamQualitySettingSlider::MinValue |
|
332 // Returns the minimum slider value |
|
333 // ----------------------------------------------------------------------------- |
|
334 // |
|
335 TInt CGSCamQualitySettingSlider::MinValue() const |
|
336 { |
|
337 return iMinSliderValue; |
|
338 } |
|
339 |
|
340 // ----------------------------------------------------------------------------- |
|
341 // CGSCamQualitySettingSlider::MaxValue |
|
342 // Returns the maximum slider value |
|
343 // ----------------------------------------------------------------------------- |
|
344 // |
|
345 TInt CGSCamQualitySettingSlider::MaxValue() const |
|
346 { |
|
347 return iMaxSliderValue; |
|
348 } |
|
349 |
|
350 |
|
351 // ----------------------------------------------------------------------------- |
|
352 // CGSCamQualitySettingSlider::SetRange |
|
353 // Sets the minimum and maximum values of the slider control |
|
354 // ----------------------------------------------------------------------------- |
|
355 // |
|
356 void CGSCamQualitySettingSlider::SetRange( TInt aMin, TInt aMax ) |
|
357 { |
|
358 ASSERT( aMin < aMax ); |
|
359 iMinSliderValue = aMin; |
|
360 iMaxSliderValue = aMax; |
|
361 iNumSliderValues = iMaxSliderValue + 1; |
|
362 } |
|
363 |
|
364 |
|
365 // ----------------------------------------------------------------------------- |
|
366 // CGSCamQualitySettingSlider::Draw |
|
367 // Draws the slider |
|
368 // ----------------------------------------------------------------------------- |
|
369 // |
|
370 void CGSCamQualitySettingSlider::Draw( const TRect& /*aRect*/ ) const |
|
371 { |
|
372 CFbsBitmap* shaft; |
|
373 CFbsBitmap* shaftMask; |
|
374 CWindowGc& gc = SystemGc(); |
|
375 TRgb color; |
|
376 |
|
377 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
378 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, |
|
379 EAknsCIQsnTextColorsCG6 ); |
|
380 |
|
381 MAknsControlContext *cc = AknsDrawUtils::ControlContext( iParentControl ); |
|
382 //AknsDrawUtils::Background( skin, cc, iParentControl, gc, Rect() ); |
|
383 |
|
384 // draw top and bottom subtitles |
|
385 iLayoutSubtitleTop.DrawText( gc, iTopSubtitle->Des(), ETrue, color ); |
|
386 iLayoutSubtitleBottom.DrawText( gc, iBottomSubtitle->Des(), ETrue, color ); |
|
387 |
|
388 // Draw the legend icons |
|
389 TInt count = iLegendArray.Count(); |
|
390 TInt i = 0; |
|
391 for ( i = 0; i < count; i++ ) |
|
392 { |
|
393 iLegendArray[i]->Draw( gc ); |
|
394 } |
|
395 |
|
396 // the quality slider has a different shaft icon for each slider value |
|
397 if ( iMaxSliderValue <= BITMAP_SHAFT_MAX_DIVISIONS |
|
398 && iValue <= BITMAP_SHAFT_MAX_DIVISIONS |
|
399 && iMaxSliderValue >= 0 |
|
400 && iValue >= 0 ) |
|
401 { |
|
402 shaft = iBitmapShafts[iValue]; |
|
403 shaftMask = iBitmapShaftsMasks[iValue]; |
|
404 } |
|
405 else |
|
406 { |
|
407 shaft = NULL; |
|
408 } |
|
409 |
|
410 // Draw the shaft bitmap |
|
411 if ( shaft ) |
|
412 { |
|
413 iShaftLayout.DrawImage( gc, shaft, shaftMask ); |
|
414 } |
|
415 } |
|
416 |
|
417 |
|
418 // --------------------------------------------------------- |
|
419 // CGSCamQualitySettingSlider::SizeChanged |
|
420 // Calculates the new minimum size |
|
421 // --------------------------------------------------------- |
|
422 // |
|
423 void CGSCamQualitySettingSlider::SizeChanged() |
|
424 { |
|
425 TRAPD( ignore, ReadLayoutL() ); |
|
426 if ( ignore ) |
|
427 { |
|
428 // Do nothing ( removes build warning ) |
|
429 } |
|
430 |
|
431 // Work out the minimum size |
|
432 TInt count = iLegendArray.Count(); |
|
433 |
|
434 TRect minimumRect; |
|
435 |
|
436 // Start min rect as first legend text |
|
437 if ( count > 0 ) |
|
438 { |
|
439 minimumRect = iLegendArray[0]->Rect(); |
|
440 } |
|
441 |
|
442 // Take into account the other legend texts |
|
443 TInt i; |
|
444 for ( i = 1; i < count; i++ ) |
|
445 { |
|
446 minimumRect.BoundingRect( iLegendArray[i]->Rect() ); |
|
447 } |
|
448 |
|
449 // Take into account the shaft bitmap |
|
450 minimumRect.BoundingRect( iShaftLayout.Rect() ); |
|
451 |
|
452 iMinimumSize = minimumRect.Size(); |
|
453 } |
|
454 |
|
455 |
|
456 // ----------------------------------------------------------------------------- |
|
457 // CGSCamQualitySettingSlider::OfferKeyEventL |
|
458 // Allows the user to change the current EV value via key presses. |
|
459 // ----------------------------------------------------------------------------- |
|
460 // |
|
461 TKeyResponse CGSCamQualitySettingSlider::OfferKeyEventL( |
|
462 const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
463 { |
|
464 if ( aType == EEventKey ) |
|
465 { |
|
466 if ( aKeyEvent.iScanCode == EStdKeyUpArrow ) |
|
467 { |
|
468 if ( iValue < iMaxSliderValue ) |
|
469 { |
|
470 iValue ++; |
|
471 // Tell observer about change |
|
472 iSettingObserver->HandleSettingValueUpdateL( iValue ); |
|
473 DrawNow(); |
|
474 } |
|
475 |
|
476 return EKeyWasConsumed; |
|
477 } |
|
478 else if ( aKeyEvent.iScanCode == EStdKeyDownArrow ) |
|
479 { |
|
480 if ( iValue > iMinSliderValue ) |
|
481 { |
|
482 iValue --; |
|
483 // Tell observer about change |
|
484 iSettingObserver->HandleSettingValueUpdateL( iValue ); |
|
485 DrawNow(); |
|
486 } |
|
487 |
|
488 return EKeyWasConsumed; |
|
489 } |
|
490 else if ( aKeyEvent.iCode == EKeyOK && aKeyEvent.iRepeats == 0 ) |
|
491 { |
|
492 return EKeyWasConsumed; |
|
493 } |
|
494 // No allowing left and right key events thansfer to other view. |
|
495 else if( aKeyEvent.iScanCode == EStdKeyLeftArrow |
|
496 || aKeyEvent.iScanCode == EStdKeyRightArrow ) |
|
497 { |
|
498 return EKeyWasConsumed; |
|
499 } |
|
500 // otherwise, do nothing |
|
501 else |
|
502 { |
|
503 // empty statement to remove Lint error, MISRA required rule 60 |
|
504 } |
|
505 } |
|
506 return EKeyWasNotConsumed; |
|
507 } |
|
508 |
|
509 // --------------------------------------------------------- |
|
510 // CGSCamQualitySettingSlider::MinimumSize |
|
511 // --------------------------------------------------------- |
|
512 // |
|
513 TSize CGSCamQualitySettingSlider::MinimumSize() |
|
514 { |
|
515 TSize zerosize = TSize( 0, 0 ); |
|
516 if ( iMinimumSize == zerosize ) |
|
517 { |
|
518 SizeChanged(); |
|
519 } |
|
520 return iMinimumSize; |
|
521 } |
|
522 |
|
523 |
|
524 // --------------------------------------------------------- |
|
525 // CGSCamQualitySettingSlider::ReadLayoutL |
|
526 // --------------------------------------------------------- |
|
527 // |
|
528 void CGSCamQualitySettingSlider::ReadLayoutL() |
|
529 { |
|
530 // We can use Rect() as the parent rectangle for subcomponents, because |
|
531 // CGSCamQualitySettingSlider uses the main_cset_slider_pane layout |
|
532 |
|
533 // We're starting again from scratch, so delete the old layout(s) |
|
534 iLegendArray.ResetAndDestroy(); |
|
535 |
|
536 if( iSettingType == ECamSettingItemVideoQuality ) |
|
537 { |
|
538 if ( CamUtility::IsNhdDevice() ) |
|
539 { |
|
540 TouchLayoutVideo(); |
|
541 } |
|
542 else |
|
543 { |
|
544 NonTouchLayoutVideo(); |
|
545 } |
|
546 |
|
547 AppendLegendArrayL( ECamPsiVideoQualityIconIds ); |
|
548 AppendLegendArrayL( ECamPsiVideoQualityFileTypeId, iNumSliderValues ); |
|
549 } |
|
550 else // iSettingType == ECamSettingItemPhotoQuality |
|
551 { |
|
552 if ( CamUtility::IsNhdDevice() ) |
|
553 { |
|
554 TouchLayoutPhoto(); |
|
555 } |
|
556 else |
|
557 { |
|
558 NonTouchLayoutPhoto(); |
|
559 } |
|
560 AppendLegendArrayL( ECamPsiStillQualityIconIds ); |
|
561 } |
|
562 |
|
563 // set the shaft icon sizes |
|
564 for ( TInt i = 0; i < BITMAP_SHAFT_MAX_DIVISIONS+1; i++ ) |
|
565 { |
|
566 AknIconUtils::SetSize( iBitmapShafts[ i ], iShaftLayout.Rect().Size(), |
|
567 EAspectRatioNotPreserved ); |
|
568 } |
|
569 |
|
570 } |
|
571 |
|
572 // ----------------------------------------------------------------------------- |
|
573 // CGSCamQualitySettingSlider::TouchLayoutVideo |
|
574 // Generate layouts for slider legend icons |
|
575 // ----------------------------------------------------------------------------- |
|
576 // |
|
577 void CGSCamQualitySettingSlider::TouchLayoutVideo() |
|
578 { |
|
579 // Set the shaft layout structure |
|
580 iShaftLayout.LayoutRect( Rect(), |
|
581 AknLayoutScalable_Apps::cset_slider_pane( 4 ) ); |
|
582 // set subtitle text layouts |
|
583 iLayoutSubtitleTop.LayoutText( Rect(), |
|
584 AknLayoutScalable_Apps::main_cset_slider_pane_t1( 4 ) ); |
|
585 iLayoutSubtitleBottom.LayoutText( Rect(), |
|
586 AknLayoutScalable_Apps::main_cset_slider_pane_t7( 4 ) ); |
|
587 } |
|
588 |
|
589 // ----------------------------------------------------------------------------- |
|
590 // CGSCamQualitySettingSlider::NonTouchLayoutVideo |
|
591 // Generate layouts for slider legend icons |
|
592 // ----------------------------------------------------------------------------- |
|
593 // |
|
594 void CGSCamQualitySettingSlider::NonTouchLayoutVideo() |
|
595 { |
|
596 // Set the shaft layout structure |
|
597 iShaftLayout.LayoutRect( Rect(), |
|
598 AknLayoutScalable_Apps::cset6_slider_pane( 4 )); |
|
599 // set subtitle text layouts |
|
600 iLayoutSubtitleTop.LayoutText( Rect(), |
|
601 AknLayoutScalable_Apps::main_cset6_slider_pane_t1( 4 ) ); |
|
602 iLayoutSubtitleBottom.LayoutText( Rect(), |
|
603 AknLayoutScalable_Apps::main_cset6_slider_pane_t7( 4 ) ); |
|
604 } |
|
605 |
|
606 // ----------------------------------------------------------------------------- |
|
607 // CGSCamQualitySettingSlider::TouchLayoutPhoto |
|
608 // Generate layouts for slider legend icons |
|
609 // ----------------------------------------------------------------------------- |
|
610 // |
|
611 void CGSCamQualitySettingSlider::TouchLayoutPhoto() |
|
612 { |
|
613 iShaftLayout.LayoutRect( Rect(), |
|
614 AknLayoutScalable_Apps::cset_slider_pane( 2 ) ); |
|
615 // set subtitle text layouts |
|
616 iLayoutSubtitleTop.LayoutText( Rect(), |
|
617 AknLayoutScalable_Apps::main_cset_slider_pane_t1( 2 ) ); |
|
618 iLayoutSubtitleBottom.LayoutText( Rect(), |
|
619 AknLayoutScalable_Apps::main_cset_slider_pane_t7( 2 ) ); |
|
620 } |
|
621 |
|
622 // ----------------------------------------------------------------------------- |
|
623 // CGSCamQualitySettingSlider::NonTouchLayoutPhoto |
|
624 // Generate layouts for slider legend icons |
|
625 // ----------------------------------------------------------------------------- |
|
626 // |
|
627 void CGSCamQualitySettingSlider::NonTouchLayoutPhoto() |
|
628 { |
|
629 // Set the shaft layout structure |
|
630 iShaftLayout.LayoutRect( Rect(), |
|
631 AknLayoutScalable_Apps::cset6_slider_pane( 2 )); |
|
632 // set subtitle text layouts |
|
633 iLayoutSubtitleTop.LayoutText( Rect(), |
|
634 AknLayoutScalable_Apps::main_cset6_slider_pane_t1( 2 ) ); |
|
635 iLayoutSubtitleBottom.LayoutText( Rect(), |
|
636 AknLayoutScalable_Apps::main_cset6_slider_pane_t7( 2 ) ); |
|
637 } |
|
638 |
|
639 // ----------------------------------------------------------------------------- |
|
640 // CGSCamQualitySettingSlider::AppendLegendArrayL |
|
641 // ----------------------------------------------------------------------------- |
|
642 // |
|
643 void CGSCamQualitySettingSlider::AppendLegendArrayL( TCamPsiKey aKey, |
|
644 TInt aNumSliderValues ) |
|
645 { |
|
646 RArray<TInt> array; |
|
647 CleanupClosePushL( array ); |
|
648 |
|
649 TAknLayoutRect layout; |
|
650 iConfiguration->GetPsiIntArrayL( aKey, array ); |
|
651 for( TInt i = 0; i < array.Count(); i+=2 ) |
|
652 { |
|
653 // get positioning info |
|
654 if ( iSettingType == ECamSettingItemVideoQuality ) |
|
655 { |
|
656 if ( CamUtility::IsNhdDevice() ) |
|
657 { |
|
658 layout = GetTouchVideoLegendLayout( Rect(), |
|
659 i/2 + aNumSliderValues ); |
|
660 } |
|
661 else |
|
662 { |
|
663 layout = GetNonTouchVideoLegendLayout( Rect(), |
|
664 i/2 + aNumSliderValues ); |
|
665 } |
|
666 } |
|
667 else |
|
668 { |
|
669 if ( CamUtility::IsNhdDevice() ) |
|
670 { |
|
671 if ( IsThreeTicksSlider() ) |
|
672 { |
|
673 // Touch layouts supports only three ticks sliders |
|
674 layout = GetTouchPhotoLegendLayout( Rect(), |
|
675 i/2 + aNumSliderValues ); |
|
676 } |
|
677 else |
|
678 { |
|
679 // Five ticks slider is taken from NonTouch layouts |
|
680 layout = GetNonTouchPhotoLegend5Layout( Rect(), |
|
681 i/2 + aNumSliderValues ); |
|
682 } |
|
683 } |
|
684 else |
|
685 { |
|
686 if ( IsThreeTicksSlider() ) |
|
687 { |
|
688 layout = GetNonTouchPhotoLegend3Layout( Rect(), |
|
689 i/2 + aNumSliderValues ); |
|
690 } |
|
691 else |
|
692 { |
|
693 layout = GetNonTouchPhotoLegend5Layout( Rect(), |
|
694 i/2 + aNumSliderValues ); |
|
695 } |
|
696 } |
|
697 } |
|
698 |
|
699 CCamSliderLegend* legend = new ( ELeave ) CCamSliderLegend(); |
|
700 CleanupStack::PushL( legend ); |
|
701 legend->ConstructL( layout, array[i], array[i+1] ); |
|
702 |
|
703 User::LeaveIfError( iLegendArray.Append( legend ) ); |
|
704 CleanupStack::Pop( legend ); |
|
705 } |
|
706 CleanupStack::PopAndDestroy( &array ); |
|
707 } |
|
708 |
|
709 // ----------------------------------------------------------------------------- |
|
710 // CGSCamQualitySettingSlider::GetTouchVideoLegendLayout |
|
711 // Select layout for slider legend icons |
|
712 // ----------------------------------------------------------------------------- |
|
713 // |
|
714 TAknLayoutRect CGSCamQualitySettingSlider::GetTouchVideoLegendLayout( |
|
715 const TRect& aParentRect, |
|
716 TInt aIndex ) const |
|
717 { |
|
718 TAknLayoutRect res; |
|
719 switch ( aIndex ) |
|
720 { |
|
721 case KVideoQualityTVHigh : |
|
722 { |
|
723 res.LayoutRect( aParentRect, |
|
724 AknLayoutScalable_Apps::main_cset_slider_pane_g7( 0 ) ); |
|
725 break; |
|
726 } |
|
727 case KVideoQualityTVHighType : |
|
728 { |
|
729 res.LayoutRect( aParentRect, |
|
730 AknLayoutScalable_Apps::main_cset_slider_pane_g8( 0 ) ); |
|
731 break; |
|
732 } |
|
733 case KVideoQualityWide : |
|
734 { |
|
735 res.LayoutRect( aParentRect, |
|
736 AknLayoutScalable_Apps::main_cset_slider_pane_g11( 0 ) ); |
|
737 |
|
738 break; |
|
739 } |
|
740 case KVideoQualityWideType : |
|
741 { |
|
742 res.LayoutRect( aParentRect, |
|
743 AknLayoutScalable_Apps::main_cset_slider_pane_g12( 0 ) ); |
|
744 break; |
|
745 } |
|
746 case KVideoQualityEmailHigh : |
|
747 { |
|
748 res.LayoutRect( aParentRect, |
|
749 AknLayoutScalable_Apps::main_cset_slider_pane_g16( 0 ) ); |
|
750 break; |
|
751 } |
|
752 case KVideoQualityEmailHighType : |
|
753 { |
|
754 res.LayoutRect( aParentRect, |
|
755 AknLayoutScalable_Apps::main_cset_slider_pane_g17( 0 ) ); |
|
756 break; |
|
757 } |
|
758 case KVideoQualityEmailNormal : |
|
759 { |
|
760 res.LayoutRect( aParentRect, |
|
761 AknLayoutScalable_Apps::main_cset_slider_pane_g13( 0 ) ); |
|
762 break; |
|
763 } |
|
764 case KVideoQualityEmailNormalType : |
|
765 { |
|
766 res.LayoutRect( aParentRect, |
|
767 AknLayoutScalable_Apps::main_cset_slider_pane_g14( 0 ) ); |
|
768 break; |
|
769 } |
|
770 case KVideoQualitySharing : |
|
771 { |
|
772 res.LayoutRect( aParentRect, |
|
773 AknLayoutScalable_Apps::main_cset_slider_pane_g16( 0 ) ); |
|
774 break; |
|
775 } |
|
776 case KVideoQualitySharingType : |
|
777 { |
|
778 res.LayoutRect( aParentRect, |
|
779 AknLayoutScalable_Apps::main_cset_slider_pane_g17( 0 ) ); |
|
780 break; |
|
781 } |
|
782 default: |
|
783 { |
|
784 break; |
|
785 } |
|
786 } |
|
787 return res; |
|
788 } |
|
789 |
|
790 // ----------------------------------------------------------------------------- |
|
791 // CGSCamQualitySettingSlider::GetNonTouchVideoLegendLayout |
|
792 // Select layout for slider legend icons |
|
793 // ----------------------------------------------------------------------------- |
|
794 // |
|
795 TAknLayoutRect CGSCamQualitySettingSlider::GetNonTouchVideoLegendLayout( |
|
796 const TRect& aParentRect, |
|
797 TInt aIndex ) const |
|
798 { |
|
799 TAknLayoutRect res; |
|
800 switch ( aIndex ) |
|
801 { |
|
802 case KVideoQualityTVHigh : |
|
803 { |
|
804 res.LayoutRect( aParentRect, |
|
805 AknLayoutScalable_Apps::main_cset6_slider_pane_g7( 0 ) ); |
|
806 break; |
|
807 } |
|
808 case KVideoQualityTVHighType : |
|
809 { |
|
810 res.LayoutRect( aParentRect, |
|
811 AknLayoutScalable_Apps::main_cset6_slider_pane_g8( 0 ) ); |
|
812 break; |
|
813 } |
|
814 case KVideoQualityWide : |
|
815 { |
|
816 res.LayoutRect( aParentRect, |
|
817 AknLayoutScalable_Apps::main_cset6_slider_pane_g11( 0 ) ); |
|
818 break; |
|
819 } |
|
820 case KVideoQualityWideType : |
|
821 { |
|
822 res.LayoutRect( aParentRect, |
|
823 AknLayoutScalable_Apps::main_cset6_slider_pane_g12( 0 ) ); |
|
824 break; |
|
825 } |
|
826 case KVideoQualityEmailHigh : |
|
827 { |
|
828 res.LayoutRect( aParentRect, |
|
829 AknLayoutScalable_Apps::main_cset6_slider_pane_g16( 0 ) ); |
|
830 break; |
|
831 } |
|
832 case KVideoQualityEmailHighType : |
|
833 { |
|
834 res.LayoutRect( aParentRect, |
|
835 AknLayoutScalable_Apps::main_cset6_slider_pane_g17( 0 ) ); |
|
836 break; |
|
837 } |
|
838 case KVideoQualityEmailNormal : |
|
839 { |
|
840 res.LayoutRect( aParentRect, |
|
841 AknLayoutScalable_Apps::main_cset6_slider_pane_g13( 0 ) ); |
|
842 break; |
|
843 } |
|
844 case KVideoQualityEmailNormalType : |
|
845 { |
|
846 res.LayoutRect( aParentRect, |
|
847 AknLayoutScalable_Apps::main_cset6_slider_pane_g14( 0 ) ); |
|
848 break; |
|
849 } |
|
850 case KVideoQualitySharing : |
|
851 { |
|
852 res.LayoutRect( aParentRect, |
|
853 AknLayoutScalable_Apps::main_cset6_slider_pane_g16( 0 ) ); |
|
854 break; |
|
855 } |
|
856 case KVideoQualitySharingType : |
|
857 { |
|
858 res.LayoutRect( aParentRect, |
|
859 AknLayoutScalable_Apps::main_cset6_slider_pane_g17( 0 ) ); |
|
860 break; |
|
861 } |
|
862 default: |
|
863 { |
|
864 break; |
|
865 } |
|
866 } |
|
867 return res; |
|
868 } |
|
869 |
|
870 // ----------------------------------------------------------------------------- |
|
871 // CGSCamQualitySettingSlider::GetTouchPhotoLegendLayout |
|
872 // Select layout for slider legend icons |
|
873 // ----------------------------------------------------------------------------- |
|
874 // |
|
875 TAknLayoutRect CGSCamQualitySettingSlider::GetTouchPhotoLegendLayout( |
|
876 const TRect& aParentRect, |
|
877 TInt aIndex ) const |
|
878 { |
|
879 TAknLayoutRect res; |
|
880 switch ( aIndex ) |
|
881 { |
|
882 case KImageQualityHigh : |
|
883 { |
|
884 res.LayoutRect( aParentRect, |
|
885 AknLayoutScalable_Apps::main_cset_slider_pane_g3( 0 ) ); |
|
886 break; |
|
887 } |
|
888 case KImageQualityMedium : |
|
889 { |
|
890 res.LayoutRect( aParentRect, |
|
891 AknLayoutScalable_Apps::main_cset_slider_pane_g4( 0 ) ); |
|
892 break; |
|
893 } |
|
894 case KImageQualityLow : |
|
895 { |
|
896 res.LayoutRect( aParentRect, |
|
897 AknLayoutScalable_Apps::main_cset_slider_pane_g5( 0 ) ); |
|
898 break; |
|
899 } |
|
900 default: |
|
901 { |
|
902 res.LayoutRect( aParentRect, |
|
903 AknLayoutScalable_Apps::main_cset_slider_pane_g5( 0 ) ); |
|
904 break; |
|
905 } |
|
906 } |
|
907 return res; |
|
908 } |
|
909 |
|
910 // ----------------------------------------------------------------------------- |
|
911 // CGSCamQualitySettingSlider::GetNonTouchPhotoLegend3Layout |
|
912 // Select layout for slider legend icons |
|
913 // ----------------------------------------------------------------------------- |
|
914 // |
|
915 TAknLayoutRect CGSCamQualitySettingSlider::GetNonTouchPhotoLegend3Layout( |
|
916 const TRect& aParentRect, |
|
917 TInt aIndex ) const |
|
918 { |
|
919 TAknLayoutRect res; |
|
920 switch ( aIndex ) |
|
921 { |
|
922 case KImageQualityHigh : |
|
923 { |
|
924 res.LayoutRect( aParentRect, |
|
925 AknLayoutScalable_Apps::main_cset6_slider_pane_g7( 0 ) ); |
|
926 break; |
|
927 } |
|
928 case KImageQualityMedium : |
|
929 { |
|
930 res.LayoutRect( aParentRect, |
|
931 AknLayoutScalable_Apps::main_cset6_slider_pane_g4( 0 ) ); |
|
932 break; |
|
933 } |
|
934 case KImageQualityLow : |
|
935 { |
|
936 res.LayoutRect( aParentRect, |
|
937 AknLayoutScalable_Apps::main_cset6_slider_pane_g5( 0 ) ); |
|
938 break; |
|
939 } |
|
940 default: |
|
941 { |
|
942 res.LayoutRect( aParentRect, |
|
943 AknLayoutScalable_Apps::main_cset6_slider_pane_g5( 0 ) ); |
|
944 break; |
|
945 } |
|
946 } |
|
947 return res; |
|
948 } |
|
949 |
|
950 // ----------------------------------------------------------------------------- |
|
951 // CGSCamQualitySettingSlider::GetNonTouchPhotoLegend5Layout |
|
952 // Select layout for slider legend icons |
|
953 // ----------------------------------------------------------------------------- |
|
954 // |
|
955 TAknLayoutRect CGSCamQualitySettingSlider::GetNonTouchPhotoLegend5Layout( |
|
956 const TRect& aParentRect, |
|
957 TInt aIndex ) const |
|
958 { |
|
959 TAknLayoutRect res; |
|
960 switch ( aIndex ) |
|
961 { |
|
962 case KImageQualityHigh : |
|
963 { |
|
964 res.LayoutRect( aParentRect, |
|
965 AknLayoutScalable_Apps::main_cset6_slider_pane_g7( 0 ) ); |
|
966 break; |
|
967 } |
|
968 case KImageQualityMedium : |
|
969 { |
|
970 res.LayoutRect( aParentRect, |
|
971 AknLayoutScalable_Apps::main_cset6_slider_pane_g9( 0 ) ); |
|
972 break; |
|
973 } |
|
974 case KImageQualityLow : |
|
975 { |
|
976 res.LayoutRect( aParentRect, |
|
977 AknLayoutScalable_Apps::main_cset6_slider_pane_g4( 0 ) ); |
|
978 break; |
|
979 } |
|
980 case KImageQualityLower : |
|
981 { |
|
982 res.LayoutRect( aParentRect, |
|
983 AknLayoutScalable_Apps::main_cset6_slider_pane_g13( 0 ) ); |
|
984 |
|
985 break; |
|
986 } |
|
987 case KImageQualityLowest : |
|
988 { |
|
989 res.LayoutRect( aParentRect, |
|
990 AknLayoutScalable_Apps::main_cset6_slider_pane_g5( 0 ) ); |
|
991 break; |
|
992 } |
|
993 default: |
|
994 { |
|
995 res.LayoutRect( aParentRect, |
|
996 AknLayoutScalable_Apps::main_cset6_slider_pane_g5( 0 ) ); |
|
997 |
|
998 break; |
|
999 } |
|
1000 } |
|
1001 return res; |
|
1002 } |
|
1003 |
|
1004 // ----------------------------------------------------------------------------- |
|
1005 // CGSCamQualitySettingSlider::IsThreeTicksSlider |
|
1006 // Select layout for slider legend icons |
|
1007 // ----------------------------------------------------------------------------- |
|
1008 // |
|
1009 TBool CGSCamQualitySettingSlider::IsThreeTicksSlider() const |
|
1010 { |
|
1011 if ( !iConfiguration ) |
|
1012 { |
|
1013 return ETrue; |
|
1014 } |
|
1015 TInt count; |
|
1016 if ( iSettingType == ECamSettingItemVideoQuality ) |
|
1017 { |
|
1018 count = iConfiguration->NumVideoQualities(); |
|
1019 } |
|
1020 else |
|
1021 { |
|
1022 count = iConfiguration->NumPrimaryImageQualities(); |
|
1023 } |
|
1024 |
|
1025 PRINT1( _L("Camera <> CGSCamQualitySettingSlider::IsThreeTicksSlider count=%d"), count ); |
|
1026 return count < 4; // Magic: less than three steps |
|
1027 } |
|
1028 |
|
1029 // ----------------------------------------------------------------------------- |
|
1030 // CGSCamQualitySettingSlider::HandlePointerEventL |
|
1031 // Handles slider pointer events |
|
1032 // ----------------------------------------------------------------------------- |
|
1033 // |
|
1034 void CGSCamQualitySettingSlider::HandlePointerEventL( |
|
1035 const TPointerEvent& aPointerEvent ) |
|
1036 { |
|
1037 |
|
1038 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
1039 |
|
1040 // This is the max bitmap offset from the top of the shaft that the |
|
1041 // selection can be |
|
1042 TInt maxVOffset = iShaftLayout.Rect().Size().iHeight; |
|
1043 |
|
1044 // This is the no. of pixels for a "step" |
|
1045 TInt stepInPixels = ( maxVOffset * KDivisorFactor ) / iNumSliderValues; |
|
1046 |
|
1047 // Calculate new setting value |
|
1048 TInt deltaY = aPointerEvent.iPosition.iY - iShaftLayout.Rect().iTl.iY; |
|
1049 TInt nbrSteps = deltaY / ( stepInPixels / KDivisorFactor ); |
|
1050 iValue = iMaxSliderValue - nbrSteps; |
|
1051 |
|
1052 if ( iValue < iMinSliderValue ) |
|
1053 { |
|
1054 iValue = iMinSliderValue; |
|
1055 } |
|
1056 |
|
1057 if (iValue > iMaxSliderValue) |
|
1058 { |
|
1059 iValue = iMaxSliderValue; |
|
1060 } |
|
1061 // Tell observer about change |
|
1062 iSettingObserver->HandleSettingValueUpdateL( iValue ); |
|
1063 DrawNow(); |
|
1064 |
|
1065 } |
|
1066 |
|
1067 // End of File |
|
1068 |
|