photosgallery/viewframework/layouts/src/glxzoomlayoutbase.cpp
branchRCL_3
changeset 18 bcb43dc84c44
parent 14 ce1c7ad1f18b
child 22 2dac0fdba72b
equal deleted inserted replaced
14:ce1c7ad1f18b 18:bcb43dc84c44
     1 /*
       
     2 * Copyright (c) 2008-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:    Implementation of TGlxZoomLayoutBase
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "glxzoomlayoutbase.h"
       
    24 
       
    25 #include <alf/alftimedvalue.h>
       
    26 
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // -----------------------------------------------------------------------------
       
    30 // C++ default constructor can NOT contain any code, that might leave.
       
    31 // -----------------------------------------------------------------------------
       
    32 //
       
    33 EXPORT_C TGlxZoomLayoutBase::TGlxZoomLayoutBase()
       
    34     {
       
    35     }
       
    36 
       
    37 // -----------------------------------------------------------------------------
       
    38 // Destructor
       
    39 // -----------------------------------------------------------------------------
       
    40 //
       
    41 EXPORT_C TGlxZoomLayoutBase::~TGlxZoomLayoutBase()
       
    42     {
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // SetImageDimensions
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 EXPORT_C void TGlxZoomLayoutBase::SetImageDimensions(const TSize& aDimensions)
       
    50     {
       
    51     iImageDimensions = aDimensions;
       
    52     iChanged = ETrue;
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // ImageDimensions
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 EXPORT_C const TSize& TGlxZoomLayoutBase::ImageDimensions() const
       
    60     {
       
    61     return iImageDimensions;
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // DoSetLayoutValues
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 EXPORT_C void TGlxZoomLayoutBase::DoSetLayoutValues(TGlxLayoutInfo& aInfo)
       
    69     {
       
    70     TAlfRealRect rect;
       
    71     GetCurrentCoords(rect);
       
    72 
       
    73     // These checks on iImageDimensions width/height must occur after GetCurrentCoords,
       
    74   /*  // since they may be changed as a result of the call to GetCurrentCoords
       
    75     if ( iImageDimensions.iWidth > 0 && iImageDimensions.iHeight > 0 )
       
    76         {
       
    77         // The previous layout in the chain has set the position and size for
       
    78         // the visual to fill the screen, so we base the values on that.
       
    79 
       
    80         // Now adjust according to zoom coordinates
       
    81         TAlfRealPoint centre = rect.Center();        
       
    82         TReal32 width = aInfo.iScreenSize.iX * rect.Width();
       
    83         TReal32 height = aInfo.iScreenSize.iY * rect.Height();
       
    84 
       
    85         // Adjust size according to proportion of screen that image fills
       
    86         // Account for TGlxRotationLayout swapping width and height
       
    87         TAlfRealSize imageSize(iImageDimensions);
       
    88         TAlfRealSize screenSize(aInfo.ScreenInfo()->iWidth,
       
    89                                 aInfo.ScreenInfo()->iHeight);
       
    90         if ( screenSize.iHeight * imageSize.iWidth
       
    91                 < imageSize.iHeight * screenSize.iWidth )
       
    92             {
       
    93             // Screen has wider aspect than image
       
    94             TReal32 sizeRatioX = (screenSize.iHeight * imageSize.iWidth)
       
    95                                 / (screenSize.iWidth * imageSize.iHeight);
       
    96             if ( aInfo.iRotation )
       
    97                 {
       
    98                 // Rotated
       
    99                 height *= sizeRatioX;
       
   100                 }
       
   101             else
       
   102                 {
       
   103                 // Normal
       
   104                 width *= sizeRatioX;
       
   105                 }
       
   106             }
       
   107         else
       
   108             {
       
   109             // Screen has taller aspect than image
       
   110             TReal32 sizeRatioY = (screenSize.iWidth * imageSize.iHeight)
       
   111                                 / (screenSize.iHeight * imageSize.iWidth);
       
   112             if ( aInfo.iRotation )
       
   113                 {
       
   114                 // Rotated
       
   115                 width *= sizeRatioY;
       
   116                 }
       
   117             else
       
   118                 {
       
   119                 // Normal
       
   120                 height *= sizeRatioY;
       
   121                 }
       
   122             }
       
   123 
       
   124         aInfo.iPosition.iX += centre.iX * aInfo.iSize.iX;
       
   125         aInfo.iPosition.iY += centre.iY * aInfo.iSize.iY;
       
   126         aInfo.iSize.iX = width;
       
   127         aInfo.iSize.iY = height;
       
   128         }
       
   129 */
       
   130     }
       
   131 
       
   132 
       
   133 //  End of File