|
| 1 | +// |
| 2 | +// OGFPlaceholderTypes.swift |
| 3 | +// OpenGestures |
| 4 | +// |
| 5 | +// Placeholder protocol definitions for non-Darwin platforms where |
| 6 | +// the ObjC protocols from COpenGestures are not available. |
| 7 | + |
| 8 | +#if !canImport(ObjectiveC) |
| 9 | + |
| 10 | +public protocol OGFGestureNode: AnyObject { |
| 11 | + // weak in ObjC |
| 12 | + // Swift protocols can't express weak without @objc, |
| 13 | + /*weak*/ var delegate: (any OGFGestureNodeDelegate)? { get set } |
| 14 | + /*weak*/ var container: (any OGFGestureNodeContainer)? { get set } |
| 15 | + var coordinator: (any OGFGestureNodeCoordinator)? { get set } |
| 16 | + var phase: OGFGesturePhase { get } |
| 17 | + var isBlocked: Bool { get } |
| 18 | + var identifier: String { get } |
| 19 | + var tag: String? { get set } |
| 20 | + var isDisabled: Bool { get set } |
| 21 | + var disallowExclusionWithUnresolvedFailureRequirements: Bool { get set } |
| 22 | + var platformKey: Int { get } |
| 23 | + var failureReason: (any Error)? { get } |
| 24 | + |
| 25 | + func abort() throws |
| 26 | + func addRelation(type: OGFGestureRelationType, role: OGFGestureRelationRole, relatedNode: any OGFGestureNode) |
| 27 | + func ensureUpdated() throws |
| 28 | + func fail(reason: Any?, error: inout (any Error)?) throws |
| 29 | + func removeRelation(type: OGFGestureRelationType, role: OGFGestureRelationRole, relatedNode: any OGFGestureNode) |
| 30 | + func setTracking(_ tracking: Bool, eventsWithIdentifiers identifiers: [Any]) |
| 31 | + func update(value: Any?, isFinal: Bool) throws |
| 32 | +} |
| 33 | + |
| 34 | +public protocol OGFGestureNodeDelegate: AnyObject { |
| 35 | + func gestureNode(_ node: any OGFGestureNode, didUpdatePhase phase: OGFGesturePhase) |
| 36 | + func gestureNode(_ node: any OGFGestureNode, roleForRelationType type: OGFGestureRelationType, relatedNode: any OGFGestureNode) -> Any? |
| 37 | + func gestureNodeShouldActivate(_ node: any OGFGestureNode) -> Bool |
| 38 | + func gestureNodeWillUnblock(_ node: any OGFGestureNode) |
| 39 | + |
| 40 | + // optional in ObjC |
| 41 | + // Swift protocols can't express optional without @objc, |
| 42 | + // so we provide default empty implementations below. |
| 43 | + /*optional*/ func gestureNode(_ node: any OGFGestureNode, didEnqueuePhase phase: OGFGesturePhase) |
| 44 | + /*optional*/ func gestureNodeWillAbort(_ node: any OGFGestureNode) |
| 45 | +} |
| 46 | + |
| 47 | +extension OGFGestureNodeDelegate { |
| 48 | + public func gestureNode(_ node: any OGFGestureNode, didEnqueuePhase phase: OGFGesturePhase) {} |
| 49 | + public func gestureNodeWillAbort(_ node: any OGFGestureNode) {} |
| 50 | +} |
| 51 | + |
| 52 | +public protocol OGFGestureNodeContainer: AnyObject { |
| 53 | + func indexOfGestureNode(_ node: any OGFGestureNode) -> Int |
| 54 | + func isDeeperThanContainer(_ container: any OGFGestureNodeContainer, referenceNode: any OGFGestureNode) -> Bool |
| 55 | + func isDescendantOfContainer(_ container: any OGFGestureNodeContainer, referenceNode: any OGFGestureNode) -> Bool |
| 56 | +} |
| 57 | + |
| 58 | +public protocol OGFGestureNodeCoordinator: AnyObject { |
| 59 | + var nodes: [any OGFGestureNode] { get } |
| 60 | + var willUpdateHandler: (() -> Void)? { get set } |
| 61 | + var willProcessUpdateQueueHandler: (() -> Void)? { get set } |
| 62 | + var didUpdateHandler: (() -> Void)? { get set } |
| 63 | + |
| 64 | + func enqueueUpdatesForNodes(_ nodes: [any OGFGestureNode], inBlock block: ([any OGFGestureNode]) -> Void, reason: String) |
| 65 | + func hasUnresolvedFailureDependenciesForNode(_ node: any OGFGestureNode) -> Bool |
| 66 | + func updateWithNodes(_ nodes: [any OGFGestureNode], reason: String, updateHandler: ([any OGFGestureNode]) -> Void) |
| 67 | + func failureDependentsForNode(_ node: any OGFGestureNode) -> [any OGFGestureNode] |
| 68 | + func processUpdatesWithReason(_ reason: String) |
| 69 | +} |
| 70 | + |
| 71 | +#endif |
0 commit comments