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 /include | |
parent | 6b6088fa9cfe6f81107e4aed80f18dfdf3f664f0 (diff) |
ready for integration with CATiledLayer
Change-Id: I50f519a37036ed3d17f73c80b33f4a9c4c19cb52
Diffstat (limited to 'include')
-rw-r--r-- | include/touch/touch.h | 74 |
1 files changed, 65 insertions, 9 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) |