[Libreoffice-commits] core.git: Branch 'feature/tiledrendering' - include/touch ios/shared sw/source

Ptyl Dragon ptyl at cloudon.com
Wed Oct 30 18:58:07 CET 2013


 include/touch/touch.h                                           |   74 ++++++++--
 ios/shared/ios_sharedlo/objective_c/gestures/MLOGestureEngine.m |    4 
 sw/source/core/view/viewsh.cxx                                  |   26 ++-
 3 files changed, 90 insertions(+), 14 deletions(-)

New commits:
commit 19879fe620e72f45f8faffee8f8d1271d803aa6e
Author: Ptyl Dragon <ptyl at cloudon.com>
Date:   Wed Oct 30 19:42:09 2013 +0200

    ready for integration with CATiledLayer
    
    Change-Id: I50f519a37036ed3d17f73c80b33f4a9c4c19cb52

diff --git a/include/touch/touch.h b/include/touch/touch.h
index 6ba2fab..f0cdabe 100644
--- a/include/touch/touch.h
+++ b/include/touch/touch.h
@@ -69,19 +69,75 @@ typedef CGRect MLORect;
 typedef basegfx::B2IBox MLORect;
 #endif
 
-typedef long long MLOContentSizeDimension;
-struct MLOContentSize {
-    MLOContentSizeDimension width;
-    MLOContentSizeDimension height;
+// MLODip - Device Independent Pixels
+
+typedef long long MLOPixel;
+static const MLOPixel LO_TWIPS_TO_MLO_PIXEL_RATIO = 10L;
+struct MLOPixelSize {
+    MLOPixel width;
+    MLOPixel height;
+};
+typedef struct MLOPixelSize MLOPixelSize;
+struct MLOPixelPoint {
+    MLOPixel x;
+    MLOPixel y;
 };
-typedef struct MLOContentSize MLOContentSize;
+typedef struct MLOPixelPoint MLOPixelPoint;
+
+CG_INLINE CGFloat
+MLOPixelToCGFloat(MLOPixel mloPixel)
+{
+    return (CGFloat) (mloPixel / LO_TWIPS_TO_MLO_PIXEL_RATIO);
+}
+
+CG_INLINE MLOPixel
+CGFloatToMLOPixel(CGFloat cgFloat)
+{
+    return (MLOPixel) cgFloat * LO_TWIPS_TO_MLO_PIXEL_RATIO;
+}
+
+CG_INLINE MLOPixelSize
+MLOPixelSizeMake(MLOPixel width, MLOPixel height)
+{
+    MLOPixelSize size; size.width = width; size.height = height; return size;
+}
+
+CG_INLINE MLOPixelPoint
+MLOPixelPointMake(MLOPixel x, MLOPixel y)
+{
+    MLOPixelPoint point; point.x = x; point.y = y; return point;
+}
+
+CG_INLINE MLOPixelSize
+CGSizeToMLOPixelSize(CGSize cgSize)
+{
+    MLOPixelSize mloPixelSize;
+    mloPixelSize.width = MLOPixelToCGFloat(cgSize.width);
+    mloPixelSize.height = MLOPixelToCGFloat(cgSize.height);
+    return mloPixelSize;
+}
+
+CG_INLINE CGSize
+MLOPixelsToCGSize(MLOPixel width, MLOPixel height)
+{
+    CGFloat fWidth = CGFloatToMLOPixel(width);
+    CGFloat fHeight = CGFloatToMLOPixel(height);
+    return CGSizeMake(fWidth, fHeight);
+}
 
-CG_INLINE MLOContentSize
-MLOContentSizeMake(MLOContentSizeDimension width, MLOContentSizeDimension height)
+CG_INLINE CGSize
+MLOPixelSizeToCGSize(MLOPixelSize mloPixelSize)
 {
-    MLOContentSize size; size.width = width; size.height = height; return size;
+    return MLOPixelsToCGSize(mloPixelSize.width, mloPixelSize.height);
 }
 
+MLOPixelPoint CGPointToMLOPixelPoint(CGPoint cgPoint);
+
+CGPoint MLOPixelPointToCGPoint(MLOPixelPoint mloPixelPoint);
+
+
+// selection
+
 void touch_ui_selection_start(MLOSelectionKind kind,
                               const void *documentHandle,
                               MLORect *rectangles,
@@ -124,7 +180,7 @@ context, contextHeight, contextWidth specify where to draw.
 */
 void touch_lo_draw_tile(void *context, int contextWidth, int contextHeight, int tilePosX, int tilePosY, int tileWidth, int tileHeight);
 void touch_lo_copy_buffer(const void * source, size_t sourceWidth, size_t sourceHeight, size_t sourceBytesPerRow, void * target, size_t targetWidth, size_t targetHeight);
-MLOContentSize touch_lo_get_content_size();
+CGSize touch_lo_get_content_size();
 void touch_lo_mouse_drag(int x, int y, MLOMouseButtonState state);
 
 // Move the start of the selection to (x,y)
diff --git a/ios/shared/ios_sharedlo/objective_c/gestures/MLOGestureEngine.m b/ios/shared/ios_sharedlo/objective_c/gestures/MLOGestureEngine.m
index 3523dca..f2a6f8e 100644
--- a/ios/shared/ios_sharedlo/objective_c/gestures/MLOGestureEngine.m
+++ b/ios/shared/ios_sharedlo/objective_c/gestures/MLOGestureEngine.m
@@ -470,3 +470,7 @@ void touch_ui_selection_start(MLOSelectionKind kind,
               rectangles[i].origin.y);
     }
 }
+
+void touch_ui_selection_none(){
+    // STUB
+}
diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx
index 420715a..8606126 100644
--- a/sw/source/core/view/viewsh.cxx
+++ b/sw/source/core/view/viewsh.cxx
@@ -1818,7 +1818,7 @@ void touch_lo_draw_tile(void * context, int contextWidth, int contextHeight, int
     Application::ReleaseSolarMutex();
 }
 extern "C"
-MLOContentSize touch_lo_get_content_size()
+CGSize touch_lo_get_content_size()
 {
     SwWrtShell *pViewShell = GetActiveWrtShell();
     if (pViewShell)
@@ -1826,14 +1826,30 @@ MLOContentSize touch_lo_get_content_size()
         static const long WIDTH_ADDITION  = 6L * DOCUMENTBORDER;
         static const long HEIGHT_ADDITION = 2L * DOCUMENTBORDER;
         Size documentSize =pViewShell->GetView().GetDocSz();
-        return MLOContentSizeMake(documentSize.Width() + WIDTH_ADDITION,
+        return MLOPixelsToCGSize(documentSize.Width() + WIDTH_ADDITION,
                                   documentSize.Height() + HEIGHT_ADDITION);
     }
-    return MLOContentSizeMake(0,0);
+    return CGSizeMake(0,0);
+}
+
+extern "C"
+MLOPixelPoint CGPointToMLOPixelPoint(CGPoint cgPoint)
+{
+    CGSize contentSize = touch_lo_get_content_size();
+    MLOPixel x = CGFloatToMLOPixel(cgPoint.x - (contentSize.width/2.0f));
+    MLOPixel y = CGFloatToMLOPixel(cgPoint.y);
+    return MLOPixelPointMake(x,y);
 }
-#endif
 
-extern "C" void touch_ui_selection_none() {}
+extern "C"
+CGPoint MLOPixelPointToCGPoint(MLOPixelPoint mloPixelPoint)
+{
+    CGSize contentSize = touch_lo_get_content_size();
+    CGFloat x = MLOPixelToCGFloat(mloPixelPoint.x) + (contentSize.width/2.0f);
+    CGFloat y = MLOPixelToCGFloat(mloPixelPoint.y);
+    return CGPointMake(x,y);
+}
+#endif
 
 void ViewShell::SetBrowseBorder( const Size& rNew )
 {


More information about the Libreoffice-commits mailing list