diff options
author | Ptyl Dragon <ptyl@cloudon.com> | 2013-10-30 19:42:09 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2013-11-15 16:51:57 +0100 |
commit | 814ca0766e52d60d21abe76a4a24e9b46a721689 (patch) | |
tree | 1773fe998675f92e7d837b13b697422702828106 | |
parent | 6b6088fa9cfe6f81107e4aed80f18dfdf3f664f0 (diff) |
ready for integration with CATiledLayer
Change-Id: I50f519a37036ed3d17f73c80b33f4a9c4c19cb52
-rw-r--r-- | include/touch/touch.h | 74 | ||||
-rw-r--r-- | ios/shared/ios_sharedlo/objective_c/gestures/MLOGestureEngine.m | 2 | ||||
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 26 |
3 files changed, 87 insertions, 15 deletions
diff --git a/include/touch/touch.h b/include/touch/touch.h index 6fba7bd9b737..f9f6e2dc3548 100644 --- a/include/touch/touch.h +++ b/include/touch/touch.h @@ -90,19 +90,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, @@ -145,7 +201,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 53d3c74f7324..f2a6f8ec6814 100644 --- a/ios/shared/ios_sharedlo/objective_c/gestures/MLOGestureEngine.m +++ b/ios/shared/ios_sharedlo/objective_c/gestures/MLOGestureEngine.m @@ -473,4 +473,4 @@ void touch_ui_selection_start(MLOSelectionKind kind, void touch_ui_selection_none(){ // STUB -}
\ No newline at end of file +} diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 690105b12d2b..62cd9e8d928c 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1816,7 +1816,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) @@ -1824,14 +1824,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 SwViewShell::SetBrowseBorder( const Size& rNew ) { |