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 | |
parent | a83b3b5d45ba516883e80eefd7c5f6785b8a567c (diff) |
New iOS client code
does not work yet - needs fix by tor after refactoring of ios-bootstrap.h
Change-Id: I0728306beb734511bd3f16e2e4922fd726bb37da
-rw-r--r-- | include/touch/touch.h | 4 | ||||
-rw-r--r-- | sw/source/ui/uiview/viewport.cxx | 106 | ||||
-rw-r--r-- | vcl/ios/iosinst.cxx | 8 |
3 files changed, 33 insertions, 85 deletions
diff --git a/include/touch/touch.h b/include/touch/touch.h index 1f0d7efa40b0..1d93e6572325 100644 --- a/include/touch/touch.h +++ b/include/touch/touch.h @@ -58,9 +58,9 @@ void touch_lo_pan(int deltaX, int deltaY); void touch_lo_zoom(int x, int y, float scale); void touch_lo_keyboard_input(int c); -typedef enum { DOWN, MOVE, UP} LOMouseButtonState; +typedef enum { DOWN, MOVE, UP} MLOMouseButtonState; -void touch_lo_mouse_drag(int x, int y, LOMouseButtonState state); +void touch_lo_mouse_drag(int x, int y, MLOMouseButtonState state); #ifdef __cplusplus } 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; } diff --git a/vcl/ios/iosinst.cxx b/vcl/ios/iosinst.cxx index 7b4bcd2db879..353abe4662ef 100644 --- a/vcl/ios/iosinst.cxx +++ b/vcl/ios/iosinst.cxx @@ -155,7 +155,7 @@ public: sal_uLong nSalFrameStyle, SystemParentData *pSysParent ) : SvpSalFrame( pInstance, pParent, nSalFrameStyle, - true, basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA, + true, basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_BGRA, pSysParent ) { enableDamageTracker(); @@ -339,7 +339,7 @@ IMPL_LINK( IosSalInstance, RenderWindows, RenderWindowsArg*, arg ) it++ ) { IosSalFrame *pFrame = static_cast<IosSalFrame *>(*it); SalFrameGeometry aGeom = pFrame->GetGeometry(); - CGRect bbox = CGRectMake( aGeom.nX, aGeom.nY, aGeom.nWidth, aGeom.nHeight ); + CGRect bbox = CGRectMake( 0, 0, aGeom.nWidth, aGeom.nHeight ); if ( pFrame->IsVisible() && CGRectIntersectsRect( invalidRect, bbox ) ) { @@ -353,7 +353,7 @@ IMPL_LINK( IosSalInstance, RenderWindows, RenderWindowsArg*, arg ) CGImageCreate( aDevice->getSize().getX(), aDevice->getSize().getY(), 8, 32, aDevice->getScanlineStride(), CGColorSpaceCreateDeviceRGB(), - kCGImageAlphaNoneSkipLast, + kCGImageAlphaNoneSkipFirst | kCGBitmapByteOrder32Little, provider, NULL, false, @@ -428,7 +428,7 @@ void touch_lo_tap(int x, int y) } extern "C" -void touch_lo_mouse_drag(int x, int y, LOMouseButtonState state) +void touch_lo_mouse_drag(int x, int y, MLOMouseButtonState state) { SalFrame *pFocus = IosSalInstance::getInstance()->getFocusFrame(); |