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 the EV slider* |
|
15 */ |
|
16 |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CamCaptureSetupSlider.h" |
|
21 #include "CamPanic.h" // Panic codes |
|
22 #include "CamUtility.h" |
|
23 #include "CamAppUi.h" |
|
24 #include "CamPSI.h" |
|
25 #include "camconfiguration.h" |
|
26 #include "CameraUiConfigManager.h" |
|
27 |
|
28 #include <e32base.h> |
|
29 #include <e32std.h> |
|
30 #include <coemain.h> |
|
31 #include <eikenv.h> |
|
32 #include <cameraapp.mbg> |
|
33 #include <eikappui.h> // For CCoeAppUiBase |
|
34 #include <eikapp.h> // For CEikApplication |
|
35 #include <barsread.h> // resource reader |
|
36 #include <AknIconUtils.h> |
|
37 #include <AknsDrawUtils.h> |
|
38 #include <touchfeedback.h> |
|
39 |
|
40 #include <cameraapp.rsg> |
|
41 #include <vgacamsettings.rsg> |
|
42 #include <aknlayoutscalable_apps.cdl.h> |
|
43 |
|
44 // EXTERNAL DATA STRUCTURES |
|
45 |
|
46 // EXTERNAL FUNCTION PROTOTYPES |
|
47 |
|
48 // CONSTANTS |
|
49 const TInt KDivisorFactor = 1024; // Avoids using TReal maths, use factor of 2 |
|
50 |
|
51 // Contrast slider value indexes |
|
52 const TInt KContrastPlusInd = 0; |
|
53 const TInt KContrastMinusInd = 1; |
|
54 const TInt KContrastIconInd = 2; |
|
55 |
|
56 // EV slider value indexes |
|
57 const TInt KEVPlus20Ind = 0; |
|
58 const TInt KEVPlus15Ind = 1; |
|
59 const TInt KEVPlus10Ind = 2; |
|
60 const TInt KEVPlus05Ind = 3; |
|
61 const TInt KEV0Ind = 4; |
|
62 const TInt KEVMinus05Ind = 5; |
|
63 const TInt KEVMinus10Ind = 6; |
|
64 const TInt KEVMinus15Ind = 7; |
|
65 const TInt KEVMinus20Ind = 8; |
|
66 const TUint32 KToolbarExtensionBgColor = 0x00000000; |
|
67 const TInt KToolBarExtensionBgAlpha = 0x7F; |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 // ============================ MEMBER FUNCTIONS =============================== |
|
73 |
|
74 // --------------------------------------------------------- |
|
75 // CCamSliderLegend::~CCamSliderLegend |
|
76 // destructor |
|
77 // --------------------------------------------------------- |
|
78 // |
|
79 CCamSliderLegend::~CCamSliderLegend() |
|
80 { |
|
81 PRINT( _L("Camera => ~CCamSliderLegend") ); |
|
82 delete iText; |
|
83 delete iBitmap; |
|
84 delete iMask; |
|
85 PRINT( _L("Camera <= ~CCamSliderLegend") ); |
|
86 } |
|
87 |
|
88 CCamSliderLegend::CCamSliderLegend( TBool aFullySkinned ) |
|
89 : iFullySkinned( aFullySkinned ) |
|
90 { |
|
91 } |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CCamSliderLegend::Draw |
|
95 // Draws the legend |
|
96 // --------------------------------------------------------- |
|
97 // |
|
98 void CCamSliderLegend::Draw( CWindowGc& aGc ) const |
|
99 { |
|
100 if ( iItem == ECamSliderLegendItemText ) |
|
101 { |
|
102 TRgb color; |
|
103 if( iFullySkinned ) |
|
104 { |
|
105 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
106 AknsUtils::GetCachedColor( skin, color, KAknsIIDQsnTextColors, |
|
107 EAknsCIQsnTextColorsCG6 ); |
|
108 } |
|
109 else |
|
110 { |
|
111 color=KRgbWhite; |
|
112 } |
|
113 iPosition.DrawText( aGc, iText->Des(), ETrue, color ); |
|
114 } |
|
115 else |
|
116 { |
|
117 iIconRect.DrawImage( aGc, iBitmap, iMask ); |
|
118 } |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // CCamSliderLegend::Rect |
|
123 // Returns the legend rect |
|
124 // --------------------------------------------------------- |
|
125 // |
|
126 TRect CCamSliderLegend::Rect() const |
|
127 { |
|
128 if ( iItem == ECamSliderLegendItemText ) |
|
129 { |
|
130 return iPosition.TextRect(); |
|
131 } |
|
132 else |
|
133 { |
|
134 return iIconRect.Rect(); |
|
135 } |
|
136 } |
|
137 |
|
138 |
|
139 // --------------------------------------------------------- |
|
140 // CCamSliderLegend::ConstructTextL |
|
141 // Constructs a text element from resources with given layout |
|
142 // --------------------------------------------------------- |
|
143 // |
|
144 void CCamSliderLegend::ConstructTextL( |
|
145 TResourceReader& aReader, |
|
146 const TRect& aRect, |
|
147 const TAknTextComponentLayout& aLayout ) |
|
148 { |
|
149 iItem = static_cast<TCamSliderLegendItem>( aReader.ReadInt16() ); |
|
150 if ( iItem == ECamSliderLegendItemText ) |
|
151 { // must be a text |
|
152 iPosition.LayoutText( aRect, aLayout ); |
|
153 iText = aReader.ReadHBufC16L(); |
|
154 aReader.ReadInt32(); // bitmap |
|
155 aReader.ReadInt32(); // mask |
|
156 } |
|
157 } |
|
158 |
|
159 // --------------------------------------------------------- |
|
160 // CCamSliderLegend::ConstructIconL |
|
161 // Constructs an icon from resources with given layout |
|
162 // --------------------------------------------------------- |
|
163 // |
|
164 void CCamSliderLegend::ConstructIconL( |
|
165 TResourceReader& aReader, |
|
166 const TRect& aRect, |
|
167 const TAknWindowComponentLayout& aLayout ) |
|
168 { |
|
169 iItem = static_cast<TCamSliderLegendItem>( aReader.ReadInt16() ); |
|
170 if ( iItem == ECamSliderLegendItemIcon ) |
|
171 { // must be an icon |
|
172 iIconRect.LayoutRect( aRect, aLayout ); |
|
173 iText = aReader.ReadHBufC16L(); |
|
174 TInt bitmap = aReader.ReadInt32(); |
|
175 TInt mask = aReader.ReadInt32(); |
|
176 |
|
177 // Create component bitmaps |
|
178 TFileName resFileName; |
|
179 CamUtility::ResourceFileName( resFileName ); |
|
180 TPtrC resname = resFileName; |
|
181 AknIconUtils::CreateIconL( iBitmap, iMask, resname, bitmap, mask ); |
|
182 AknIconUtils::SetSize( iBitmap, iIconRect.Rect().Size() ); |
|
183 } |
|
184 } |
|
185 |
|
186 |
|
187 // ----------------------------------------------------------------------------- |
|
188 // CCamCaptureSetupSlider::CCamCaptureSetupSlider |
|
189 // C++ default constructor can NOT contain any code, that |
|
190 // might leave. |
|
191 // ----------------------------------------------------------------------------- |
|
192 // |
|
193 CCamCaptureSetupSlider::CCamCaptureSetupSlider( MCamSettingValueObserver* aObserver, |
|
194 TCamSettingItemIds aSettingType, |
|
195 TInt aSteps, |
|
196 TBool aFullySkinned ) |
|
197 : iSettingObserver( aObserver ), iSettingType( aSettingType ), iSteps( aSteps ), iFullySkinned( aFullySkinned ) |
|
198 { |
|
199 } |
|
200 |
|
201 |
|
202 /* |
|
203 * CCamCaptureSetupSlider::InitializeSliderValuesL |
|
204 */ |
|
205 |
|
206 void CCamCaptureSetupSlider::InitializeSliderValuesL() |
|
207 { |
|
208 CCameraUiConfigManager* configManager = static_cast<CCamAppUi*> |
|
209 ( iCoeEnv->AppUi() )->AppController().UiConfigManagerPtr(); |
|
210 TBool configureRunTime = EFalse; |
|
211 RArray<TInt> range; |
|
212 CleanupClosePushL( range ); |
|
213 |
|
214 switch ( iSettingType ) |
|
215 { |
|
216 case ECamSettingItemDynamicPhotoBrightness: |
|
217 case ECamSettingItemDynamicVideoBrightness: |
|
218 case ECamSettingItemUserSceneBrightness: |
|
219 { |
|
220 if ( configManager && configManager->IsBrightnessSupported() ) |
|
221 { |
|
222 configManager->SupportedBrightnessRangeL( range ); |
|
223 configureRunTime = ETrue; |
|
224 } |
|
225 break; |
|
226 } |
|
227 case ECamSettingItemDynamicPhotoContrast: |
|
228 case ECamSettingItemDynamicVideoContrast: |
|
229 case ECamSettingItemUserSceneContrast: |
|
230 { |
|
231 if ( configManager && configManager->IsContrastSupported() ) |
|
232 { |
|
233 configManager->SupportedContrastRangeL( range ); |
|
234 configureRunTime = ETrue; |
|
235 } |
|
236 } |
|
237 break; |
|
238 |
|
239 case ECamSettingItemDynamicPhotoExposure: |
|
240 case ECamSettingItemDynamicVideoExposure: |
|
241 case ECamSettingItemUserSceneExposure: |
|
242 { |
|
243 // get range of EV values from product specific utility |
|
244 TCamEvCompRange evRange = |
|
245 static_cast<CCamAppUi*>( |
|
246 iCoeEnv->AppUi() )->AppController().EvRange(); |
|
247 |
|
248 iMaxSliderValue = evRange.iMaxValue * evRange.iStepsPerUnit; |
|
249 iMinSliderValue = evRange.iMinValue * evRange.iStepsPerUnit; |
|
250 iNumSliderValues = iMaxSliderValue - iMinSliderValue; |
|
251 } |
|
252 break; |
|
253 |
|
254 default: |
|
255 { |
|
256 } |
|
257 break; |
|
258 } |
|
259 |
|
260 if ( configureRunTime ) |
|
261 { |
|
262 if ( range.Count() > 0 ) |
|
263 { |
|
264 iMinSliderValue = range[0]; //min value |
|
265 iMaxSliderValue = range[1]; // max value |
|
266 iNumSliderValues = range[range.Count()-1]; // steps |
|
267 } |
|
268 } |
|
269 |
|
270 CleanupStack::PopAndDestroy( &range ); |
|
271 |
|
272 } |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // CCamCaptureSetupSlider::ConstructL |
|
276 // Symbian 2nd phase constructor can leave. |
|
277 // ----------------------------------------------------------------------------- |
|
278 // |
|
279 void CCamCaptureSetupSlider::ConstructL( const CCoeControl* aParent ) |
|
280 { |
|
281 __ASSERT_DEBUG( aParent!=NULL, CamPanic( ECamPanicNullPointer ) ); |
|
282 |
|
283 InitializeSliderValuesL(); |
|
284 |
|
285 iParentControl = aParent; |
|
286 SetContainerWindowL( *iParentControl ); |
|
287 |
|
288 TFileName resFileName; |
|
289 CamUtility::ResourceFileName( resFileName ); |
|
290 TPtrC resname = resFileName; |
|
291 |
|
292 // Create component bitmaps |
|
293 AknIconUtils::CreateIconL( iBitmapShaft, |
|
294 iBitmapShaftMask, |
|
295 resname, |
|
296 EMbmCameraappQgn_graf_nslider_cam4_empty, |
|
297 EMbmCameraappQgn_graf_nslider_cam4_empty_mask ); |
|
298 |
|
299 AknIconUtils::CreateIconL( iBitmapThumb, |
|
300 iBitmapThumbMask, |
|
301 resname, |
|
302 EMbmCameraappQgn_graf_nslider_cam4_marker, |
|
303 EMbmCameraappQgn_graf_nslider_cam4_marker_mask ); |
|
304 |
|
305 AknIconUtils::CreateIconL( iBitmapThumbSelected, |
|
306 iBitmapThumbSelectedMask, |
|
307 resname, |
|
308 EMbmCameraappQgn_graf_nslider_cam4_marker_selected, |
|
309 EMbmCameraappQgn_graf_nslider_cam4_marker_selected_mask ); |
|
310 iBitmapThumbCurrent = iBitmapThumb; |
|
311 iBitmapThumbCurrentMask = iBitmapThumbMask; |
|
312 } |
|
313 |
|
314 // ----------------------------------------------------------------------------- |
|
315 // CCamCaptureSetupSlider::NewL |
|
316 // Two-phased constructor. |
|
317 // ----------------------------------------------------------------------------- |
|
318 // |
|
319 CCamCaptureSetupSlider* CCamCaptureSetupSlider::NewL( const CCoeControl* aParent, |
|
320 MCamSettingValueObserver* aObserver, |
|
321 TCamSettingItemIds aSettingItem, |
|
322 TInt aSteps, |
|
323 TBool aFullySkinned ) |
|
324 { |
|
325 CCamCaptureSetupSlider* self = |
|
326 new( ELeave ) CCamCaptureSetupSlider( aObserver, aSettingItem, aSteps, |
|
327 aFullySkinned ); |
|
328 CleanupStack::PushL( self ); |
|
329 self->ConstructL( aParent ); |
|
330 CleanupStack::Pop( self ); |
|
331 return self; |
|
332 } |
|
333 |
|
334 // ----------------------------------------------------------------------------- |
|
335 // CCamCaptureSetupSlider::~CCamCaptureSetupSlider |
|
336 // Destructor |
|
337 // ----------------------------------------------------------------------------- |
|
338 // |
|
339 CCamCaptureSetupSlider::~CCamCaptureSetupSlider() |
|
340 { |
|
341 PRINT( _L("Camera => ~CCamCaptureSetupSlider") ); |
|
342 |
|
343 // Destroy legend strings |
|
344 iLegendArray.ResetAndDestroy(); |
|
345 |
|
346 delete iBitmapShaft; |
|
347 delete iBitmapShaftMask; |
|
348 delete iBitmapThumb; |
|
349 delete iBitmapThumbMask; |
|
350 delete iBitmapThumbSelected; |
|
351 delete iBitmapThumbSelectedMask; |
|
352 PRINT( _L("Camera <= ~CCamCaptureSetupSlider") ); |
|
353 } |
|
354 |
|
355 // ----------------------------------------------------------------------------- |
|
356 // CCamCaptureSetupSlider::InitializeL |
|
357 // Sets up the slider with the initial value |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 void CCamCaptureSetupSlider::InitializeL( TInt aValue ) |
|
361 { |
|
362 // Check the initial value is valid. If no, leave. |
|
363 if ( aValue < iMinSliderValue || |
|
364 aValue > iMaxSliderValue ) |
|
365 { |
|
366 User::Leave( KErrArgument ); |
|
367 } |
|
368 |
|
369 iValue = aValue; |
|
370 } |
|
371 |
|
372 // ----------------------------------------------------------------------------- |
|
373 // CCamCaptureSetupSlider::MinValue |
|
374 // Returns the minimum slider value |
|
375 // ----------------------------------------------------------------------------- |
|
376 // |
|
377 TInt CCamCaptureSetupSlider::MinValue() const |
|
378 { |
|
379 return iMinSliderValue; |
|
380 } |
|
381 |
|
382 // ----------------------------------------------------------------------------- |
|
383 // CCamCaptureSetupSlider::MaxValue |
|
384 // Returns the maximum slider value |
|
385 // ----------------------------------------------------------------------------- |
|
386 // |
|
387 TInt CCamCaptureSetupSlider::MaxValue() const |
|
388 { |
|
389 return iMaxSliderValue; |
|
390 } |
|
391 |
|
392 |
|
393 // ----------------------------------------------------------------------------- |
|
394 // CCamCaptureSetupSlider::SetRange |
|
395 // Sets the minimum and maximum values of the slider control |
|
396 // ----------------------------------------------------------------------------- |
|
397 // |
|
398 void CCamCaptureSetupSlider::SetRange( TInt aMin, TInt aMax ) |
|
399 { |
|
400 ASSERT( aMin < aMax ); |
|
401 iMinSliderValue = aMin; |
|
402 iMaxSliderValue = aMax; |
|
403 iNumSliderValues = iMaxSliderValue; |
|
404 } |
|
405 |
|
406 |
|
407 // ----------------------------------------------------------------------------- |
|
408 // CCamCaptureSetupSlider::Draw |
|
409 // Draws the slider |
|
410 // ----------------------------------------------------------------------------- |
|
411 // |
|
412 void CCamCaptureSetupSlider::Draw( const TRect& /*aRect*/ ) const |
|
413 { |
|
414 CWindowGc& gc = SystemGc(); |
|
415 |
|
416 if( iFullySkinned ) |
|
417 { |
|
418 MAknsSkinInstance* skin = AknsUtils::SkinInstance(); |
|
419 MAknsControlContext *cc = AknsDrawUtils::ControlContext( iParentControl ); |
|
420 AknsDrawUtils::Background( skin, cc, iParentControl, gc, Rect() ); |
|
421 } |
|
422 else |
|
423 { |
|
424 gc.SetDrawMode( CGraphicsContext::EDrawModeWriteAlpha ); |
|
425 gc.SetPenSize( TSize (1,1) ); |
|
426 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
427 gc.SetPenColor( TRgb( 0x00ffffff, KToolBarExtensionBgAlpha ) ); |
|
428 gc.SetBrushColor( TRgb( KToolbarExtensionBgColor, KToolBarExtensionBgAlpha ) ); |
|
429 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
430 gc.DrawRect( Rect() ); |
|
431 } |
|
432 |
|
433 // STEP 1: Draw the legend text |
|
434 TInt count = iLegendArray.Count(); |
|
435 TInt i = 0; |
|
436 for ( i = 0; i < count; i++ ) |
|
437 { |
|
438 iLegendArray[i]->Draw( gc ); |
|
439 } |
|
440 |
|
441 CFbsBitmap* shaft = iBitmapShaft; |
|
442 CFbsBitmap* shaftMask = iBitmapShaftMask; |
|
443 |
|
444 // Step 2: Draw the shaft bitmap |
|
445 if ( shaft ) |
|
446 { |
|
447 iShaftLayout.DrawImage( gc, shaft, shaftMask ); |
|
448 } |
|
449 |
|
450 // Step 3: Work out the position of the thumb |
|
451 TPoint thumbPoint = iThumbPoint; |
|
452 |
|
453 // This is the max bitmap offset from the top of the shaft that the thumb can be |
|
454 TInt maxVOffset = iShaftLayout.Rect().Size().iHeight - iBitmapThumb->SizeInPixels().iHeight; |
|
455 |
|
456 // This is the no. of pixels for a "step" |
|
457 TInt stepInPixels = ( maxVOffset * KDivisorFactor ) / iNumSliderValues; |
|
458 |
|
459 // Thumb position = top of shaft + delta |
|
460 TInt nbrSteps = iMaxSliderValue - iValue; |
|
461 thumbPoint.iY = iShaftLayout.Rect().iTl.iY + stepInPixels * nbrSteps / KDivisorFactor; |
|
462 |
|
463 // Step 4: Blit the thumb bitmap |
|
464 gc.BitBltMasked( thumbPoint, iBitmapThumbCurrent, iBitmapThumb->SizeInPixels(), iBitmapThumbCurrentMask, ETrue ); |
|
465 } |
|
466 |
|
467 |
|
468 // --------------------------------------------------------- |
|
469 // CCamCaptureSetupSlider::SizeChanged |
|
470 // Calculates the new minimum size |
|
471 // --------------------------------------------------------- |
|
472 // |
|
473 void CCamCaptureSetupSlider::SizeChanged() |
|
474 { |
|
475 TRAPD( ignore, ReadLayoutL() ); |
|
476 if ( ignore ) |
|
477 { |
|
478 // Do nothing ( removes build warning ) |
|
479 } |
|
480 |
|
481 // Work out the minimum size |
|
482 TInt count = iLegendArray.Count(); |
|
483 |
|
484 TRect minimumRect; |
|
485 |
|
486 // Start min rect as first legend text |
|
487 if ( count > 0 ) |
|
488 { |
|
489 minimumRect = iLegendArray[0]->Rect(); |
|
490 } |
|
491 |
|
492 // Take into account the other legend texts |
|
493 TInt i; |
|
494 for ( i = 1; i < count; i++ ) |
|
495 { |
|
496 minimumRect.BoundingRect( iLegendArray[i]->Rect() ); |
|
497 } |
|
498 |
|
499 // Take into account the shaft bitmap |
|
500 minimumRect.BoundingRect( iShaftLayout.Rect() ); |
|
501 |
|
502 iMinimumSize = minimumRect.Size(); |
|
503 } |
|
504 |
|
505 |
|
506 // ----------------------------------------------------------------------------- |
|
507 // CCamCaptureSetupSlider::OfferKeyEventL |
|
508 // Allows the user to change the current EV value via key presses. |
|
509 // ----------------------------------------------------------------------------- |
|
510 // |
|
511 TKeyResponse CCamCaptureSetupSlider::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType ) |
|
512 { |
|
513 PRINT( _L("CCamCaptureSetupSlider::OfferKeyEventL") ); |
|
514 if ( aType == EEventKey ) |
|
515 { |
|
516 if ( aKeyEvent.iScanCode == EStdKeyUpArrow ) |
|
517 { |
|
518 if ( iValue < iMaxSliderValue ) |
|
519 { |
|
520 iValue ++; |
|
521 iSettingObserver->HandleSettingValueUpdateL( iValue ); // Tell observer about change |
|
522 DrawNow(); |
|
523 } |
|
524 |
|
525 return EKeyWasConsumed; |
|
526 } |
|
527 else if ( aKeyEvent.iScanCode == EStdKeyDownArrow ) |
|
528 { |
|
529 if ( iValue > iMinSliderValue ) |
|
530 { |
|
531 iValue --; |
|
532 iSettingObserver->HandleSettingValueUpdateL( iValue ); // Tell observer about change |
|
533 DrawNow(); |
|
534 } |
|
535 |
|
536 return EKeyWasConsumed; |
|
537 } |
|
538 else if ( aKeyEvent.iCode == EKeyOK && aKeyEvent.iRepeats == 0 ) |
|
539 { |
|
540 return EKeyWasConsumed; |
|
541 } |
|
542 // otherwise, do nothing |
|
543 else |
|
544 { |
|
545 // empty statement to remove Lint error |
|
546 } |
|
547 } |
|
548 return EKeyWasNotConsumed; |
|
549 } |
|
550 |
|
551 // --------------------------------------------------------- |
|
552 // CCamCaptureSetupSlider::MinimumSize |
|
553 // --------------------------------------------------------- |
|
554 // |
|
555 TSize CCamCaptureSetupSlider::MinimumSize() |
|
556 { |
|
557 TSize zerosize = TSize( 0, 0 ); |
|
558 if ( iMinimumSize == zerosize ) |
|
559 { |
|
560 SizeChanged(); |
|
561 } |
|
562 return iMinimumSize; |
|
563 } |
|
564 |
|
565 |
|
566 // --------------------------------------------------------- |
|
567 // CCamCaptureSetupSlider::ReadLayoutL |
|
568 // --------------------------------------------------------- |
|
569 // |
|
570 void CCamCaptureSetupSlider::ReadLayoutL() |
|
571 { |
|
572 TRect shaftRect; |
|
573 TSize shaftSize; |
|
574 |
|
575 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, |
|
576 iLayoutAreaRect ); |
|
577 |
|
578 // layout area rectangle contains the area, where components need to be |
|
579 // drawn to. the container size is the whole screen, but the layouts are |
|
580 // for the client area. aRect is the container size that might include or |
|
581 // might not include statuspane area. calculating area self will |
|
582 // go around the problem |
|
583 |
|
584 // We're starting again from scratch, so delete the old legend layouts |
|
585 iLegendArray.ResetAndDestroy(); |
|
586 if ( CamUtility::IsNhdDevice() ) |
|
587 { |
|
588 TouchLayoutL(); |
|
589 } |
|
590 else |
|
591 { |
|
592 NonTouchLayoutL(); |
|
593 } |
|
594 |
|
595 AknIconUtils::SetSize( iBitmapThumb, |
|
596 iThumbLayout.Rect().Size(), EAspectRatioPreserved ); |
|
597 AknIconUtils::SetSize( iBitmapThumbSelected, |
|
598 iThumbLayout.Rect().Size(), EAspectRatioPreserved ); |
|
599 |
|
600 // set the shaft icon size |
|
601 shaftRect = iShaftLayout.Rect(); |
|
602 shaftSize = shaftRect.Size(); |
|
603 AknIconUtils::SetSize( iBitmapShaft, shaftSize, EAspectRatioNotPreserved ); |
|
604 |
|
605 // calculate initial thumb position |
|
606 iThumbPoint = TPoint( shaftRect.iTl.iX + shaftSize.iWidth/2 - |
|
607 iBitmapThumb->SizeInPixels().iWidth/2, |
|
608 shaftRect.iTl.iY + shaftSize.iHeight/2 - |
|
609 iBitmapThumb->SizeInPixels().iHeight/2 ); |
|
610 } |
|
611 |
|
612 // --------------------------------------------------------- |
|
613 // CCamCaptureSetupSlider::TouchLayoutL |
|
614 // --------------------------------------------------------- |
|
615 // |
|
616 void CCamCaptureSetupSlider::TouchLayoutL() |
|
617 { |
|
618 TRect statusPaneRect; |
|
619 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EStatusPane, |
|
620 statusPaneRect ); |
|
621 iLayoutAreaRect.BoundingRect( statusPaneRect ); |
|
622 |
|
623 // Get the slider layout |
|
624 TAknLayoutRect sliderLayout; |
|
625 sliderLayout.LayoutRect( iLayoutAreaRect, |
|
626 AknLayoutScalable_Apps::main_cset_slider_pane( 1 ) ); |
|
627 TRect sliderRect( sliderLayout.Rect() ); |
|
628 |
|
629 // Set the thumb layout and icon size |
|
630 iThumbLayout.LayoutRect( sliderRect, |
|
631 AknLayoutScalable_Apps::main_cset_slider_pane_g18( 0 ) ); |
|
632 |
|
633 if ( iSettingType == ECamSettingItemDynamicPhotoContrast || |
|
634 iSettingType == ECamSettingItemDynamicVideoContrast || |
|
635 iSettingType == ECamSettingItemUserSceneContrast ) |
|
636 { |
|
637 // Set the shaft layout and icon size for Contrast slider |
|
638 iShaftLayout.LayoutRect( sliderRect, |
|
639 AknLayoutScalable_Apps::cset_slider_pane( 5 ) ); |
|
640 // set Contrast slider legend layouts |
|
641 TouchContrastLayoutL( sliderRect ); |
|
642 } |
|
643 else |
|
644 { |
|
645 // Set the shaft layout and icon size for EV slider |
|
646 iShaftLayout.LayoutRect( sliderRect, |
|
647 AknLayoutScalable_Apps::cset_slider_pane( 7 ) ); |
|
648 // set EV slider legend layouts |
|
649 TouchEVLayoutL( sliderRect ); |
|
650 } |
|
651 } |
|
652 |
|
653 // ----------------------------------------------------------------------------- |
|
654 // CCamCaptureSetupSlider::NonTouchLayout |
|
655 // ----------------------------------------------------------------------------- |
|
656 // |
|
657 void CCamCaptureSetupSlider::NonTouchLayoutL() |
|
658 { |
|
659 // Non-touch has a visible title & status panes |
|
660 TRect titlePaneRect; |
|
661 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::ETitlePane, |
|
662 titlePaneRect ); |
|
663 iLayoutAreaRect.Move( 0, -titlePaneRect.Height() ); |
|
664 |
|
665 iThumbLayout.LayoutRect( Rect(), |
|
666 AknLayoutScalable_Apps::main_cset6_slider_pane_g1( 2 ) ); |
|
667 |
|
668 if ( iSettingType == ECamSettingItemDynamicPhotoContrast || |
|
669 iSettingType == ECamSettingItemDynamicVideoContrast || |
|
670 iSettingType == ECamSettingItemUserSceneContrast ) |
|
671 { |
|
672 // Set the shaft layout for Contrast slider |
|
673 iShaftLayout.LayoutRect( Rect(), |
|
674 AknLayoutScalable_Apps::cset6_slider_pane( 5 ) ); |
|
675 // set Contrast slider legend layouts |
|
676 NonTouchContrastLayoutL( Rect() ); |
|
677 } |
|
678 else |
|
679 { |
|
680 // Set the shaft layout for EV slider |
|
681 iShaftLayout.LayoutRect( Rect(), |
|
682 AknLayoutScalable_Apps::cset6_slider_pane( 6 ) ); |
|
683 // set EV slider legend layouts |
|
684 NonTouchEVLayoutL( Rect() ); |
|
685 } |
|
686 } |
|
687 |
|
688 // ----------------------------------------------------------------------------- |
|
689 // CCamCaptureSetupSlider::TouchContrastLayoutL |
|
690 // ----------------------------------------------------------------------------- |
|
691 // |
|
692 void CCamCaptureSetupSlider::TouchContrastLayoutL( const TRect& aParentRect ) |
|
693 { |
|
694 TInt resourceId = ROID(R_CAM_CAPTURE_SETUP_SLIDER_CONTRAST_ARRAY_ID); |
|
695 TResourceReader reader; |
|
696 iEikonEnv->CreateResourceReaderLC( reader, resourceId ); |
|
697 |
|
698 const TInt count = reader.ReadInt16(); |
|
699 |
|
700 // Read all EV entries from the resource file and construct them with layout |
|
701 for ( TInt i = 0; i < count; i++ ) |
|
702 { |
|
703 CCamSliderLegend* legend = new ( ELeave ) CCamSliderLegend( iFullySkinned ); |
|
704 CleanupStack::PushL( legend ); |
|
705 switch ( i ) |
|
706 { |
|
707 case KContrastPlusInd : |
|
708 { |
|
709 legend->ConstructTextL( |
|
710 reader, |
|
711 aParentRect, |
|
712 AknLayoutScalable_Apps::main_cset_slider_pane_t14( 5 ) ); |
|
713 } |
|
714 break; |
|
715 case KContrastMinusInd : |
|
716 { |
|
717 legend->ConstructTextL( |
|
718 reader, |
|
719 aParentRect, |
|
720 AknLayoutScalable_Apps::main_cset_slider_pane_t15( 5 ) ); |
|
721 } |
|
722 break; |
|
723 case KContrastIconInd : |
|
724 { |
|
725 legend->ConstructIconL( |
|
726 reader, |
|
727 aParentRect, |
|
728 AknLayoutScalable_Apps::main_cset_slider_pane_g15( 2 ) ); |
|
729 } |
|
730 break; |
|
731 default: |
|
732 { |
|
733 } |
|
734 break; |
|
735 } |
|
736 User::LeaveIfError( iLegendArray.Append( legend ) ); |
|
737 CleanupStack::Pop( legend ); |
|
738 } |
|
739 |
|
740 CleanupStack::PopAndDestroy(); // reader |
|
741 } |
|
742 |
|
743 // ----------------------------------------------------------------------------- |
|
744 // CCamCaptureSetupSlider::NonTouchContrastLayoutL |
|
745 // ----------------------------------------------------------------------------- |
|
746 // |
|
747 void CCamCaptureSetupSlider::NonTouchContrastLayoutL( |
|
748 const TRect& aParentRect ) |
|
749 { |
|
750 TInt resourceId = ROID(R_CAM_CAPTURE_SETUP_SLIDER_CONTRAST_ARRAY_ID); |
|
751 TResourceReader reader; |
|
752 iEikonEnv->CreateResourceReaderLC( reader, resourceId ); |
|
753 |
|
754 const TInt count = reader.ReadInt16(); |
|
755 |
|
756 // Read all EV entries from the resource file |
|
757 // and construct them with layout |
|
758 for ( TInt i = 0; i < count; i++ ) |
|
759 { |
|
760 CCamSliderLegend* legend = new ( ELeave ) CCamSliderLegend; |
|
761 CleanupStack::PushL( legend ); |
|
762 switch ( i ) |
|
763 { |
|
764 case KContrastPlusInd : |
|
765 { |
|
766 legend->ConstructTextL( |
|
767 reader, |
|
768 aParentRect, |
|
769 AknLayoutScalable_Apps::main_cset6_slider_pane_t14( 5 ) ); |
|
770 } |
|
771 break; |
|
772 case KContrastMinusInd : |
|
773 { |
|
774 legend->ConstructTextL( |
|
775 reader, |
|
776 aParentRect, |
|
777 AknLayoutScalable_Apps::main_cset6_slider_pane_t15( 5 ) ); |
|
778 } |
|
779 break; |
|
780 case KContrastIconInd : |
|
781 { |
|
782 legend->ConstructIconL( |
|
783 reader, |
|
784 aParentRect, |
|
785 AknLayoutScalable_Apps::main_cset6_slider_pane_g15( 2 ) ); |
|
786 } |
|
787 break; |
|
788 default: |
|
789 { |
|
790 } |
|
791 break; |
|
792 } |
|
793 User::LeaveIfError( iLegendArray.Append( legend ) ); |
|
794 CleanupStack::Pop( legend ); |
|
795 } |
|
796 |
|
797 CleanupStack::PopAndDestroy(); // reader |
|
798 } |
|
799 |
|
800 // ----------------------------------------------------------------------------- |
|
801 // CCamCaptureSetupSlider::TouchEVLayoutL |
|
802 // ----------------------------------------------------------------------------- |
|
803 // |
|
804 void CCamCaptureSetupSlider::TouchEVLayoutL( const TRect& aParentRect ) |
|
805 { |
|
806 TInt resourceId = ROID(R_CAM_CAPTURE_SETUP_SLIDER_EV_ARRAY_ID); |
|
807 TResourceReader reader; |
|
808 iEikonEnv->CreateResourceReaderLC( reader, resourceId ); |
|
809 |
|
810 const TInt count = reader.ReadInt16(); |
|
811 |
|
812 // Read all Contrast entries from the resource file |
|
813 // and construct them with layout |
|
814 for ( TInt i = 0; i < count; i++ ) |
|
815 { |
|
816 CCamSliderLegend* legend = new ( ELeave ) CCamSliderLegend( iFullySkinned ); |
|
817 CleanupStack::PushL( legend ); |
|
818 switch ( i ) |
|
819 { |
|
820 case KEVPlus20Ind : |
|
821 { |
|
822 legend->ConstructTextL( |
|
823 reader, |
|
824 aParentRect, |
|
825 AknLayoutScalable_Apps::main_cset_slider_pane_t1( 6 ) ); |
|
826 } |
|
827 break; |
|
828 case KEVPlus15Ind : |
|
829 { |
|
830 legend->ConstructTextL( |
|
831 reader, |
|
832 aParentRect, |
|
833 AknLayoutScalable_Apps::main_cset_slider_pane_t8( 2 ) ); |
|
834 } |
|
835 break; |
|
836 case KEVPlus10Ind : |
|
837 { |
|
838 legend->ConstructTextL( |
|
839 reader, |
|
840 aParentRect, |
|
841 AknLayoutScalable_Apps::main_cset_slider_pane_t2( 3 ) ); |
|
842 } |
|
843 break; |
|
844 case KEVPlus05Ind : |
|
845 { |
|
846 legend->ConstructTextL( |
|
847 reader, |
|
848 aParentRect, |
|
849 AknLayoutScalable_Apps::main_cset_slider_pane_t9( 2 ) ); |
|
850 } |
|
851 break; |
|
852 case KEV0Ind : |
|
853 { |
|
854 legend->ConstructTextL( |
|
855 reader, |
|
856 aParentRect, |
|
857 AknLayoutScalable_Apps::main_cset_slider_pane_t3( 3 ) ); |
|
858 } |
|
859 break; |
|
860 case KEVMinus05Ind : |
|
861 { |
|
862 legend->ConstructTextL( |
|
863 reader, |
|
864 aParentRect, |
|
865 AknLayoutScalable_Apps::main_cset_slider_pane_t10( 2 ) ); |
|
866 } |
|
867 break; |
|
868 case KEVMinus10Ind : |
|
869 { |
|
870 legend->ConstructTextL( |
|
871 reader, |
|
872 aParentRect, |
|
873 AknLayoutScalable_Apps::main_cset_slider_pane_t4( 3 ) ); |
|
874 } |
|
875 break; |
|
876 case KEVMinus15Ind : |
|
877 { |
|
878 legend->ConstructTextL( |
|
879 reader, |
|
880 aParentRect, |
|
881 AknLayoutScalable_Apps::main_cset_slider_pane_t11( 2 ) ); |
|
882 } |
|
883 break; |
|
884 case KEVMinus20Ind : |
|
885 { |
|
886 legend->ConstructTextL( |
|
887 reader, |
|
888 aParentRect, |
|
889 AknLayoutScalable_Apps::main_cset_slider_pane_t5( 3 ) ); |
|
890 } |
|
891 break; |
|
892 default: |
|
893 { |
|
894 } |
|
895 break; |
|
896 } |
|
897 User::LeaveIfError( iLegendArray.Append( legend ) ); |
|
898 CleanupStack::Pop( legend ); |
|
899 } |
|
900 |
|
901 CleanupStack::PopAndDestroy(); // reader |
|
902 } |
|
903 |
|
904 |
|
905 |
|
906 // ----------------------------------------------------------------------------- |
|
907 // CCamCaptureSetupSlider::NonTouchEVLayoutL |
|
908 // ----------------------------------------------------------------------------- |
|
909 // |
|
910 void CCamCaptureSetupSlider::NonTouchEVLayoutL( const TRect& aParentRect ) |
|
911 { |
|
912 TInt resourceId = ROID(R_CAM_CAPTURE_SETUP_SLIDER_EV_ARRAY_ID); |
|
913 TResourceReader reader; |
|
914 iEikonEnv->CreateResourceReaderLC( reader, resourceId ); |
|
915 |
|
916 const TInt count = reader.ReadInt16(); |
|
917 |
|
918 // Read all Contrast entries from the resource file |
|
919 // and construct them with layout |
|
920 for ( TInt i = 0; i < count; i++ ) |
|
921 { |
|
922 CCamSliderLegend* legend = new ( ELeave ) CCamSliderLegend; |
|
923 CleanupStack::PushL( legend ); |
|
924 switch ( i ) |
|
925 { |
|
926 case KEVPlus20Ind : |
|
927 { |
|
928 legend->ConstructTextL( reader, aParentRect, |
|
929 AknLayoutScalable_Apps::main_cset6_slider_pane_t1( 5 ) ); |
|
930 } |
|
931 break; |
|
932 case KEVPlus15Ind : |
|
933 { |
|
934 legend->ConstructTextL( reader, aParentRect, |
|
935 AknLayoutScalable_Apps::main_cset6_slider_pane_t8( 2 ) ); |
|
936 } |
|
937 break; |
|
938 case KEVPlus10Ind : |
|
939 { |
|
940 legend->ConstructTextL( reader, aParentRect, |
|
941 AknLayoutScalable_Apps::main_cset6_slider_pane_t2( 3 ) ); |
|
942 } |
|
943 break; |
|
944 case KEVPlus05Ind : |
|
945 { |
|
946 legend->ConstructTextL( reader, aParentRect, |
|
947 AknLayoutScalable_Apps::main_cset6_slider_pane_t9( 2 ) ); |
|
948 } |
|
949 break; |
|
950 case KEV0Ind : |
|
951 { |
|
952 legend->ConstructTextL( reader, aParentRect, |
|
953 AknLayoutScalable_Apps::main_cset6_slider_pane_t3( 3 ) ); |
|
954 } |
|
955 break; |
|
956 case KEVMinus05Ind : |
|
957 { |
|
958 legend->ConstructTextL( reader, aParentRect, |
|
959 AknLayoutScalable_Apps::main_cset6_slider_pane_t10( 2 ) ); |
|
960 } |
|
961 break; |
|
962 case KEVMinus10Ind : |
|
963 { |
|
964 legend->ConstructTextL( reader, aParentRect, |
|
965 AknLayoutScalable_Apps::main_cset6_slider_pane_t4( 3 ) ); |
|
966 } |
|
967 break; |
|
968 case KEVMinus15Ind : |
|
969 { |
|
970 legend->ConstructTextL( reader, aParentRect, |
|
971 AknLayoutScalable_Apps::main_cset6_slider_pane_t11( 2 ) ); |
|
972 } |
|
973 break; |
|
974 case KEVMinus20Ind : |
|
975 { |
|
976 legend->ConstructTextL( reader, aParentRect, |
|
977 AknLayoutScalable_Apps::main_cset6_slider_pane_t5( 3 ) ); |
|
978 } |
|
979 break; |
|
980 default: |
|
981 break; |
|
982 } |
|
983 User::LeaveIfError( iLegendArray.Append( legend ) ); |
|
984 CleanupStack::Pop( legend ); |
|
985 } |
|
986 |
|
987 CleanupStack::PopAndDestroy(); // reader |
|
988 } |
|
989 |
|
990 // ----------------------------------------------------------------------------- |
|
991 // CCamCaptureSetupSlider::HandlePointerEventL |
|
992 // Handles slider pointer events |
|
993 // ----------------------------------------------------------------------------- |
|
994 // |
|
995 void CCamCaptureSetupSlider::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
996 { |
|
997 if( !Rect().Contains(aPointerEvent.iPosition) && iBitmapThumbCurrent != iBitmapThumbSelected ) |
|
998 { |
|
999 return; |
|
1000 } |
|
1001 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
1002 |
|
1003 // This is the max bitmap offset from the top of the shaft that the thumb can be |
|
1004 TInt maxVOffset = iShaftLayout.Rect().Size().iHeight - iBitmapThumb->SizeInPixels().iHeight; |
|
1005 |
|
1006 // This is the no. of pixels for a "step" |
|
1007 TInt stepInPixels = ( maxVOffset * KDivisorFactor ) / iNumSliderValues; |
|
1008 |
|
1009 // Calculate new setting value |
|
1010 TInt oldValue = iValue; |
|
1011 TInt deltaY = aPointerEvent.iPosition.iY - iShaftLayout.Rect().iTl.iY; |
|
1012 TInt nbrSteps = deltaY / ( stepInPixels / KDivisorFactor ); |
|
1013 iValue = iMaxSliderValue - nbrSteps; |
|
1014 |
|
1015 if ( iValue < iMinSliderValue ) |
|
1016 { |
|
1017 iValue = iMinSliderValue; |
|
1018 } |
|
1019 |
|
1020 if (iValue > iMaxSliderValue) |
|
1021 { |
|
1022 iValue = iMaxSliderValue; |
|
1023 } |
|
1024 |
|
1025 if ( iValue != oldValue && aPointerEvent.iType == TPointerEvent::EDrag ) |
|
1026 { |
|
1027 MTouchFeedback* feedback = MTouchFeedback::Instance(); |
|
1028 if ( feedback ) |
|
1029 { |
|
1030 feedback->InstantFeedback( ETouchFeedbackSensitive ); |
|
1031 } |
|
1032 } |
|
1033 |
|
1034 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
1035 { |
|
1036 // Change thumb marker to selected |
|
1037 iBitmapThumbCurrent = iBitmapThumbSelected; |
|
1038 iBitmapThumbCurrentMask = iBitmapThumbSelectedMask; |
|
1039 } |
|
1040 |
|
1041 if ( aPointerEvent.iType == TPointerEvent::EButton1Up ) |
|
1042 { |
|
1043 // Change thumb marker to normal |
|
1044 iBitmapThumbCurrent = iBitmapThumb; |
|
1045 iBitmapThumbCurrentMask = iBitmapThumbMask; |
|
1046 } |
|
1047 |
|
1048 iSettingObserver->HandleSettingValueUpdateL( iValue ); // Tell observer about change |
|
1049 DrawNow(); |
|
1050 static_cast<CCamAppUi*>( iCoeEnv->AppUi() )-> |
|
1051 AppController().StartIdleTimer(); |
|
1052 } |
|
1053 |
|
1054 // End of File |
|
1055 |
|