@@ -12,36 +12,57 @@ import AppKit
12
12
#endif
13
13
import QuartzCore
14
14
15
+ /// A protocol that defines methods and properties for managing vector layers within a composite layer.
16
+ ///
17
+ /// This protocol is intended to be used for managing the addition and removal of vector layers,
18
+ /// which are overlaid on top of other content, such as video streams.
19
+ ///
15
20
@available ( iOS 14 , macOS 11 , tvOS 14 , * )
16
21
@MainActor
17
- public protocol LayerMakerProtocol {
18
-
19
- var compositeLayer : CALayer { get }
20
-
22
+ public protocol LayerMakerProtocol {
23
+
24
+ /// The composite layer that contains all the sublayers, including vector layers.
25
+ ///
26
+ /// This layer acts as a container for all vector layers added through the protocol methods.
27
+ var compositeLayer : CALayer { get }
28
+
29
+ /// The frame of the composite layer.
30
+ ///
31
+ /// This property defines the size and position of the composite layer within its parent view.
21
32
var frame : CGRect { get set }
22
-
23
- var bounds : CGRect { get set }
24
-
25
- func addVectorLayer( builder : any ShapeLayerBuilderProtocol , clear: Bool )
26
-
33
+
34
+ /// The bounds of the composite layer.
35
+ ///
36
+ /// This property defines the drawable area of the composite layer, relative to its own coordinate system.
37
+ var bounds : CGRect { get set }
38
+
39
+ /// Adds a vector layer to the composite layer using a specified builder.
40
+ ///
41
+ /// - Parameters:
42
+ /// - builder: An instance conforming to `ShapeLayerBuilderProtocol` that constructs the vector layer.
43
+ /// - clear: A Boolean value that indicates whether to clear existing vector layers before adding the new one.
44
+ func addVectorLayer( builder: any ShapeLayerBuilderProtocol , clear: Bool )
45
+
46
+ /// Removes all vector layers from the composite layer.
27
47
func removeAllVectors( )
28
48
}
29
49
30
50
extension LayerMakerProtocol {
31
51
32
52
@MainActor
33
- /// Sets a vector graphic operation on the video player.
53
+ /// Adds a vector layer to the composite layer using a specified builder.
54
+ ///
34
55
/// - Parameters:
35
- /// - builder: An instance conforming to `ShapeLayerBuilderProtocol` to provide the shape layer.
36
- /// - clear: A Boolean value indicating whether to clear existing vector graphics before applying the new one. Defaults to `false` .
56
+ /// - builder: An instance conforming to `ShapeLayerBuilderProtocol` that constructs the vector layer.
57
+ /// - clear: A Boolean value that indicates whether to clear existing vector layers before adding the new one.
37
58
func addVectorLayer( builder : any ShapeLayerBuilderProtocol , clear: Bool ) {
38
59
if clear{ removeAllVectors ( ) }
39
60
let layer = builder. build ( with: ( frame, bounds) )
40
61
compositeLayer. addSublayer ( layer)
41
62
}
42
63
43
64
@MainActor
44
- /// Clears all vector graphics from the video player .
65
+ /// Removes all vector layers from the composite layer .
45
66
func removeAllVectors( ) {
46
67
compositeLayer. sublayers? . forEach { $0. removeFromSuperlayer ( ) }
47
68
}
0 commit comments