35 const TInt KGlxPanInertiaFactor = 10 ; |
35 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 |
36 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 ; |
37 const TInt KGlxMaxPanUpdateMultiple = 6 ; |
38 const TInt KGlxOrigin = 0 ; |
38 const TInt KGlxOrigin = 0 ; |
39 |
39 |
40 const TInt KGlxMinRelativeZoomPercent = 85 ; |
40 const TInt KGlxMinRelativeZoomPercent = 70 ; |
41 const TInt KGlxMaxRelativeZoomPercent = 115 ; |
41 const TInt KGlxMaxRelativeZoomPercent = 130 ; |
42 |
42 |
43 const TInt KGlxZoomPanInc = 10 ; // Min number of pixels panned in one keypress. This value is incremented exponentially by multiples of iPanFactor |
43 const TInt KGlxZoomPanInc = 10 ; // Min number of pixels panned in one keypress. This value is incremented exponentially by multiples of iPanFactor |
44 |
44 |
45 // ============================ MEMBER FUNCTIONS =============================== |
45 // ============================ MEMBER FUNCTIONS =============================== |
46 |
46 |
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 = %x. ", newZoomRatio ); |
229 GLX_LOG_INFO1(" Zoom: newZoomRatio = %f. ", 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 |
256 { |
256 { |
257 iCenter.iY=(imageDimension.iHeight/2); |
257 iCenter.iY=(imageDimension.iHeight/2); |
258 } |
258 } |
259 else |
259 else |
260 { |
260 { |
261 TInt weightedBorderHeight = (iBorderWidth.iHeight*(100-((newZoomRatio-iMinZoomRatio)*100/(iMaxZoomRatio-iMinZoomRatio))))/100 ; |
|
262 // Is Center positioned such that the top end of the image is inside the |
261 // Is Center positioned such that the top end of the image is inside the |
263 // screen. |
262 // screen. |
264 if( iCenter.iY < (halfScreenHeight - weightedBorderHeight )) |
263 if( iCenter.iY < halfScreenHeight ) |
265 { |
264 { |
266 iCenter.iY = halfScreenHeight - weightedBorderHeight ; |
265 iCenter.iY = halfScreenHeight; |
267 } |
266 } |
268 // Is Center positioned such that the Bottom end of the image is inside the |
267 // Is Center positioned such that the Bottom end of the image is inside the |
269 // screen. |
268 // screen. |
270 else if((iCenter.iY + (halfScreenHeight - weightedBorderHeight ))> imageDimension.iHeight) |
269 else if((iCenter.iY + halfScreenHeight)> imageDimension.iHeight) |
271 { |
270 { |
272 // if so pan the image so that the edge of the image and screen coincide. |
271 // if so pan the image so that the edge of the image and screen coincide. |
273 iCenter.iY = imageDimension.iHeight - (halfScreenHeight - weightedBorderHeight) ; |
272 iCenter.iY = imageDimension.iHeight - halfScreenHeight ; |
274 } |
273 } |
275 } |
274 } |
276 |
275 |
277 //WIDTH Calculation |
276 //WIDTH Calculation |
278 if((imageDimension.iWidth < iScreenSize.iWidth - BORDER_WIDTH)) |
277 if(imageDimension.iWidth < iScreenSize.iWidth ) |
279 { |
278 { |
280 iCenter.iX=(imageDimension.iWidth/2); |
279 iCenter.iX=(imageDimension.iWidth/2); |
281 } |
280 } |
282 else |
281 else |
283 { |
282 { |
284 TInt weightedBorderWidth = (iBorderWidth.iWidth*(100-((newZoomRatio-iMinZoomRatio)*100/(iMaxZoomRatio-iMinZoomRatio))))/100 ; |
283 if( iCenter.iX < halfScreenWidth) |
285 if( iCenter.iX < (halfScreenWidth - weightedBorderWidth )) |
284 { |
286 { |
285 iCenter.iX = halfScreenWidth; |
287 iCenter.iX = (halfScreenWidth - weightedBorderWidth ); |
286 } |
288 } |
287 else if((iCenter.iX + halfScreenWidth)> imageDimension.iWidth) |
289 else if((iCenter.iX + (halfScreenWidth - weightedBorderWidth ))> imageDimension.iWidth) |
288 { |
290 { |
289 iCenter.iX = imageDimension.iWidth - halfScreenWidth; |
291 iCenter.iX = imageDimension.iWidth - (halfScreenWidth - weightedBorderWidth ) ; |
|
292 } |
290 } |
293 } |
291 } |
294 //Update the TopLeft corner and then re align to the center in the below code |
292 //Update the TopLeft corner and then re align to the center in the below code |
295 viewPortTopLeft.iY = iCenter.iY - halfScreenHeight ; |
293 viewPortTopLeft.iY = iCenter.iY - halfScreenHeight ; |
296 viewPortTopLeft.iX = iCenter.iX - halfScreenWidth ; |
294 viewPortTopLeft.iX = iCenter.iX - halfScreenWidth ; |
329 iCenter.iY = imageDimension.iHeight - halfScreenHeight; |
327 iCenter.iY = imageDimension.iHeight - halfScreenHeight; |
330 } |
328 } |
331 // New DIM is less than Old one. and all above conditions fail. |
329 // New DIM is less than Old one. and all above conditions fail. |
332 // This means that new DIM is smaller than VP DIM. So keep center 'centered'. |
330 // This means that new DIM is smaller than VP DIM. So keep center 'centered'. |
333 // DIM = dimension |
331 // DIM = dimension |
334 else if(iImageVirtualSize.iHeight > imageDimension.iHeight) |
332 else if(iCenter.iY < halfScreenHeight) |
335 { |
333 { |
336 //This is executed in the Zoom Out Case,In ZoomIn Case the Image is widened. |
334 iCenter.iY=halfScreenHeight; |
337 iCenter.iY=(imageDimension.iHeight/2); |
|
338 } |
335 } |
339 } |
336 } |
340 |
337 |
341 if((imageDimension.iWidth <= iScreenSize.iWidth) || |
338 if((imageDimension.iWidth <= iScreenSize.iWidth) || |
342 ( (imageDimension.iWidth > iScreenSize.iWidth) && (iCenter.iX == |
339 ( (imageDimension.iWidth > iScreenSize.iWidth) && (iCenter.iX == |
354 if( (iCenter.iX + halfScreenWidth) > imageDimension.iWidth ) |
351 if( (iCenter.iX + halfScreenWidth) > imageDimension.iWidth ) |
355 { |
352 { |
356 //Stick the Image to right side and then re-posistion the center |
353 //Stick the Image to right side and then re-posistion the center |
357 iCenter.iX = imageDimension.iWidth - halfScreenWidth ; |
354 iCenter.iX = imageDimension.iWidth - halfScreenWidth ; |
358 } |
355 } |
359 else if(iImageVirtualSize.iWidth >imageDimension.iWidth ) |
356 else if(iCenter.iX < halfScreenWidth) |
360 { |
357 { |
361 //The Image is panned and while zooming out ,the center has to be possistioned to center of the screen. |
358 //The Image is panned and while zooming out ,the center has to be possistioned to center of the screen. |
362 iCenter.iX =(imageDimension.iWidth/2); |
359 iCenter.iX = halfScreenWidth; |
363 } |
360 } |
364 } |
361 } |
365 viewPortTopLeft.iX = iCenter.iX - halfScreenWidth; |
362 viewPortTopLeft.iX = iCenter.iX - halfScreenWidth; |
366 viewPortTopLeft.iY = iCenter.iY - halfScreenHeight; |
363 viewPortTopLeft.iY = iCenter.iY - halfScreenHeight; |
367 iImageVirtualSize = imageDimension; |
364 iImageVirtualSize = imageDimension; |
415 TInt aRelativeZoomFactor, |
412 TInt aRelativeZoomFactor, |
416 TZoomMode aZoomMode, |
413 TZoomMode aZoomMode, |
417 TBool *aThresholdReached) |
414 TBool *aThresholdReached) |
418 { |
415 { |
419 TRACER("TGlxZoomAndPanMathsEngine::NewZoomRatio "); |
416 TRACER("TGlxZoomAndPanMathsEngine::NewZoomRatio "); |
420 GLX_LOG_INFO1("NewZoomRatio: Old Zoom Ratio = %x . ",iZoomRatio ); |
417 GLX_LOG_INFO1("NewZoomRatio: Old Zoom Ratio = %f . ",iZoomRatio ); |
421 GLX_LOG_INFO1("NewZoomRatio: Expected Zoom Ratio = %d . ",aExpectedZoomRatio ); |
418 GLX_LOG_INFO1("NewZoomRatio: Expected Zoom Ratio = %d . ",aExpectedZoomRatio ); |
422 GLX_LOG_INFO1("NewZoomRatio: Relative Zoom Factor = %d . ",aRelativeZoomFactor ); |
419 GLX_LOG_INFO1("NewZoomRatio: Relative Zoom Factor = %d . ",aRelativeZoomFactor ); |
423 |
420 |
424 // We ignore zoommode and aRelativeZoomFactor if we have a aExpectedZoomRatio. |
421 // We ignore zoommode and aRelativeZoomFactor if we have a aExpectedZoomRatio. |
425 // We ignore zoommode if we have a aRelativeZoomFactor. |
422 // We ignore zoommode if we have a aRelativeZoomFactor. |
428 iZoomRatio = aExpectedZoomRatio ; |
425 iZoomRatio = aExpectedZoomRatio ; |
429 } |
426 } |
430 else if (aRelativeZoomFactor > 0) |
427 else if (aRelativeZoomFactor > 0) |
431 { |
428 { |
432 //Pruning extreme values. Not allowing more than 15% change in zoom ratio. |
429 //Pruning extreme values. Not allowing more than 15% change in zoom ratio. |
433 TInt normalizedRelativeZoomFactor = aRelativeZoomFactor ; |
430 TReal normalizedRelativeZoomFactor = aRelativeZoomFactor ; |
434 if (normalizedRelativeZoomFactor < KGlxMinRelativeZoomPercent) |
431 if (normalizedRelativeZoomFactor < KGlxMinRelativeZoomPercent) |
435 { |
432 { |
436 normalizedRelativeZoomFactor = KGlxMinRelativeZoomPercent; |
433 normalizedRelativeZoomFactor = KGlxMinRelativeZoomPercent; |
437 } |
434 } |
438 else if (normalizedRelativeZoomFactor > KGlxMaxRelativeZoomPercent) |
435 else if (normalizedRelativeZoomFactor > KGlxMaxRelativeZoomPercent) |
439 { |
436 { |
440 normalizedRelativeZoomFactor = KGlxMaxRelativeZoomPercent; |
437 normalizedRelativeZoomFactor = KGlxMaxRelativeZoomPercent; |
441 } |
438 } |
442 iZoomRatio = (iZoomRatio * normalizedRelativeZoomFactor)/100 ; |
439 iZoomRatio = (iZoomRatio * ((normalizedRelativeZoomFactor - 100.0F)*0.75F + 100.0F))/100.0F ; |
|
440 GLX_LOG_INFO1("NewZoomRatio: New Zoom Ratio = %f . ",iZoomRatio ); |
443 } |
441 } |
444 else |
442 else |
445 { |
443 { |
446 if(EZoomIn == aZoomMode) |
444 if(EZoomIn == aZoomMode) |
447 { |
445 { |
466 else if( iZoomRatio <= iMinZoomRatio ) |
464 else if( iZoomRatio <= iMinZoomRatio ) |
467 { |
465 { |
468 iZoomRatio = iMinZoomRatio; |
466 iZoomRatio = iMinZoomRatio; |
469 if (NULL != aThresholdReached) |
467 if (NULL != aThresholdReached) |
470 { |
468 { |
471 GLX_LOG_INFO1("NewZoomRatio: Min Threshold Reached iInitialZoomRatio = %d .", iMinZoomRatio ); |
469 GLX_LOG_INFO1("NewZoomRatio: Min Threshold Reached iMinZoomRatio = %d .", iMinZoomRatio ); |
472 *aThresholdReached = ETrue; |
470 *aThresholdReached = ETrue; |
473 } |
471 } |
474 } |
472 } |
475 |
473 |
476 GLX_LOG_INFO1("NewZoomRatio: New Zoom Ratio = %x. ",iZoomRatio ); |
474 GLX_LOG_INFO1("NewZoomRatio: New Zoom Ratio = %f. ",iZoomRatio ); |
477 return iZoomRatio; |
475 return iZoomRatio; |
478 } |
476 } |
479 |
477 |
480 |
478 |
481 //------------------------------------------------------------------------------------- |
479 //------------------------------------------------------------------------------------- |