[Libreoffice-commits] core.git: include/touch sw/source vcl/ios

ptyl at cloudon.com ptyl at cloudon.com
Tue Oct 15 12:50:51 PDT 2013


 include/touch/touch.h            |    4 -
 sw/source/ui/uiview/viewport.cxx |  106 +++++++++------------------------------
 vcl/ios/iosinst.cxx              |    8 +-
 3 files changed, 33 insertions(+), 85 deletions(-)

New commits:
commit 79d83741eb0d60d741415de8b8f01b3ef8510ae2
Author: ptyl at cloudon.com <ptyl at cloudon.com>
Date:   Tue Oct 15 20:21:17 2013 +0200

    New iOS client code
    
    does not work yet - needs fix by tor after refactoring of ios-bootstrap.h
    
    Change-Id: I0728306beb734511bd3f16e2e4922fd726bb37da

diff --git a/include/touch/touch.h b/include/touch/touch.h
index 1f0d7ef..1d93e65 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 9a0125e..a5fb8de 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 7b4bcd2..353abe4 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();
 


More information about the Libreoffice-commits mailing list