71 const TInt KLongTapStartLongDelay( 500000 ); // 0.5s |
71 const TInt KLongTapStartLongDelay( 500000 ); // 0.5s |
72 const TInt KLongTapTimeShortDelay( 600000 ); // 0.6s for SK |
72 const TInt KLongTapTimeShortDelay( 600000 ); // 0.6s for SK |
73 const TInt KLongTapTimeLongDelay( 1500000 ); // 1.5s |
73 const TInt KLongTapTimeLongDelay( 1500000 ); // 1.5s |
74 |
74 |
75 const TInt KDragThreshold = 20; // pixels |
75 const TInt KDragThreshold = 20; // pixels |
|
76 |
|
77 const TReal KEps( 3e-16 ); // proximite EPS value for double FP numbers |
76 |
78 |
77 // LOCAL FUNCTION PROTOTYPES |
79 // LOCAL FUNCTION PROTOTYPES |
78 static TRgb ConvertHslToRgb( TInt aHue, TInt aSaturation, TInt aLightness ); |
80 static TRgb ConvertHslToRgb( TInt aHue, TInt aSaturation, TInt aLightness ); |
79 static void ConvertRgbToHsl( TRgb aRGB, TUint& aHue, TUint& aSaturation, |
81 static void ConvertRgbToHsl( TRgb aRGB, TUint& aHue, TUint& aSaturation, |
80 TUint& aLightness ); |
82 TUint& aLightness ); |
3431 } |
3433 } |
3432 } |
3434 } |
3433 } |
3435 } |
3434 |
3436 |
3435 // ----------------------------------------------------------------------------- |
3437 // ----------------------------------------------------------------------------- |
|
3438 // Calculates scaled bitmap size (rect) |
|
3439 // ----------------------------------------------------------------------------- |
|
3440 // |
|
3441 void CalculateScaledBitmapRect( TSize& aScaledSize, const TSize& aDrawSize, |
|
3442 const TSize& aImageSize ) |
|
3443 { |
|
3444 //no scaling as default |
|
3445 TReal scaleRatio( 1.0f ); |
|
3446 aScaledSize.SetSize( aDrawSize.iWidth, aDrawSize.iHeight ); |
|
3447 |
|
3448 //If any dimension is 0, then we do not bother to scale |
|
3449 if ( aDrawSize.iWidth == 0 || aDrawSize.iHeight == 0 ) |
|
3450 { |
|
3451 return; |
|
3452 } |
|
3453 |
|
3454 TReal xRatio = |
|
3455 ( ( TReal )aImageSize.iWidth / ( TReal )aDrawSize.iWidth ); |
|
3456 TReal yRatio = |
|
3457 ( ( TReal )aImageSize.iHeight / ( TReal )aDrawSize.iHeight ); |
|
3458 //Find out appropriate scaling factor |
|
3459 xRatio > yRatio ? ( scaleRatio = xRatio ) : ( scaleRatio = yRatio ); |
|
3460 |
|
3461 // ratio is too small (can be considered as division by zero) |
|
3462 if ( scaleRatio < KEps && scaleRatio > -KEps ) |
|
3463 { |
|
3464 return; |
|
3465 } |
|
3466 |
|
3467 // Otherwise scaling can be done |
|
3468 aScaledSize.iWidth = ( TInt )( ( TReal )aImageSize.iWidth / scaleRatio ); |
|
3469 aScaledSize.iHeight = |
|
3470 ( TInt )( ( TReal )aImageSize.iHeight / scaleRatio ); |
|
3471 } |
|
3472 |
|
3473 // ----------------------------------------------------------------------------- |
3436 // BuildSwipeTriggerNodeLC |
3474 // BuildSwipeTriggerNodeLC |
3437 // Build trigger node for swipe event |
3475 // Build trigger node for swipe event |
3438 // ----------------------------------------------------------------------------- |
3476 // ----------------------------------------------------------------------------- |
3439 // |
3477 // |
3440 CXnNode* CXnControlAdapterImpl::BuildSwipeTriggerNodeLC( |
3478 CXnNode* CXnControlAdapterImpl::BuildSwipeTriggerNodeLC( |
4493 aGc.DrawRect( paddingRect ); |
4531 aGc.DrawRect( paddingRect ); |
4494 aGc.SetPenColor( KRgbRed ); |
4532 aGc.SetPenColor( KRgbRed ); |
4495 aGc.DrawRect( contentRect ); |
4533 aGc.DrawRect( contentRect ); |
4496 #endif |
4534 #endif |
4497 TRAP_IGNORE( DoDrawL( aRect, aGc ) ); |
4535 TRAP_IGNORE( DoDrawL( aRect, aGc ) ); |
4498 aGc.CancelClippingRect(); |
4536 // aGc.CancelClippingRect(); |
4499 } |
4537 } |
4500 |
4538 |
4501 // ----------------------------------------------------------------------------- |
4539 // ----------------------------------------------------------------------------- |
4502 // CXnControlAdapterImpl::ComponentControl |
4540 // CXnControlAdapterImpl::ComponentControl |
4503 // Return a child control by index |
4541 // Return a child control by index |
4967 } |
5005 } |
4968 } |
5006 } |
4969 |
5007 |
4970 TRect bitmapRect = rect; |
5008 TRect bitmapRect = rect; |
4971 bitmapRect.Move( -rect.iTl.iX, -rect.iTl.iY ); |
5009 bitmapRect.Move( -rect.iTl.iX, -rect.iTl.iY ); |
|
5010 // Finds appropriate method of scaling |
4972 if ( AknIconUtils::IsMifIcon( iContentBitmap ) ) |
5011 if ( AknIconUtils::IsMifIcon( iContentBitmap ) ) |
4973 { |
5012 { |
4974 if ( preserveAspectRatio ) |
5013 if ( preserveAspectRatio ) |
4975 { |
5014 { |
4976 AknIconUtils::SetSize( |
5015 AknIconUtils::SetSize( |
4977 iContentBitmap, bitmapRect.Size(), EAspectRatioPreserved ); |
5016 iContentBitmap, bitmapRect.Size(), |
|
5017 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
4978 AknIconUtils::SetSize( |
5018 AknIconUtils::SetSize( |
4979 iContentMask, bitmapRect.Size(), EAspectRatioPreserved ); |
5019 iContentMask, bitmapRect.Size(), |
|
5020 EAspectRatioPreservedAndUnusedSpaceRemoved ); |
|
5021 // In some cases resizing might fail with previous settings |
|
5022 if ( iContentBitmap->SizeInPixels().iHeight == 0 || |
|
5023 iContentBitmap->SizeInPixels().iWidth == 0 ) |
|
5024 { |
|
5025 AknIconUtils::SetSize( |
|
5026 iContentBitmap, bitmapRect.Size(), |
|
5027 EAspectRatioPreserved ); |
|
5028 AknIconUtils::SetSize( |
|
5029 iContentMask, bitmapRect.Size(), |
|
5030 EAspectRatioPreserved ); |
|
5031 } |
4980 } |
5032 } |
4981 else |
5033 else |
4982 { |
5034 { |
4983 AknIconUtils::SetSize( |
5035 AknIconUtils::SetSize( |
4984 iContentBitmap, bitmapRect.Size(), EAspectRatioNotPreserved ); |
5036 iContentBitmap, bitmapRect.Size(), EAspectRatioNotPreserved ); |
4985 AknIconUtils::SetSize( |
5037 AknIconUtils::SetSize( |
4986 iContentMask, bitmapRect.Size(), EAspectRatioNotPreserved ); |
5038 iContentMask, bitmapRect.Size(), EAspectRatioNotPreserved ); |
|
5039 } |
|
5040 // Set a new bitmap size |
|
5041 bitmapRect.SetSize( iContentBitmap->SizeInPixels() ); |
|
5042 } |
|
5043 else |
|
5044 { |
|
5045 if ( preserveAspectRatio ) |
|
5046 { |
|
5047 TSize newBitmapSize; |
|
5048 // scaling is done in bitmap drawing routine, here only the |
|
5049 // sacling rect is calculated |
|
5050 CalculateScaledBitmapRect( newBitmapSize, rect.Size(), |
|
5051 iContentBitmap->SizeInPixels() ); |
|
5052 bitmapRect.SetSize( newBitmapSize ); |
4987 } |
5053 } |
4988 } |
5054 } |
4989 |
5055 |
4990 // Calculate new point to start draw |
5056 // Calculate new point to start draw |
4991 // in order to center bitmap to drawing area |
5057 // in order to center bitmap to drawing area |
4992 rect.iTl.iY += |
5058 rect.iTl.iY += |
4993 ( rect.Height() - bitmapRect.Height() ) / 2; |
5059 ( rect.Height() - bitmapRect.Height() ) / 2; |
4994 rect.iTl.iX += |
5060 rect.iTl.iX += |
4995 ( rect.Width() - bitmapRect.Width() ) / 2; |
5061 ( rect.Width() - bitmapRect.Width() ) / 2; |
|
5062 // sets a new size to draw |
|
5063 rect.SetSize( bitmapRect.Size() ); |
4996 |
5064 |
4997 if ( iContentBitmap && iContentMask ) |
5065 if ( iContentBitmap && iContentMask ) |
4998 { |
5066 { |
4999 aGc.DrawBitmapMasked( rect, |
5067 aGc.DrawBitmapMasked( rect, |
5000 iContentBitmap, |
5068 iContentBitmap, |