26 |
26 |
27 #include <telbubblecallimage.h> |
27 #include <telbubblecallimage.h> |
28 #include <AknIconUtils.h> |
28 #include <AknIconUtils.h> |
29 #include <layoutmetadata.cdl.h> |
29 #include <layoutmetadata.cdl.h> |
30 |
30 |
|
31 #define SCALE_FACTOR 1.5 |
|
32 |
31 // --------------------------------------------------------------------------- |
33 // --------------------------------------------------------------------------- |
32 // C++ constructor |
34 // C++ constructor |
33 // --------------------------------------------------------------------------- |
35 // --------------------------------------------------------------------------- |
34 // |
36 // |
35 CBubbleMainPaneControl::CBubbleMainPaneControl( |
37 CBubbleMainPaneControl::CBubbleMainPaneControl( |
36 CBubbleManager& aBubbleManager, |
38 CBubbleManager& aBubbleManager, |
37 CBubbleCallObjectManager& aCallObjectManager ) : |
39 CBubbleCallObjectManager& aCallObjectManager ) : |
38 iBubbleManager( aBubbleManager ), |
40 iBubbleManager( aBubbleManager ), |
39 iCallObjectManager ( aCallObjectManager ) |
41 iCallObjectManager ( aCallObjectManager ), |
|
42 iScaler( NULL ), |
|
43 iScaledImage( NULL ) |
40 { |
44 { |
41 } |
45 } |
42 |
46 |
43 // --------------------------------------------------------------------------- |
47 // --------------------------------------------------------------------------- |
44 // ConstructL |
48 // ConstructL |
45 // --------------------------------------------------------------------------- |
49 // --------------------------------------------------------------------------- |
46 // |
50 // |
47 void CBubbleMainPaneControl::ConstructL() |
51 void CBubbleMainPaneControl::ConstructL() |
48 { |
52 { |
|
53 iScaler = CTelBubbleImageScaler::NewL( *this ); |
49 } |
54 } |
50 |
55 |
51 // --------------------------------------------------------------------------- |
56 // --------------------------------------------------------------------------- |
52 // NewL |
57 // NewL |
53 // --------------------------------------------------------------------------- |
58 // --------------------------------------------------------------------------- |
70 // Destructor |
75 // Destructor |
71 // --------------------------------------------------------------------------- |
76 // --------------------------------------------------------------------------- |
72 // |
77 // |
73 CBubbleMainPaneControl::~CBubbleMainPaneControl() |
78 CBubbleMainPaneControl::~CBubbleMainPaneControl() |
74 { |
79 { |
|
80 delete iScaler; |
|
81 iScaler = NULL; |
|
82 |
|
83 delete iScaledImage; |
|
84 iScaledImage = NULL; |
75 } |
85 } |
76 |
86 |
77 // --------------------------------------------------------------------------- |
87 // --------------------------------------------------------------------------- |
78 // ReadBubbleHeader |
88 // ReadBubbleHeader |
79 // --------------------------------------------------------------------------- |
89 // --------------------------------------------------------------------------- |
80 // |
90 // |
81 void CBubbleMainPaneControl::ReadBubbleHeader( |
91 void CBubbleMainPaneControl::ReadBubbleHeader( |
82 const CBubbleHeader& aHeader ) |
92 const CBubbleHeader& aHeader ) |
83 { |
93 { |
84 iBubble = aHeader.BubbleId(); |
94 iBubble = aHeader.BubbleId(); |
85 iBitmap = aHeader.CallObjectImage(); |
95 TBool thumbnail( EFalse ); |
86 iMask = aHeader.CallObjectImageMask(); |
96 TBool noScaling( EFalse ); |
|
97 |
|
98 if ( aHeader.CallObjectImage() ) |
|
99 { |
|
100 iBitmap = aHeader.CallObjectImage(); |
|
101 iMask = aHeader.CallObjectImageMask(); |
|
102 } |
|
103 else if ( aHeader.TnBitmap() ) |
|
104 { |
|
105 iBitmap = aHeader.TnBitmap(); |
|
106 iMask = aHeader.TnBitmapMask(); |
|
107 thumbnail = ETrue; |
|
108 } |
|
109 else |
|
110 { |
|
111 iBitmap = NULL; |
|
112 } |
|
113 |
87 iThreeLinedBubble = ( aHeader.CNAP().Length() > 0 ); |
114 iThreeLinedBubble = ( aHeader.CNAP().Length() > 0 ); |
88 |
115 |
|
116 // PrepareBitmapsL() needs to know if a brand new thumbnail is about to get prepared. |
|
117 if ( thumbnail && (iOldBitmap != NULL) && (iOldBitmap == iBitmap) && (iScaler->GetState() != CTelBubbleImageScaler::EScalingStarted) ) |
|
118 { |
|
119 noScaling = ETrue; |
|
120 } |
|
121 |
89 if ( iBitmap ) |
122 if ( iBitmap ) |
90 { |
123 { |
91 CFbsBitmap* bitmap; |
124 iOldBitmap = iBitmap; |
92 CFbsBitmap* mask; |
125 |
93 TBool bitmapOwnership; |
126 CFbsBitmap* bitmap( NULL ); |
94 TBool maskOwnership; |
127 CFbsBitmap* mask( NULL ); |
|
128 TBool bitmapOwnership( EFalse ); |
|
129 TBool maskOwnership( EFalse ); |
95 |
130 |
96 TRAPD(err, PrepareBitmapsL( bitmap, |
131 TRAPD(err, PrepareBitmapsL( bitmap, |
97 bitmapOwnership, |
132 bitmapOwnership, |
98 mask, |
133 mask, |
99 maskOwnership, |
134 maskOwnership, |
100 aHeader.CallObjectImageType() == |
135 aHeader.CallObjectImageType() == |
101 CBubbleHeader::EThemeImage ) ); |
136 CBubbleHeader::EThemeImage, |
|
137 noScaling )); |
102 |
138 |
103 if ( err ) |
139 if ( err ) |
104 { |
140 { |
105 return; |
141 return; |
106 } |
142 } |
117 image->SetImage( bitmap, EFalse, mask, maskOwnership ); |
153 image->SetImage( bitmap, EFalse, mask, maskOwnership ); |
118 } |
154 } |
119 |
155 |
120 iIsUsed = ETrue; |
156 iIsUsed = ETrue; |
121 MakeVisible( ETrue ); |
157 MakeVisible( ETrue ); |
|
158 |
|
159 // upscale thumbnails if loading it for the first time. |
|
160 if ( thumbnail && !noScaling && ( iScaler->GetState() != CTelBubbleImageScaler::EScalingStarted ) ) |
|
161 { |
|
162 StartScaling( iBitmap ); |
|
163 } |
122 } |
164 } |
123 } |
165 } |
124 |
166 |
125 // --------------------------------------------------------------------------- |
167 // --------------------------------------------------------------------------- |
126 // PrepareBitmapsL |
168 // PrepareBitmapsL |
129 void CBubbleMainPaneControl::PrepareBitmapsL( |
171 void CBubbleMainPaneControl::PrepareBitmapsL( |
130 CFbsBitmap*& aBitmap, |
172 CFbsBitmap*& aBitmap, |
131 TBool& aBitmapOwnership, |
173 TBool& aBitmapOwnership, |
132 CFbsBitmap*& aMask, |
174 CFbsBitmap*& aMask, |
133 TBool& aMaskOwnership, |
175 TBool& aMaskOwnership, |
134 TBool aIsScalable ) |
176 TBool aIsScalable, |
135 { |
177 TBool aThumbnail ) |
136 aBitmap = iBitmap; |
178 { |
|
179 if ( aThumbnail ) |
|
180 { |
|
181 aBitmap = iScaledImage; |
|
182 } |
|
183 else |
|
184 { |
|
185 aBitmap = iBitmap; |
|
186 } |
|
187 |
137 aMask = iMask; |
188 aMask = iMask; |
138 aBitmapOwnership = EFalse; |
189 aBitmapOwnership = EFalse; |
139 aMaskOwnership = EFalse; |
190 aMaskOwnership = EFalse; |
140 |
191 |
141 if ( aIsScalable ) |
192 if ( aIsScalable ) |
276 image->SetImagePlacingArea( imageArea ); |
327 image->SetImagePlacingArea( imageArea ); |
277 } |
328 } |
278 } |
329 } |
279 } |
330 } |
280 |
331 |
|
332 // --------------------------------------------------------------------------- |
|
333 // CTelBubbleCallImage::ImageScalingComplete |
|
334 // |
|
335 // --------------------------------------------------------------------------- |
|
336 // |
|
337 void CBubbleMainPaneControl::ImageScalingComplete( TInt aError, |
|
338 CFbsBitmap* aBitmap ) |
|
339 { |
|
340 if ( aError == KErrNone ) |
|
341 { |
|
342 // Draw the scaled image |
|
343 iScaledImage = aBitmap; |
|
344 iScaler->SetState( CTelBubbleImageScaler::EScalingDone ); |
|
345 |
|
346 CFbsBitmap* bitmap( NULL ); |
|
347 CFbsBitmap* mask( NULL ); |
|
348 TBool bitmapOwnership( EFalse ); |
|
349 TBool maskOwnership( EFalse ); |
|
350 |
|
351 TRAPD(err, PrepareBitmapsL( bitmap, |
|
352 bitmapOwnership, |
|
353 mask, |
|
354 maskOwnership, |
|
355 EFalse, |
|
356 ETrue ) ); |
|
357 |
|
358 if ( err ) |
|
359 { |
|
360 return; |
|
361 } |
|
362 |
|
363 if ( iCallImage->ControlType() == |
|
364 CTelBubbleCustomElement::EBubbleCallImage ) |
|
365 { |
|
366 CTelBubbleCallImage* image = |
|
367 static_cast<CTelBubbleCallImage*> ( iCallImage->Control() ); |
|
368 image->SetImage( bitmap, EFalse, mask, maskOwnership ); |
|
369 } |
|
370 |
|
371 SizeChanged(); |
|
372 |
|
373 iIsUsed = ETrue; |
|
374 MakeVisible( ETrue ); |
|
375 |
|
376 Parent()->DrawNow(); // refreshing view with scaled image |
|
377 } |
|
378 else if ( aError == KErrCancel ) |
|
379 { |
|
380 // error is ignored |
|
381 // This error is returned when a previous scaling is cancelled |
|
382 // while new scaling request is given to active object |
|
383 } |
|
384 else |
|
385 { |
|
386 // draw the unscaled image in error cases |
|
387 |
|
388 delete iScaledImage; |
|
389 iScaledImage = NULL; |
|
390 } |
|
391 |
|
392 iScaler->SetState( CTelBubbleImageScaler::EScalingDone ); |
|
393 } |
|
394 |
|
395 // --------------------------------------------------------------------------- |
|
396 // CTelBubbleCallImage::StartScaling |
|
397 // |
|
398 // --------------------------------------------------------------------------- |
|
399 // |
|
400 void CBubbleMainPaneControl::StartScaling( CFbsBitmap *aSourceBitmap ) |
|
401 { |
|
402 if ( !iScaler ) |
|
403 { |
|
404 return; |
|
405 } |
|
406 |
|
407 iScaler->Cancel(); // cancels any outstanding scaling requests |
|
408 |
|
409 delete iScaledImage; |
|
410 iScaledImage = NULL; |
|
411 |
|
412 // create a bitmap for scaled size |
|
413 TRAPD( err, iScaledImage = new (ELeave) CFbsBitmap ); |
|
414 if ( err != KErrNone ) |
|
415 { |
|
416 // no scaling in error cases |
|
417 iScaler->SetState( CTelBubbleImageScaler::EScalingIdle ); |
|
418 return; |
|
419 } |
|
420 |
|
421 TSize size = aSourceBitmap->SizeInPixels(); |
|
422 TRect scaledRect( 0, 0, size.iWidth * SCALE_FACTOR, size.iHeight * SCALE_FACTOR ); |
|
423 |
|
424 TRAP( err, iScaledImage->Create( scaledRect.Size(), aSourceBitmap->DisplayMode() ) ); |
|
425 if ( err != KErrNone ) |
|
426 { |
|
427 delete iScaledImage; |
|
428 iScaledImage = NULL; |
|
429 iScaler->SetState( CTelBubbleImageScaler::EScalingIdle ); |
|
430 } |
|
431 else |
|
432 { |
|
433 //start scaling |
|
434 TRAPD( err, iScaler->StartScaleL( aSourceBitmap, iScaledImage ) ); |
|
435 if (err != KErrNone) |
|
436 { |
|
437 iScaler->SetState( CTelBubbleImageScaler::EScalingIdle ); |
|
438 delete iScaledImage; |
|
439 iScaledImage = NULL; |
|
440 } |
|
441 } |
|
442 } |
|
443 |
281 // END OF FILE |
444 // END OF FILE |
282 |
445 |