23 |
23 |
24 // Includes for Logs |
24 // Includes for Logs |
25 #include <glxtracer.h> // For Tracer |
25 #include <glxtracer.h> // For Tracer |
26 #include <glxlog.h> // For Log |
26 #include <glxlog.h> // For Log |
27 |
27 |
28 #define BORDER_HEIGHT (iBorderWidth.iHeight*(100-((newZoomRatio-iMinZoomRatio)*100/(iMaxZoomRatio-iMinZoomRatio))))/100 |
|
29 #define BORDER_WIDTH (iBorderWidth.iWidth*(100-((newZoomRatio-iMinZoomRatio)*100/(iMaxZoomRatio-iMinZoomRatio))))/100 |
|
30 // LOCAL CONSTANTS AND MACROS |
28 // LOCAL CONSTANTS AND MACROS |
31 const TInt KGlxLargeImageMaximumZoomRatio = 100 ; |
29 const TInt KGlxLargeImageMaximumZoomRatio = 100 ; |
32 const TInt KGlxSmallImageMaximumZoomRatio = 150 ; |
30 const TInt KGlxSmallImageMaximumZoomRatio = 150 ; |
33 |
31 |
34 const TInt KGlxMinPanFactor = 1 ; // The min multiple of pixles to pan |
32 const TInt KGlxMinPanFactor = 1 ; // The min multiple of pixles to pan |
35 const TInt KGlxPanInertiaFactor = 10 ; |
33 const TInt KGlxPanInertiaFactor = 10 ; |
36 const TInt KGlxPanFactorUpdateMultiple = 5 ; // The number of pan operations after which panning speed is increased by an order of magnitude |
34 const TInt KGlxPanFactorUpdateMultiple = 5 ; // The number of pan operations after which panning speed is increased by an order of magnitude |
37 const TInt KGlxMaxPanUpdateMultiple = 6 ; |
35 const TInt KGlxMaxPanUpdateMultiple = 6 ; |
38 const TInt KGlxOrigin = 0 ; |
36 const TInt KGlxOrigin = 0 ; |
39 |
37 |
40 const TInt KGlxMinRelativeZoomPercent = 70 ; |
38 const TInt KGlxMinRelativeZoomPercent = 85 ; |
41 const TInt KGlxMaxRelativeZoomPercent = 130 ; |
39 const TInt KGlxMaxRelativeZoomPercent = 115 ; |
42 |
40 |
43 const TInt KGlxZoomPanInc = 10 ; // Min number of pixels panned in one keypress. This value is incremented exponentially by multiples of iPanFactor |
41 const TInt KGlxZoomPanInc = 10 ; // Min number of pixels panned in one keypress. This value is incremented exponentially by multiples of iPanFactor |
44 |
42 |
45 // ============================ MEMBER FUNCTIONS =============================== |
43 // ============================ MEMBER FUNCTIONS =============================== |
46 |
44 |
47 void TGlxZoomAndPanMathsEngine::Initialize(TPoint& aCenter, |
45 void TGlxZoomAndPanMathsEngine::Initialize(TPoint& aCenter, |
48 TSize& aScreenSize, |
46 TSize& aScreenSize, |
49 TSize& aImageSize, |
47 TSize& aImageSize, |
50 TSize& /*aOriginalZoomedDimensions*/, |
48 TUint8 aInitialZoomRatio, |
51 TUint8 aInitialZoomRatio) |
49 TUint8 aMinZoomRatio) |
52 { |
50 { |
53 TRACER("void TGlxZoomAndPanMathsEngine::Initialize()"); |
51 TRACER("void TGlxZoomAndPanMathsEngine::Initialize()"); |
54 |
52 |
55 iCenter = aCenter; |
53 iCenter = aCenter; |
56 iScreenSize = aScreenSize; |
54 iScreenSize = aScreenSize; |
57 |
55 |
58 // This will only be set at initialization/constructiron. Never afterwards. |
56 // This will only be set at initialization/constructiron. Never afterwards. |
59 // [TODO] Is there a way to make this constant. |
57 // [TODO] Is there a way to make this constant. |
60 iActualImageSize = aImageSize; |
58 iActualImageSize = aImageSize; |
61 |
59 |
62 iMinZoomRatio = aInitialZoomRatio; |
60 iMinZoomRatio = aMinZoomRatio; |
63 iZoomRatio = aInitialZoomRatio; |
61 iZoomRatio = aInitialZoomRatio; |
64 iMaxZoomRatio = ((aInitialZoomRatio == KGlxLargeImageMaximumZoomRatio) ? |
62 iMaxZoomRatio = ((aInitialZoomRatio >= KGlxLargeImageMaximumZoomRatio) ? |
65 KGlxSmallImageMaximumZoomRatio:KGlxLargeImageMaximumZoomRatio); |
63 KGlxSmallImageMaximumZoomRatio:KGlxLargeImageMaximumZoomRatio); |
|
64 GLX_LOG_INFO1("TGlxZoomAndPanMathsEngine::Initialize: Minimum ZoomRatio = [%d] ", iMinZoomRatio ); |
|
65 GLX_LOG_INFO1("TGlxZoomAndPanMathsEngine::Initialize: Maximum ZoomRatio = [%d] ", iMaxZoomRatio ); |
66 |
66 |
67 iPanFactor = KGlxMinPanFactor; |
67 iPanFactor = KGlxMinPanFactor; |
68 |
68 |
69 iImageVirtualSize.iHeight = aImageSize.iHeight * aInitialZoomRatio /100; |
69 iImageVirtualSize.iHeight = aImageSize.iHeight * aInitialZoomRatio /100; |
70 iImageVirtualSize.iWidth = aImageSize.iWidth * aInitialZoomRatio /100; |
70 iImageVirtualSize.iWidth = aImageSize.iWidth * aInitialZoomRatio /100; |
72 iCenter.iX = iImageVirtualSize.iWidth/2 ; |
72 iCenter.iX = iImageVirtualSize.iWidth/2 ; |
73 iCenter.iY = iImageVirtualSize.iHeight/2; |
73 iCenter.iY = iImageVirtualSize.iHeight/2; |
74 |
74 |
75 iBorderWidth.iWidth = (iScreenSize.iWidth - iImageVirtualSize.iWidth )/2 ; |
75 iBorderWidth.iWidth = (iScreenSize.iWidth - iImageVirtualSize.iWidth )/2 ; |
76 iBorderWidth.iHeight = (iScreenSize.iHeight - iImageVirtualSize.iHeight)/2 ; |
76 iBorderWidth.iHeight = (iScreenSize.iHeight - iImageVirtualSize.iHeight)/2 ; |
|
77 |
|
78 GLX_LOG_INFO2("TGlxZoomAndPanMathsEngine::Initialize: Center at Initialization = [%f,%f] ", iCenter.iX, iCenter.iY ); |
77 |
79 |
78 } |
80 } |
79 |
81 |
80 TInt TGlxZoomAndPanMathsEngine::NewCenterCoordinate(TInt aCenter, |
82 TInt TGlxZoomAndPanMathsEngine::NewCenterCoordinate(TInt aCenter, |
81 TInt aOffset, |
83 TInt aOffset, |
122 TBool * aThresholdReached) |
124 TBool * aThresholdReached) |
123 { |
125 { |
124 TRACER("TGlxZoomAndPanMathsEngine::Pan"); |
126 TRACER("TGlxZoomAndPanMathsEngine::Pan"); |
125 |
127 |
126 GLX_LOG_INFO2("Pan: Center before PAN= [%d,%d] ", iCenter.iX, iCenter.iY ); |
128 GLX_LOG_INFO2("Pan: Center before PAN= [%d,%d] ", iCenter.iX, iCenter.iY ); |
127 GLX_LOG_INFO2("Pan: Pan Offset = [%d,%d] ", TInt(aOffset.iX), TInt(aOffset.iY)); |
129 GLX_LOG_INFO2("Pan: Pan Offset = [%d,%d] ", aOffset.iX, aOffset.iY); |
128 |
130 |
129 TPoint panOffset = aOffset; |
131 TPoint panOffset = aOffset; |
130 TUint16 halfScreenWidth = iScreenSize.iWidth>>1; |
132 TUint16 halfScreenWidth = iScreenSize.iWidth>>1; |
131 TUint16 halfScreenHeight = iScreenSize.iHeight>>1; |
133 TUint16 halfScreenHeight = iScreenSize.iHeight>>1; |
132 |
134 |