phoneuis/BubbleManager/bmcustomization/src/telbubblecallimage.cpp
branchRCL_3
changeset 57 94dc1107e8b2
parent 44 3c221667e687
--- a/phoneuis/BubbleManager/bmcustomization/src/telbubblecallimage.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneuis/BubbleManager/bmcustomization/src/telbubblecallimage.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -203,60 +203,68 @@
         {
         return;                    
         }
-    
-    // If bitmap is bigger than drawing area then clip from center.
-    TRect rect;
-    if ( IsFullScreenImage() )
-        {
-        rect = Rect();
-        }
-    else
-        {
-        rect = ImagePlacingArea();
-        }
-    
+        
+    // If bitmap is bigger than drawing area then clip from center of the image.
+    TRect rect = Rect();
     iSourceRect = iImage->SizeInPixels();
-    
+
     TInt offsetX = ( iSourceRect.Width() > rect.Width() ) ? 
                    ((iSourceRect.Width() - rect.Width()) / 2) : 0;
     TInt offsetY = ( iSourceRect.Height() > rect.Height() ) ? 
                    ((iSourceRect.Height() - rect.Height()) / 2) : 0;
-    iSourceRect.Shrink( offsetX, offsetY );    
     
-    // If bitmap is smaller than drawing area then center it.
+    iSourceRect.Shrink( offsetX, offsetY ); 
+    
+    // If bitmap is smaller than the drawing area then center the image on it.
     iOffset.iX = ( iSourceRect.Width() < rect.Width() ) ? 
                 ((rect.Width() - iSourceRect.Width()) / 2) : 0;
-    iOffset.iY = ( iSourceRect.Height() < rect.Height() ) ? 
-                ((rect.Height() - iSourceRect.Height()) / 2) : 0;
+    
+    iOffset.iY = 0;
+    
+    // lift the image higher if needed.
+    if ( iSourceRect.Height() < rect.Height() )
+        {
+        // check if it fits totally above the bubble
+        TInt height = iImagePlacingArea.iBr.iY - iImagePlacingArea.iTl.iY;
+      
+        if ( iSourceRect.Height() < height )
+            {
+            // if it fits then center it above the bubble
+            iOffset.iY = ( height - iSourceRect.Height() ) / 2;
+            }
+        }
     }
 
-
 // ---------------------------------------------------------------------------
 // CTelBubbleCallImage::Draw
 // ---------------------------------------------------------------------------
 //
 EXPORT_C void CTelBubbleCallImage::Draw( const TRect& /*aRect*/ ) const
     {
-    if ( iImage ) 
+    if ( iImage )
         {
         CWindowGc& gc = SystemGc();
-        const TPoint topLeft = IsFullScreenImage() ? Rect().iTl : iImagePlacingArea.iTl;
+    
+        const TPoint topLeft = Rect().iTl;
         const TPoint bitmapTopLeft = topLeft + iOffset;
-       
-        if( iMask ) 
+    
+        // if we have y offset then the image wont go under the bubble in any case and so
+        // no need for masking
+        if ( iMask && iOffset.iY == 0 ) 
             {
             gc.BitBltMasked( bitmapTopLeft,
-                             iImage, 
-                             iSourceRect, 
-                             iMask, 
-                             EFalse );
+                         iImage, 
+                         iSourceRect, 
+                         iMask, 
+                         EFalse );
             }
-        else            
+        else
             {
             gc.BitBlt( bitmapTopLeft,
-                       iImage,
-                       iSourceRect );    
+                   iImage,
+                   iSourceRect );    
             }
+    
         DrawRoundRect( gc, bitmapTopLeft, iSourceRect.Size() );
         }
     }