79 // CGlxZoomPanEventHandler constructor |
79 // CGlxZoomPanEventHandler constructor |
80 //---------------------------------------------------------------------------------- |
80 //---------------------------------------------------------------------------------- |
81 // |
81 // |
82 CGlxZoomPanEventHandler::CGlxZoomPanEventHandler( |
82 CGlxZoomPanEventHandler::CGlxZoomPanEventHandler( |
83 MGlxZoomEventHandlers& aZoomEventHandler) : |
83 MGlxZoomEventHandlers& aZoomEventHandler) : |
84 iZoomEventHandler(aZoomEventHandler), iPrevPinchFactor( |
84 iZoomEventHandler(aZoomEventHandler), iPrevPinchPercentage( |
85 KGlxNeutralZoomFactor) |
85 KGlxNeutralZoomFactor) |
86 { |
86 { |
87 TRACER("CGlxZoomPanEventHandler::CGlxZoomPanEventHandler()"); |
87 TRACER("CGlxZoomPanEventHandler::CGlxZoomPanEventHandler()"); |
88 // No Implementation |
88 // No Implementation |
89 } |
89 } |
234 Zoom(targetZoomLevel, 0, EZoomIn, &iZoomFocus ); |
234 Zoom(targetZoomLevel, 0, EZoomIn, &iZoomFocus ); |
235 |
235 |
236 // The boundary conditions. |
236 // The boundary conditions. |
237 if (((targetZoomLevel >= iTargetAnimatedZoomRatio) |
237 if (((targetZoomLevel >= iTargetAnimatedZoomRatio) |
238 && (EAnimationModeZoomIn == iAnimatedZoomMode)) |
238 && (EAnimationModeZoomIn == iAnimatedZoomMode)) |
239 || ((targetZoomLevel <= iMinZoomRatio) && (EAnimationModeZoomOut |
239 || ((targetZoomLevel <= iMinZoomRatio) |
240 == iAnimatedZoomMode))) |
240 && (EAnimationModeZoomOut == iAnimatedZoomMode))) |
241 { |
241 { |
242 iIsZoomingInAnimatedState = EFalse; |
242 iIsZoomingInAnimatedState = EFalse; |
243 CancelAnimationTimer(); |
243 CancelAnimationTimer(); |
244 TSize screensize = iMathsEngine.ScreenSize(); |
244 TSize screensize = iMathsEngine.ScreenSize(); |
245 iZoomFocus = TPoint(screensize.iWidth>>1,screensize.iHeight>>1) ; |
245 iZoomFocus = TPoint(screensize.iWidth>>1,screensize.iHeight>>1) ; |
628 TRACER("CGlxZoomPanEventHandler::HandleGestureReleasedEvent(const GestureHelper::MGestureEvent& )"); |
628 TRACER("CGlxZoomPanEventHandler::HandleGestureReleasedEvent(const GestureHelper::MGestureEvent& )"); |
629 |
629 |
630 if ( (EGestureSwipeLeft == iPreviousGestureCode) |
630 if ( (EGestureSwipeLeft == iPreviousGestureCode) |
631 ||(EGestureSwipeRight == iPreviousGestureCode) |
631 ||(EGestureSwipeRight == iPreviousGestureCode) |
632 ||(EGestureSwipeUp == iPreviousGestureCode) |
632 ||(EGestureSwipeUp == iPreviousGestureCode) |
633 ||(EGestureSwipeDown == iPreviousGestureCode)) |
633 ||(EGestureSwipeDown == iPreviousGestureCode) |
634 { |
634 ) |
|
635 { |
|
636 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandleGestureReleased: Previous Gesture Code [%d]" , iPreviousGestureCode); |
635 SetupAnimatedPan(); |
637 SetupAnimatedPan(); |
636 } |
638 } |
637 } |
639 } |
638 |
640 |
639 void CGlxZoomPanEventHandler::SetupAnimatedPan() |
641 void CGlxZoomPanEventHandler::SetupAnimatedPan() |
710 { |
712 { |
711 return; |
713 return; |
712 } |
714 } |
713 |
715 |
714 TPoint pinchFocus = aEvent.PinchCentrePoint(); |
716 TPoint pinchFocus = aEvent.PinchCentrePoint(); |
715 // Wrong convention in variable nomenclature but better than |
717 // Wrong convention in variable nomenclature but better than |
716 // ratioInPercentOfChangeInPinchDistance which is incidentally correct |
718 // ratioInPercentOfChangeInPinchDistance which is incidentally correct |
717 TInt pinchPercentage = aEvent.PinchPercent(); |
719 TInt pinchPercentage = aEvent.PinchPercent(); |
718 |
720 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandlePinchEventL: Percentage [%d]" , pinchPercentage); |
719 if (( iPrevPinchFactor >= KGlxNeutralZoomFactor ) && |
721 GLX_LOG_INFO2("CGlxZoomPanEventHandler::HandlePinchEventL: Pinch Focus [%d, %d]" , pinchFocus.iX, pinchFocus.iY); |
|
722 |
|
723 if (( iPrevPinchPercentage >= KGlxNeutralZoomFactor ) && |
720 ( pinchPercentage < KGlxNeutralZoomFactor )) |
724 ( pinchPercentage < KGlxNeutralZoomFactor )) |
721 { |
725 { |
722 iPrevPinchFactor = pinchPercentage ; |
726 iPrevPinchPercentage = pinchPercentage ; |
|
727 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandlePinchEventL: Pinch Ignored. Previous pinch factor = %d", iPrevPinchPercentage ); |
723 //This will result in we ignoring this event |
728 //This will result in we ignoring this event |
724 pinchPercentage = KGlxNeutralZoomFactor; |
729 pinchPercentage = KGlxNeutralZoomFactor; |
725 } |
730 } |
726 else |
731 else |
727 { |
732 { |
728 iPrevPinchFactor = pinchPercentage ; |
733 iPrevPinchPercentage = pinchPercentage ; |
729 } |
734 } |
730 |
735 |
731 // pinchPercentage == 100 => No change in finger distance => No Zoom. |
736 // pinchPercentage == 100 => No change in finger distance => No Zoom. |
732 // A negative Pinch percentage signifies an error in calculations. |
737 // A negative Pinch percentage signifies an error in calculations. |
733 // So NOT handling these |
738 // So NOT handling these |
736 { |
741 { |
737 Zoom(0, pinchPercentage, EZoomIn, &pinchFocus); |
742 Zoom(0, pinchPercentage, EZoomIn, &pinchFocus); |
738 } |
743 } |
739 |
744 |
740 HideScreenFurniture(); |
745 HideScreenFurniture(); |
741 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandlePinchEventL: Percentage [%d]" , pinchPercentage); |
|
742 } |
746 } |
743 |
747 |
744 // ----------------------------------------------------------------------------- |
748 // ----------------------------------------------------------------------------- |
745 // HandleDoubleTap |
749 // HandleDoubleTap |
746 // ----------------------------------------------------------------------------- |
750 // ----------------------------------------------------------------------------- |
917 |
921 |
918 // ----------------------------------------------------------------------------- |
922 // ----------------------------------------------------------------------------- |
919 // ActivateZoom |
923 // ActivateZoom |
920 // ----------------------------------------------------------------------------- |
924 // ----------------------------------------------------------------------------- |
921 // |
925 // |
922 void CGlxZoomPanEventHandler::ActivateZoom(TInt aInitialZoomRatio, |
926 void CGlxZoomPanEventHandler::ActivateZoom( TInt aInitialZoomRatio, |
923 TSize aImageSize, |
927 TSize aImageSize, |
924 TZoomStartMode aStartMode, |
928 TZoomStartMode aStartMode, |
925 TInt aMinSliderRange, |
929 TInt aMinZoomRatio, |
926 TInt aMaxSliderRange, |
930 TInt aMaxZoomRatio, |
927 TSize& aOriginalDimensions, |
|
928 TPoint* aZoomFocus) |
931 TPoint* aZoomFocus) |
929 { |
932 { |
930 TRACER("CGlxZoomPanEventHandler::ActivateZoom"); |
933 TRACER("CGlxZoomPanEventHandler::ActivateZoom"); |
931 |
934 |
932 TPoint center(aImageSize.iWidth/2 ,aImageSize.iHeight/2 ); |
935 TPoint center(aImageSize.iWidth/2 ,aImageSize.iHeight/2 ); |
938 TInt(center.iX), |
941 TInt(center.iX), |
939 TInt(center.iY) |
942 TInt(center.iY) |
940 ); |
943 ); |
941 |
944 |
942 // Minimum and Maximum Zoom Ratio |
945 // Minimum and Maximum Zoom Ratio |
943 iMinZoomRatio = iZoomRatio = aMinSliderRange; |
946 iZoomRatio = aInitialZoomRatio; |
944 iMaxZoomRatio = aMaxSliderRange ; |
947 iMinZoomRatio = aMinZoomRatio ; |
945 |
948 iMaxZoomRatio = aMaxZoomRatio ; |
946 iInitialZoomRatio = aInitialZoomRatio; |
949 |
947 |
|
948 iMathsEngine.Initialize(center, |
950 iMathsEngine.Initialize(center, |
949 screenSize, |
951 screenSize, |
950 imageSize, |
952 imageSize, |
951 aOriginalDimensions, |
953 iZoomRatio, |
952 iZoomRatio |
954 aMinZoomRatio |
953 ); |
955 ); |
954 |
956 |
955 //initially show the slider,so set the state to slider visible |
957 //initially show the slider,so set the state to slider visible |
956 TPoint viewPortTopLeft(0,0); |
958 TPoint viewPortTopLeft(0,0); |
957 TSize viewPortDimension(0,0); |
959 TSize viewPortDimension(0,0); |
982 } |
984 } |
983 } |
985 } |
984 break; |
986 break; |
985 case EZoomStartPinch: |
987 case EZoomStartPinch: |
986 { |
988 { |
987 iZoomRatio = iMathsEngine.Zoom(EZoomIn, aMinSliderRange, |
989 iZoomRatio = iMathsEngine.Zoom(EZoomIn, aMinZoomRatio, |
988 viewPortTopLeft, viewPortDimension); |
990 viewPortTopLeft, viewPortDimension); |
989 |
991 |
990 iZoomEventHandler.HandleViewPortParametersChanged(viewPortTopLeft , 0, |
992 iZoomEventHandler.HandleViewPortParametersChanged(viewPortTopLeft , 0, |
991 &viewPortDimension, iZoomRatio); |
993 &viewPortDimension, iZoomRatio); |
992 iZoomEventHandler.HandleShowUi(EFalse); |
994 iZoomEventHandler.HandleShowUi(EFalse); |
1044 { |
1046 { |
1045 case ETypePrimaryValueChange: |
1047 case ETypePrimaryValueChange: |
1046 { |
1048 { |
1047 GLX_LOG_INFO("CGlxZoomPanEventHandler::HandleEvent:ETypePrimaryValueChange"); |
1049 GLX_LOG_INFO("CGlxZoomPanEventHandler::HandleEvent:ETypePrimaryValueChange"); |
1048 |
1050 |
|
1051 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandleEvent:ETypePrimaryValueChange, iMinZoomRatio = [%d]", iMinZoomRatio); |
|
1052 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandleEvent:ETypePrimaryValueChange, iMaxZoomRatio = [%d]", iMaxZoomRatio); |
|
1053 |
1049 MulSliderPos* dataPtr = (MulSliderPos*)(aEvent.CustomEventData()); |
1054 MulSliderPos* dataPtr = (MulSliderPos*)(aEvent.CustomEventData()); |
1050 TInt currentSliderValue = dataPtr->mCurrentValue; |
1055 TInt currentSliderValue = dataPtr->mCurrentValue; |
|
1056 GLX_LOG_INFO1("CGlxZoomPanEventHandler::HandleEvent:ETypePrimaryValueChange, currentSliderValue = [%d]", currentSliderValue ); |
1051 |
1057 |
1052 // Is current value within acceptable range? |
1058 // Is current value within acceptable range? |
1053 // If yes, then zoom in or zoom out as needed. |
1059 // If yes, then zoom in or zoom out as needed. |
1054 if ( currentSliderValue > iMinZoomRatio |
1060 if ( currentSliderValue > iMinZoomRatio |
1055 && currentSliderValue <= iMaxZoomRatio ) |
1061 && currentSliderValue <= iMaxZoomRatio ) |
1129 // |
1135 // |
1130 void CGlxZoomPanEventHandler::ZoomToMinimumL() |
1136 void CGlxZoomPanEventHandler::ZoomToMinimumL() |
1131 { |
1137 { |
1132 TRACER("CGlxZoomPanEventHandler::ZoomToMinimumL( )"); |
1138 TRACER("CGlxZoomPanEventHandler::ZoomToMinimumL( )"); |
1133 |
1139 |
1134 Zoom(iInitialZoomRatio, 0, EZoomOut); |
1140 Zoom(iMinZoomRatio, 0, EZoomOut); |
1135 CallZoomOutL(); |
1141 CallZoomOutL(); |
1136 } |
1142 } |
1137 |
1143 |
1138 |
1144 |
1139 // ----------------------------------------------------------------------------- |
1145 // ----------------------------------------------------------------------------- |