summaryrefslogtreecommitdiff
path: root/SmartDeviceLink/SDLTouchManager.h
blob: 185aae1749100e9caf18ae2d0457ade405eb44b3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
//
//  SDLTouchManager.h
//  SmartDeviceLink-iOS
//
//  Created by Muller, Alexander (A.) on 6/14/16.
//  Copyright © 2016 smartdevicelink. All rights reserved.
//

#import <UIKit/UIKit.h>

#import "SDLTouchType.h"

@protocol SDLFocusableItemHitTester;
@protocol SDLTouchManagerDelegate;

@class SDLTouch;

NS_ASSUME_NONNULL_BEGIN

typedef void(^SDLTouchEventHandler)(SDLTouch *touch, SDLTouchType type);


@interface SDLTouchManager : NSObject

/**
 Notified of processed touches such as pinches, pans, and taps
 */
@property (nonatomic, weak, nullable) id<SDLTouchManagerDelegate> touchEventDelegate;

/**
 *  @abstract
 *      Returns all OnTouchEvent notifications as SDLTouch and SDLTouchType objects.
 */
@property (copy, nonatomic, nullable) SDLTouchEventHandler touchEventHandler;

/**
 Distance between two taps on the screen, in the head unit's coordinate system, used for registering double-tap callbacks.

 @note Defaults to 50 px.
 */
@property (nonatomic, assign) CGFloat tapDistanceThreshold;

/**
 Minimum distance for a pan gesture in the head unit's coordinate system, used for registering pan callbacks.
 
 @note Defaults to 8 px.
 */
@property (nonatomic, assign) CGFloat panDistanceThreshold;

/**
 *  @abstract
 *      Time (in seconds) between tap events to register a double-tap callback.
 *  @remark
 *      Default is 0.4 seconds.
 */
@property (nonatomic, assign) CGFloat tapTimeThreshold;

/**
 *  @abstract
 *      Time (in seconds) between movement events to register panning or pinching 
 *      callbacks.
 *  @remark
 *      Default is 0.05 seconds.
 */
@property (nonatomic, assign) CGFloat movementTimeThreshold __deprecated_msg("This is now unused, the movement time threshold is now synced to the framerate automatically");

/**
 If set to NO, the display link syncing will be ignored and `movementTimeThreshold` will be used. Defaults to YES.
 */
@property (assign, nonatomic) BOOL enableSyncedPanning;

/**
 *  @abstract
 *      Boolean denoting whether or not the touch manager should deliver touch event
 *      callbacks.
 *  @remark
 *      Default is true.
 */
@property (nonatomic, assign, getter=isTouchEnabled) BOOL touchEnabled;

/**
 *  @abstract
 *      Cancels pending touch event timers that may be in progress.
 *  @remark
 *      Currently only impacts the timer used to register single taps.
 */
- (void)cancelPendingTouches;

- (instancetype)init NS_UNAVAILABLE;

/**
 Initialize a touch manager with a hit tester if available

 @param hitTester The hit tester to be used to correlate a point with a view
 @return The initialized touch manager
 */
- (instancetype)initWithHitTester:(nullable id<SDLFocusableItemHitTester>)hitTester;

/**
 Called by SDLStreamingMediaManager in sync with the streaming framerate. This helps to moderate panning gestures by allowing the UI to be modified in time with the framerate.
 */
- (void)syncFrame;

@end

NS_ASSUME_NONNULL_END