diff options
author | Ptyl Dragon <ptyl@cloudon.com> | 2013-10-31 15:20:13 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2013-11-15 16:51:58 +0100 |
commit | 2a7ccf0c0a89438891bbe067e1772d5c093868b6 (patch) | |
tree | b803a897e61634d2f743f8964b97e199fa909e6d | |
parent | 50db10cac34203040abf7d04eae2f9f8dc0d3ed7 (diff) |
added units MLODpxes and MLORips
Change-Id: Ica09fbd0f6a822f464df302dba4cf40d1d089697
-rw-r--r-- | include/touch/touch.h | 98 | ||||
-rw-r--r-- | ios/shared/ios_sharedlo/objective_c/view_controllers/testing_tiles/MLOTestingTile.m | 8 | ||||
-rw-r--r-- | sw/source/core/view/viewsh.cxx | 46 |
3 files changed, 90 insertions, 62 deletions
diff --git a/include/touch/touch.h b/include/touch/touch.h index 3f5beb0c138d..594f9629b371 100644 --- a/include/touch/touch.h +++ b/include/touch/touch.h @@ -92,69 +92,89 @@ typedef basegfx::B2IBox MLORect; // 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 long long MLORip; +typedef CGFloat MLODpx; +typedef CGPoint MLODpxPoint; +typedef CGSize MLODpxSize; + +CG_INLINE MLODpxPoint +MLODpxPointByDpxes(MLODpx x, MLODpx y) +{ + return CGPointMake(x, y); +} + +CG_INLINE MLODpxSize +MLODpxSizeByDpxes(MLODpx width, MLODpx height) +{ + return CGSizeMake(width, height); +} + +static const MLORip LO_TWIPS_TO_MLO_RIP_RATIO = 10L; + +struct MLORipSize +{ + MLORip width; + MLORip height; }; -typedef struct MLOPixelSize MLOPixelSize; -struct MLOPixelPoint { - MLOPixel x; - MLOPixel y; +typedef struct MLORipSize MLORipSize; + +struct MLORipPoint +{ + MLORip x; + MLORip y; }; -typedef struct MLOPixelPoint MLOPixelPoint; +typedef struct MLORipPoint MLORipPoint; -CG_INLINE CGFloat -MLOPixelToCGFloat(MLOPixel mloPixel) +CG_INLINE MLODpx +MLODpxByRip(MLORip rip) { - return (CGFloat) (mloPixel / LO_TWIPS_TO_MLO_PIXEL_RATIO); + return (MLODpx) (rip / LO_TWIPS_TO_MLO_RIP_RATIO); } -CG_INLINE MLOPixel -CGFloatToMLOPixel(CGFloat cgFloat) +CG_INLINE MLORip +MLORipByDpx(MLODpx dpx) { - return (MLOPixel) cgFloat * LO_TWIPS_TO_MLO_PIXEL_RATIO; + return (MLORip) (dpx * LO_TWIPS_TO_MLO_RIP_RATIO); } -CG_INLINE MLOPixelSize -MLOPixelSizeMake(MLOPixel width, MLOPixel height) +CG_INLINE MLORipSize +MLORipSizeByRips(MLORip width, MLORip height) { - MLOPixelSize size; size.width = width; size.height = height; return size; + MLORipSize ripSize; ripSize.width = width; ripSize.height = height; return ripSize; } -CG_INLINE MLOPixelPoint -MLOPixelPointMake(MLOPixel x, MLOPixel y) +CG_INLINE MLORipPoint +MLORipPointByRips(MLORip x, MLORip y) { - MLOPixelPoint point; point.x = x; point.y = y; return point; + MLORipPoint point; point.x = x; point.y = y; return point; } -CG_INLINE MLOPixelSize -CGSizeToMLOPixelSize(CGSize cgSize) +CG_INLINE MLORipSize +MLORipSizeByDpxSize(MLODpxSize dpxSize) { - MLOPixelSize mloPixelSize; - mloPixelSize.width = MLOPixelToCGFloat(cgSize.width); - mloPixelSize.height = MLOPixelToCGFloat(cgSize.height); - return mloPixelSize; + MLORipSize ripSize; + ripSize.width = MLORipByDpx(dpxSize.width); + ripSize.height = MLORipByDpx(dpxSize.height); + return ripSize; } -CG_INLINE CGSize -MLOPixelsToCGSize(MLOPixel width, MLOPixel height) +CG_INLINE MLODpxSize +MLODpxSizeByRips(MLORip width, MLORip height) { - CGFloat fWidth = MLOPixelToCGFloat(width); - CGFloat fHeight = MLOPixelToCGFloat(height); + CGFloat fWidth = MLODpxByRip(width); + CGFloat fHeight = MLODpxByRip(height); return CGSizeMake(fWidth, fHeight); } -CG_INLINE CGSize -MLOPixelSizeToCGSize(MLOPixelSize mloPixelSize) +CG_INLINE MLODpxSize +MLODpxSizeByRipSize(MLORipSize ripSize) { - return MLOPixelsToCGSize(mloPixelSize.width, mloPixelSize.height); + return MLODpxSizeByRips(ripSize.width, ripSize.height); } -MLOPixelPoint CGPointToMLOPixelPoint(CGPoint cgPoint); +MLORipPoint MLORipPointByDpxPoint(MLODpxPoint mloDpxPoint); -CGPoint MLOPixelPointToCGPoint(MLOPixelPoint mloPixelPoint); +MLODpxPoint MLODpxPointByMLORipPoint(MLORipPoint mloRipPoint); // selection @@ -199,9 +219,9 @@ void touch_lo_keyboard_input(int c); tilePosX, tilePosY, tileWidth, tileHeight address the part of the document to be drawn. 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_draw_tile(void *context, int contextWidth, int contextHeight, MLODpxPoint tilePosition, MLODpxSize tileSize); 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); -CGSize touch_lo_get_content_size(); +MLODpxSize 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/view_controllers/testing_tiles/MLOTestingTile.m b/ios/shared/ios_sharedlo/objective_c/view_controllers/testing_tiles/MLOTestingTile.m index 14428ceba00b..f0661169e1cf 100644 --- a/ios/shared/ios_sharedlo/objective_c/view_controllers/testing_tiles/MLOTestingTile.m +++ b/ios/shared/ios_sharedlo/objective_c/view_controllers/testing_tiles/MLOTestingTile.m @@ -53,14 +53,12 @@ touch_lo_draw_tile(context, self.tester.params.contextWidth, self.tester.params.contextHeight, - self.tester.params.tilePosX, - self.tester.params.tilePosY, - self.tester.params.tileWidth, - self.tester.params.tileHeight); + MLODpxPointByDpxes(self.tester.params.tilePosX,self.tester.params.tilePosY), + MLODpxSizeByDpxes(self.tester.params.tileWidth,self.tester.params.tileHeight)); CGContextRestoreGState(context); - CGSize size = touch_lo_get_content_size(); + MLODpxSize size = touch_lo_get_content_size(); NSLog(@"touch_lo_get_content_size: width=%f, height=%f",size.width, size.height); } diff --git a/sw/source/core/view/viewsh.cxx b/sw/source/core/view/viewsh.cxx index 62cd9e8d928c..eda5be10fe0f 100644 --- a/sw/source/core/view/viewsh.cxx +++ b/sw/source/core/view/viewsh.cxx @@ -1771,8 +1771,18 @@ void SwViewShell::PaintTile(OutputDevice *pOut, const Rectangle &rRect) #if !HAVE_FEATURE_DESKTOP extern "C" -void touch_lo_draw_tile(void * context, int contextWidth, int contextHeight, int tilePosX, int tilePosY, int tileWidth, int tileHeight) -{ +void touch_lo_draw_tile(void *context, int contextWidth, int contextHeight, MLODpxPoint tileDpxPosition, MLODpxSize tileDpxSize) +{ + MLORipPoint tileRipPosition = MLORipPointByDpxPoint(tileDpxPosition); + MLORipSize rileRipSize = MLORipSizeByDpxSize(tileDpxSize); + MLORip tileRipPosX = tileRipPosition.x; + MLORip tileRipPosY = tileRipPosition.y; + MLORip tileRipWidth = rileRipSize.width; + MLORip tileRipHeight = rileRipSize.height; + int tilePosX = tileRipPosX; + int tilePosY = tileRipPosY; + int tileWidth = tileRipWidth; + int tileHeight = tileRipHeight; // Currently we expect that only one document is open, so we are using the // current shell. Should it turn out that we need to have more documents // open, we need to add a documentHandle that would hold the right @@ -1816,36 +1826,36 @@ void touch_lo_draw_tile(void * context, int contextWidth, int contextHeight, int Application::ReleaseSolarMutex(); } extern "C" -CGSize touch_lo_get_content_size() +MLODpxSize touch_lo_get_content_size() { SwWrtShell *pViewShell = GetActiveWrtShell(); if (pViewShell) { - static const long WIDTH_ADDITION = 6L * DOCUMENTBORDER; - static const long HEIGHT_ADDITION = 2L * DOCUMENTBORDER; + static const MLORip WIDTH_ADDITION = 6L * DOCUMENTBORDER; + static const MLORip HEIGHT_ADDITION = 2L * DOCUMENTBORDER; Size documentSize =pViewShell->GetView().GetDocSz(); - return MLOPixelsToCGSize(documentSize.Width() + WIDTH_ADDITION, - documentSize.Height() + HEIGHT_ADDITION); + return MLODpxSizeByRips(((MLORip)documentSize.Width()) + WIDTH_ADDITION, + ((MLORip)documentSize.Height()) + HEIGHT_ADDITION); } - return CGSizeMake(0,0); + return MLODpxSizeByDpxes(0,0); } extern "C" -MLOPixelPoint CGPointToMLOPixelPoint(CGPoint cgPoint) +MLORipPoint MLORipPointByDpxPoint(MLODpxPoint mloDpxPoint) { - 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); + MLODpxSize contentSize = touch_lo_get_content_size(); + MLORip x = MLORipByDpx(mloDpxPoint.x - (contentSize.width/2.0f)); + MLORip y = MLORipByDpx(mloDpxPoint.y); + return MLORipPointByRips(x,y); } extern "C" -CGPoint MLOPixelPointToCGPoint(MLOPixelPoint mloPixelPoint) +MLODpxPoint MLODpxPointByRipPoint(MLORipPoint mloRipPoint) { - 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); + MLODpxSize contentSize = touch_lo_get_content_size(); + MLODpx x = MLODpxByRip(mloRipPoint.x) + (contentSize.width/2.0f); + MLODpx y = MLODpxByRip(mloRipPoint.y); + return MLODpxPointByDpxes(x,y); } #endif |