diff options
Diffstat (limited to 'src/plugins/platforms/ios/qiostextinputoverlay.mm')
-rw-r--r-- | src/plugins/platforms/ios/qiostextinputoverlay.mm | 85 |
1 files changed, 36 insertions, 49 deletions
diff --git a/src/plugins/platforms/ios/qiostextinputoverlay.mm b/src/plugins/platforms/ios/qiostextinputoverlay.mm index fe3c29d037..ff696f5b7f 100644 --- a/src/plugins/platforms/ios/qiostextinputoverlay.mm +++ b/src/plugins/platforms/ios/qiostextinputoverlay.mm @@ -96,7 +96,7 @@ static void executeBlockWithoutAnimation(Block block) @implementation QIOSEditMenu -- (id)init +- (instancetype)init { if (self = [super init]) { NSNotificationCenter *center = [NSNotificationCenter defaultCenter]; @@ -160,7 +160,13 @@ static void executeBlockWithoutAnimation(Block block) // ------------------------------------------------------------------------- -@interface QIOSLoupeLayer : CALayer { +@interface QIOSLoupeLayer : CALayer +@property (nonatomic, retain) UIView *targetView; +@property (nonatomic, assign) CGPoint focalPoint; +@property (nonatomic, assign) BOOL visible; +@end + +@implementation QIOSLoupeLayer { UIView *_snapshotView; BOOL _pendingSnapshotUpdate; UIView *_loupeImageView; @@ -168,14 +174,8 @@ static void executeBlockWithoutAnimation(Block block) CGFloat _loupeOffset; QTimer _updateTimer; } -@property (nonatomic, retain) UIView *targetView; -@property (nonatomic, assign) CGPoint focalPoint; -@property (nonatomic, assign) BOOL visible; -@end -@implementation QIOSLoupeLayer - -- (id)initWithSize:(CGSize)size cornerRadius:(CGFloat)cornerRadius bottomOffset:(CGFloat)bottomOffset +- (instancetype)initWithSize:(CGSize)size cornerRadius:(CGFloat)cornerRadius bottomOffset:(CGFloat)bottomOffset { if (self = [super init]) { _loupeOffset = bottomOffset + (size.height / 2); @@ -301,26 +301,22 @@ static void executeBlockWithoutAnimation(Block block) // ------------------------------------------------------------------------- -#if QT_IOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__IPHONE_10_0) -@interface QIOSHandleLayer : CALayer <CAAnimationDelegate> { -#else -@interface QIOSHandleLayer : CALayer { -#endif - CALayer *_handleCursorLayer; - CALayer *_handleKnobLayer; - Qt::Edge _selectionEdge; -} +@interface QIOSHandleLayer : CALayer <CAAnimationDelegate> @property (nonatomic, assign) CGRect cursorRectangle; @property (nonatomic, assign) CGFloat handleScale; @property (nonatomic, assign) BOOL visible; @property (nonatomic, copy) Block onAnimationDidStop; @end -@implementation QIOSHandleLayer +@implementation QIOSHandleLayer { + CALayer *_handleCursorLayer; + CALayer *_handleKnobLayer; + Qt::Edge _selectionEdge; +} @dynamic handleScale; -- (id)initWithKnobAtEdge:(Qt::Edge)selectionEdge +- (instancetype)initWithKnobAtEdge:(Qt::Edge)selectionEdge { if (self = [super init]) { CGColorRef bgColor = [UIColor colorWithRed:0.1 green:0.4 blue:0.9 alpha:1].CGColor; @@ -355,16 +351,8 @@ static void executeBlockWithoutAnimation(Block block) // The handle should "bounce" in when becoming visible CAKeyframeAnimation * animation = [CAKeyframeAnimation animationWithKeyPath:key]; [animation setDuration:0.5]; - animation.values = [NSArray arrayWithObjects: - [NSNumber numberWithFloat:0], - [NSNumber numberWithFloat:1.3], - [NSNumber numberWithFloat:1.3], - [NSNumber numberWithFloat:1], nil]; - animation.keyTimes = [NSArray arrayWithObjects: - [NSNumber numberWithFloat:0], - [NSNumber numberWithFloat:0.3], - [NSNumber numberWithFloat:0.9], - [NSNumber numberWithFloat:1], nil]; + animation.values = @[@(0.0f), @(1.3f), @(1.3f), @(1.0f)]; + animation.keyTimes = @[@(0.0f), @(0.3f), @(0.9f), @(1.0f)]; return animation; } else { CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:key]; @@ -436,8 +424,13 @@ static void executeBlockWithoutAnimation(Block block) below will inherit. It takes care of creating and showing a magnifier glass depending on the current gesture state. */ -@interface QIOSLoupeRecognizer : UIGestureRecognizer <UIGestureRecognizerDelegate> { -@public +@interface QIOSLoupeRecognizer : UIGestureRecognizer <UIGestureRecognizerDelegate> +@property (nonatomic, assign) QPointF focalPoint; +@property (nonatomic, assign) BOOL dragTriggersGesture; +@property (nonatomic, readonly) UIView *focusView; +@end + +@implementation QIOSLoupeRecognizer { QIOSLoupeLayer *_loupeLayer; UIView *_desktopView; CGPoint _firstTouchPoint; @@ -445,14 +438,8 @@ static void executeBlockWithoutAnimation(Block block) QTimer _triggerStateBeganTimer; int _originalCursorFlashTime; } -@property (nonatomic, assign) QPointF focalPoint; -@property (nonatomic, assign) BOOL dragTriggersGesture; -@property (nonatomic, readonly) UIView *focusView; -@end -@implementation QIOSLoupeRecognizer - -- (id)init +- (instancetype)init { if (self = [super initWithTarget:self action:@selector(gestureStateChanged)]) { self.enabled = NO; @@ -657,7 +644,10 @@ static void executeBlockWithoutAnimation(Block block) on the sides. If the user starts dragging on a handle (or do a press and hold), it will show a magnifier glass that follows the handle as it moves. */ -@interface QIOSSelectionRecognizer : QIOSLoupeRecognizer { +@interface QIOSSelectionRecognizer : QIOSLoupeRecognizer +@end + +@implementation QIOSSelectionRecognizer { CALayer *_clipRectLayer; QIOSHandleLayer *_cursorLayer; QIOSHandleLayer *_anchorLayer; @@ -669,11 +659,8 @@ static void executeBlockWithoutAnimation(Block block) QMetaObject::Connection _anchorConnection; QMetaObject::Connection _clipRectConnection; } -@end - -@implementation QIOSSelectionRecognizer -- (id)init +- (instancetype)init { if (self = [super init]) { self.delaysTouchesBegan = YES; @@ -889,15 +876,15 @@ static void executeBlockWithoutAnimation(Block block) visibility of the edit menu will be toggled. Otherwise, if there's a selection, a first tap will close the edit menu (if any), and a second tap will remove the selection. */ -@interface QIOSTapRecognizer : UITapGestureRecognizer { +@interface QIOSTapRecognizer : UITapGestureRecognizer +@end + +@implementation QIOSTapRecognizer { int _cursorPosOnPress; UIView *_focusView; } -@end - -@implementation QIOSTapRecognizer -- (id)init +- (instancetype)init { if (self = [super initWithTarget:self action:@selector(gestureStateChanged)]) { self.enabled = NO; |