diff options
author | Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com> | 2016-05-18 15:28:26 +0200 |
---|---|---|
committer | Jake Petroules <jake.petroules@qt.io> | 2016-06-14 17:22:55 +0000 |
commit | 197471beacf5589802cb91f1ceba59ed99cbb511 (patch) | |
tree | 7e0e3d8f6e436de99c5024de5566f42a2504e606 /src/plugins/platforms | |
parent | f862946c228f111e9572c6103faf526260fed04d (diff) |
darwin: Add Foundation conversion functions for QPoint/QPointF
The fromCGPoint function was left out for QPoint, as the foundation type is
using CGFloats internally. Clients should use an explicit QPointF::toPoint()
when potentially throwing away precision.
Change-Id: I12a37e8f81c86b7ada56066cc18ee29709cc21e3
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@theqtcompany.com>
Reviewed-by: Jake Petroules <jake.petroules@qt.io>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/ios/qiosglobal.h | 3 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosglobal.mm | 10 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiostextinputoverlay.mm | 14 | ||||
-rw-r--r-- | src/plugins/platforms/ios/quiview.mm | 2 |
4 files changed, 8 insertions, 21 deletions
diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h index ad78bd2e50..50bedd7b28 100644 --- a/src/plugins/platforms/ios/qiosglobal.h +++ b/src/plugins/platforms/ios/qiosglobal.h @@ -61,9 +61,6 @@ class QPlatformScreen; bool isQtApplication(); -CGPoint toCGPoint(const QPointF &point); -QPointF fromCGPoint(const CGPoint &point); - #ifndef Q_OS_TVOS Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation); UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation); diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm index 11bfb41e27..7ca3c66971 100644 --- a/src/plugins/platforms/ios/qiosglobal.mm +++ b/src/plugins/platforms/ios/qiosglobal.mm @@ -58,16 +58,6 @@ bool isQtApplication() return isQt; } -CGPoint toCGPoint(const QPointF &point) -{ - return CGPointMake(point.x(), point.y()); -} - -QPointF fromCGPoint(const CGPoint &point) -{ - return QPointF(point.x, point.y); -} - #ifndef Q_OS_TVOS Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation) { diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm index 94d82c3eb9..ff260d02dc 100644 --- a/src/plugins/platforms/ios/qiostextinputoverlay.mm +++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm @@ -496,12 +496,12 @@ static void executeBlockWithoutAnimation(Block block) QGuiApplication::styleHints()->setCursorFlashTime(0); if (!_loupeLayer) [self createLoupe]; - [self updateFocalPoint:fromCGPoint(_lastTouchPoint)]; + [self updateFocalPoint:QPointF::fromCGPoint(_lastTouchPoint)]; _loupeLayer.visible = YES; break; case UIGestureRecognizerStateChanged: // Tell the sub class to move the loupe to the correct position - [self updateFocalPoint:fromCGPoint(_lastTouchPoint)]; + [self updateFocalPoint:QPointF::fromCGPoint(_lastTouchPoint)]; break; case UIGestureRecognizerStateEnded: // Restore cursor blinking, and hide the loupe @@ -526,12 +526,12 @@ static void executeBlockWithoutAnimation(Block block) - (QPointF)focalPoint { - return fromCGPoint([_loupeLayer.targetView convertPoint:_loupeLayer.focalPoint toView:_focusView]); + return QPointF::fromCGPoint([_loupeLayer.targetView convertPoint:_loupeLayer.focalPoint toView:_focusView]); } - (void)setFocalPoint:(QPointF)point { - _loupeLayer.focalPoint = [_loupeLayer.targetView convertPoint:toCGPoint(point) fromView:_focusView]; + _loupeLayer.focalPoint = [_loupeLayer.targetView convertPoint:point.toCGPoint() fromView:_focusView]; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event @@ -548,7 +548,7 @@ static void executeBlockWithoutAnimation(Block block) // If the touch point is accepted by the sub class (e.g touch on cursor), we start a // press'n'hold timer that eventually will move the state to UIGestureRecognizerStateBegan. - if ([self acceptTouchesBegan:fromCGPoint(_firstTouchPoint)]) + if ([self acceptTouchesBegan:QPointF::fromCGPoint(_firstTouchPoint)]) _triggerStateBeganTimer.start(); else self.state = UIGestureRecognizerStateFailed; @@ -934,7 +934,7 @@ static void executeBlockWithoutAnimation(Block block) } QRectF inputRect = QGuiApplication::inputMethod()->inputItemClipRectangle(); - QPointF touchPos = fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]); + QPointF touchPos = QPointF::fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]); if (!inputRect.contains(touchPos)) self.state = UIGestureRecognizerStateFailed; @@ -943,7 +943,7 @@ static void executeBlockWithoutAnimation(Block block) - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { - QPointF touchPos = fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]); + QPointF touchPos = QPointF::fromCGPoint([static_cast<UITouch *>([touches anyObject]) locationInView:_focusView]); const QTransform mapToLocal = QGuiApplication::inputMethod()->inputItemTransform().inverted(); int cursorPosOnRelease = QInputMethod::queryFocusObject(Qt::ImCursorPosition, touchPos * mapToLocal).toInt(); diff --git a/src/plugins/platforms/ios/quiview.mm b/src/plugins/platforms/ios/quiview.mm index 088d651e2e..bf929667a6 100644 --- a/src/plugins/platforms/ios/quiview.mm +++ b/src/plugins/platforms/ios/quiview.mm @@ -329,7 +329,7 @@ // as we already have the QWindow positioned at the right place, we can // just map from the local view position to global coordinates. // tvOS: all touches start at the center of the screen and move from there. - QPoint localViewPosition = fromCGPoint([uiTouch locationInView:self]).toPoint(); + QPoint localViewPosition = QPointF::fromCGPoint([uiTouch locationInView:self]).toPoint(); QPoint globalScreenPosition = m_qioswindow->mapToGlobal(localViewPosition); touchPoint.area = QRectF(globalScreenPosition, QSize(0, 0)); |