diff options
author | ptyl@cloudon.com <ptyl@cloudon.com> | 2013-10-15 20:21:17 +0200 |
---|---|---|
committer | Tor Lillqvist <tml@collabora.com> | 2013-10-15 22:38:04 +0300 |
commit | 79d83741eb0d60d741415de8b8f01b3ef8510ae2 (patch) | |
tree | 3f220783cc0b4a54cbdcda738b7ca3ac14114b36 /sw | |
parent | a83b3b5d45ba516883e80eefd7c5f6785b8a567c (diff) |
New iOS client code
does not work yet - needs fix by tor after refactoring of ios-bootstrap.h
Change-Id: I0728306beb734511bd3f16e2e4922fd726bb37da
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/ui/uiview/viewport.cxx | 106 |
1 files changed, 27 insertions, 79 deletions
diff --git a/sw/source/ui/uiview/viewport.cxx b/sw/source/ui/uiview/viewport.cxx index 9a0125eece9a..a5fb8de8f962 100644 --- a/sw/source/ui/uiview/viewport.cxx +++ b/sw/source/ui/uiview/viewport.cxx @@ -1262,95 +1262,43 @@ sal_Bool SwView::HandleWheelCommands( const CommandEvent& rCEvt ) } else if( COMMAND_WHEEL_ZOOM_SCALE == pWData->GetMode() ) { - // COMMAND_WHEEL_ZOOM_SCALE is de facto used only for Android and iOS, I think - // mobile touch zoom (pinch) section - // last location in pixels is defaulted to an illegal location - // (coordinates are always positive) - static Point lastLocationInPixels(0,0); - static const double NEW_ZOOM_START= -6666.66; - static double initialZoom = NEW_ZOOM_START; - static int rememberedZoom = 0; - - // the target should remain the same in logic, regardless of eventual zoom - const Point & targetInLogic = GetEditWin().PixelToLogic(rCEvt.GetMousePosPixel()); - double scale = double(pWData->GetDelta()) / double(MOBILE_ZOOM_SCALE_MULTIPLIER); - - if( scale==0 ) - { - // scale 0, means end of gesture, and zoom resets - rememberedZoom=0; - } - else - { - int preZoomByVCL = m_pWrtShell->GetViewOptions()->GetZoom(); - bool isFirst = rememberedZoom != preZoomByVCL; - - if( isFirst ) - { - // If this is the start of a new zoom action, we take the value from VCL. - // Otherwise, we remeber the zoom from the previous action. - // This way we can be more accurate than VCL - initialZoom =(double) preZoomByVCL; - } + // remember the center location to reach in logic - // each zooming event is scaling the initial zoom - int zoomTarget = int(initialZoom * scale); + Size winSize = GetViewFrame()->GetWindow().GetOutputSizePixel(); + Point centerInPixels(winSize.getWidth() / 2, winSize.getHeight() / 2); + const Point & preZoomTargetCenterInLogic = GetEditWin().PixelToLogic(centerInPixels); - // thresholding the zoom - zoomTarget = std::max( MOBILE_MAX_ZOOM_OUT, std::min( MOBILE_MAX_ZOOM_IN, zoomTarget ) ); - long deltaX = 0, deltaY = 0; + double scale = double(pWData->GetDelta()) / double(MOBILE_ZOOM_SCALE_MULTIPLIER); - // no point zooming if the target zoom is the same as the current zoom - if( zoomTarget != preZoomByVCL ) - { + int preZoomByVCL = m_pWrtShell->GetViewOptions()->GetZoom(); - SetZoom( SVX_ZOOM_PERCENT, zoomTarget ); + // each zooming event is scaling the initial zoom + int zoomTarget = int(preZoomByVCL * scale); - // getting the VCL post zoom - rememberedZoom = m_pWrtShell->GetViewOptions()->GetZoom(); - } - else - { - rememberedZoom = preZoomByVCL; - } + // thresholding the zoom + zoomTarget = std::max( MOBILE_MAX_ZOOM_OUT, std::min( MOBILE_MAX_ZOOM_IN, zoomTarget ) ); - // if there was no zoom - if( rememberedZoom == preZoomByVCL ) - { - if( !isFirst ) - { - // If this is not the first location of the zoom, there is a valid last location. - // Therefore, scroll the center of the gesture. - // Explanation: without a zoom transpiring, the view will not change. - // Therefore, we do a simple scrolll from screen center to screen center - deltaX = rCEvt.GetMousePosPixel().X() - lastLocationInPixels.X(); - deltaY = rCEvt.GetMousePosPixel().Y() - lastLocationInPixels.Y(); - } - } - else - { - // Otherwise, there was a zoom. - // Keep the on screen center of the pinch in the same on screen location - const Point & postZoomTargetInPixels = GetEditWin().LogicToPixel(targetInLogic); - - deltaX = rCEvt.GetMousePosPixel().X() - postZoomTargetInPixels.X(); - deltaY = rCEvt.GetMousePosPixel().Y() - postZoomTargetInPixels.Y(); - } + // no point zooming if the target zoom is the same as the current zoom + if(zoomTarget!=preZoomByVCL) + { - if( (deltaX!=0) || (deltaY!=0) ) - { - // Scrolling the deltaX deltaY - Point deltaPoint( deltaX, deltaY ); - CommandWheelData cmd( 0, 0, 0, COMMAND_WHEEL_SCROLL, 0, 0, true); - CommandEvent event(deltaPoint , COMMAND_WHEEL, sal_True, &cmd ); + SetZoom( SVX_ZOOM_PERCENT, zoomTarget ); + } + // we move to the center, and add additional tilt from center + const Point & postZoomTargetCenterInPixels = GetEditWin().LogicToPixel(preZoomTargetCenterInLogic); + long deltaX = rCEvt.GetMousePosPixel().X() + centerInPixels.X() - postZoomTargetCenterInPixels.X(); + long deltaY = rCEvt.GetMousePosPixel().Y() + centerInPixels.Y() - postZoomTargetCenterInPixels.Y(); - m_pEditWin->HandleScrollCommand(event, m_pHScrollbar, m_pVScrollbar); - } + if((deltaX!=0) || (deltaY!=0)) + { - // store the last location - lastLocationInPixels = rCEvt.GetMousePosPixel(); - } + // scrolling the deltaX deltaY + Point deltaPoint( deltaX, deltaY ); + CommandWheelData cmd( 0, 0, 0, COMMAND_WHEEL_SCROLL, 0, 0, true); + CommandEvent event(deltaPoint , COMMAND_WHEEL, sal_True, &cmd ); + m_pEditWin->HandleScrollCommand(event, m_pHScrollbar, m_pVScrollbar); + } bOk = sal_True; } |