211 TPoint(iCenter).iY - halfScreenHeight) ; |
211 TPoint(iCenter).iY - halfScreenHeight) ; |
212 GLX_LOG_INFO2(" Zoom(): Center before Zoom= [%d,%d] ", iCenter.iX, iCenter.iY ); |
212 GLX_LOG_INFO2(" Zoom(): Center before Zoom= [%d,%d] ", iCenter.iX, iCenter.iY ); |
213 GLX_LOG_INFO2(" Zoom(): viewPortTopLeft Before Zoom = [%d,%d] ", TInt(viewPortTopLeft.iX), |
213 GLX_LOG_INFO2(" Zoom(): viewPortTopLeft Before Zoom = [%d,%d] ", TInt(viewPortTopLeft.iX), |
214 TInt(viewPortTopLeft.iY) ); |
214 TInt(viewPortTopLeft.iY) ); |
215 |
215 |
216 TInt oldZoomRatio = iZoomRatio ; |
216 TReal oldZoomRatio = iZoomRatio ; |
217 TInt newZoomRatio = NewZoomRatio(aExpectedZoomRatio, aRelativeZoomFactor, aZoomMode, aThresholdReached); |
217 TReal newZoomRatio = NewZoomRatio(aExpectedZoomRatio, aRelativeZoomFactor, aZoomMode, aThresholdReached); |
218 |
218 |
219 // we have an offcenter focus for our zoom in certain cases ( e.g pinch operation) or a double tap at an offcenter point. |
219 // we have an offcenter focus for our zoom in certain cases ( e.g pinch operation) or a double tap at an offcenter point. |
220 // In such a case the zoom happens around that point. So we need to translate (move) the |
220 // In such a case the zoom happens around that point. So we need to translate (move) the |
221 // center in such a way that the relative position of the zoom facus does not change. |
221 // center in such a way that the relative position of the zoom focus does not change. |
222 // centerTranslationfactor is the vector representation of that amount. |
222 // centerTranslationfactor is the vector representation of that amount. |
223 if (NULL != apZoomFocus) |
223 if ( (NULL != apZoomFocus) ) |
224 { |
224 { |
225 centerTranslationfactor.iX = (((apZoomFocus->iX - halfScreenWidth) * newZoomRatio)/oldZoomRatio) + (halfScreenWidth - apZoomFocus->iX); |
225 centerTranslationfactor.iX = (((apZoomFocus->iX - halfScreenWidth ) * newZoomRatio)/oldZoomRatio) + (halfScreenWidth - apZoomFocus->iX); |
226 centerTranslationfactor.iY = (((apZoomFocus->iY - halfScreenHeight) * newZoomRatio)/oldZoomRatio) + (halfScreenHeight - apZoomFocus->iY); |
226 centerTranslationfactor.iY = (((apZoomFocus->iY - halfScreenHeight ) * newZoomRatio)/oldZoomRatio) + (halfScreenHeight - apZoomFocus->iY); |
227 } |
227 } |
228 |
228 |
229 GLX_LOG_INFO1(" Zoom: newZoomRatio = %d. ", newZoomRatio ); |
229 GLX_LOG_INFO1(" Zoom: newZoomRatio = %x. ", newZoomRatio ); |
230 |
230 |
231 TSize imageDimension = TSize(iActualImageSize); |
231 TSize imageDimension = TSize(iActualImageSize); |
232 imageDimension.iWidth = (imageDimension.iWidth * newZoomRatio)/100; |
232 imageDimension.iWidth = (imageDimension.iWidth * newZoomRatio)/100; |
233 imageDimension.iHeight = (imageDimension.iHeight * newZoomRatio)/100; |
233 imageDimension.iHeight = (imageDimension.iHeight * newZoomRatio)/100; |
234 |
234 |
247 // [TODO] Suggest the use of overloaded operators so that points can be operated upon by vectors. |
247 // [TODO] Suggest the use of overloaded operators so that points can be operated upon by vectors. |
248 // specifically in this case to enable a point to be multiplied by a dimension resulting from the ratio of two dimension |
248 // specifically in this case to enable a point to be multiplied by a dimension resulting from the ratio of two dimension |
249 iCenter.iX = (iCenter.iX * imageDimension.iWidth )/iImageVirtualSize.iWidth ; |
249 iCenter.iX = (iCenter.iX * imageDimension.iWidth )/iImageVirtualSize.iWidth ; |
250 iCenter.iY = (iCenter.iY * imageDimension.iHeight)/iImageVirtualSize.iHeight ; |
250 iCenter.iY = (iCenter.iY * imageDimension.iHeight)/iImageVirtualSize.iHeight ; |
251 |
251 |
252 |
|
253 //HEIGHT Calculation |
252 //HEIGHT Calculation |
254 // TODO: Hive center corrections into an different function. |
253 // TODO: Hive center corrections into an different function. |
255 // If the image might have become smaller than the screen DUE to or AFTER the above calculations |
254 // If the image might have become smaller than the screen DUE to or AFTER the above calculations |
256 if((imageDimension.iHeight < iScreenSize.iHeight - BORDER_HEIGHT)) |
255 if((imageDimension.iHeight < iScreenSize.iHeight - BORDER_HEIGHT)) |
257 { |
256 { |
361 { |
360 { |
362 //The Image is panned and while zooming out ,the center has to be possistioned to center of the screen. |
361 //The Image is panned and while zooming out ,the center has to be possistioned to center of the screen. |
363 iCenter.iX =(imageDimension.iWidth/2); |
362 iCenter.iX =(imageDimension.iWidth/2); |
364 } |
363 } |
365 } |
364 } |
366 |
|
367 viewPortTopLeft.iX = iCenter.iX - halfScreenWidth; |
365 viewPortTopLeft.iX = iCenter.iX - halfScreenWidth; |
368 viewPortTopLeft.iY = iCenter.iY - halfScreenHeight; |
366 viewPortTopLeft.iY = iCenter.iY - halfScreenHeight; |
369 iImageVirtualSize = imageDimension; |
367 iImageVirtualSize = imageDimension; |
370 |
|
371 } |
368 } |
372 |
369 |
373 // if centerTranslationfactor exists that means we have an off center zoom, then |
370 // if centerTranslationfactor exists that means we have an off center zoom, then |
374 // pan that way to get the new center. |
371 // pan that way to get the new center. |
375 Pan(centerTranslationfactor, viewPortTopLeft, EGlxPanIncrementUniform) ; |
372 Pan(centerTranslationfactor, viewPortTopLeft, EGlxPanIncrementUniform) ; |
411 |
408 |
412 //------------------------------------------------------------------------------------- |
409 //------------------------------------------------------------------------------------- |
413 // NewZoomRatio: Calculates the Zoom Ratio |
410 // NewZoomRatio: Calculates the Zoom Ratio |
414 //------------------------------------------------------------------------------------- |
411 //------------------------------------------------------------------------------------- |
415 // |
412 // |
416 TInt TGlxZoomAndPanMathsEngine::NewZoomRatio( |
413 TReal TGlxZoomAndPanMathsEngine::NewZoomRatio( |
417 TInt aExpectedZoomRatio, |
414 TInt aExpectedZoomRatio, |
418 TInt aRelativeZoomFactor, |
415 TInt aRelativeZoomFactor, |
419 TZoomMode aZoomMode, |
416 TZoomMode aZoomMode, |
420 TBool *aThresholdReached) |
417 TBool *aThresholdReached) |
421 { |
418 { |
422 TRACER("TGlxZoomAndPanMathsEngine::NewZoomRatio "); |
419 TRACER("TGlxZoomAndPanMathsEngine::NewZoomRatio "); |
423 GLX_LOG_INFO1("NewZoomRatio: Old Zoom Ratio = %d . ",TInt(iZoomRatio) ); |
420 GLX_LOG_INFO1("NewZoomRatio: Old Zoom Ratio = %x . ",iZoomRatio ); |
424 GLX_LOG_INFO1("NewZoomRatio: Expected Zoom Ratio = %d . ",aExpectedZoomRatio ); |
421 GLX_LOG_INFO1("NewZoomRatio: Expected Zoom Ratio = %d . ",aExpectedZoomRatio ); |
425 GLX_LOG_INFO1("NewZoomRatio: Relative Zoom Factor = %d . ",aRelativeZoomFactor ); |
422 GLX_LOG_INFO1("NewZoomRatio: Relative Zoom Factor = %d . ",aRelativeZoomFactor ); |
426 |
423 |
427 // We ignore zoommode and aRelativeZoomFactor if we have a aExpectedZoomRatio. |
424 // We ignore zoommode and aRelativeZoomFactor if we have a aExpectedZoomRatio. |
428 // We ignore zoommode if we have a aRelativeZoomFactor. |
425 // We ignore zoommode if we have a aRelativeZoomFactor. |
475 GLX_LOG_INFO1("NewZoomRatio: Min Threshold Reached iInitialZoomRatio = %d .", iMinZoomRatio ); |
471 GLX_LOG_INFO1("NewZoomRatio: Min Threshold Reached iInitialZoomRatio = %d .", iMinZoomRatio ); |
476 *aThresholdReached = ETrue; |
472 *aThresholdReached = ETrue; |
477 } |
473 } |
478 } |
474 } |
479 |
475 |
480 GLX_LOG_INFO1("NewZoomRatio: New Zoom Ratio = %d. ",TInt(iZoomRatio) ); |
476 GLX_LOG_INFO1("NewZoomRatio: New Zoom Ratio = %x. ",iZoomRatio ); |
481 return iZoomRatio; |
477 return iZoomRatio; |
482 } |
478 } |
483 |
479 |
484 |
480 |
485 //------------------------------------------------------------------------------------- |
481 //------------------------------------------------------------------------------------- |