objc2-sprite-kit 0.3.2

Bindings to the SpriteKit framework
Documentation
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-app-kit")]
#[cfg(target_os = "macos")]
use objc2_app_kit::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
#[cfg(feature = "objc2-core-graphics")]
use objc2_core_graphics::*;
use objc2_foundation::*;

use crate::*;

extern_class!(
    /// A SpriteKit Node used to stroke or fill a shape. CGPaths are used to supply the path.
    ///
    /// See CGPath
    /// <a href="http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGPath/Reference/reference.html">
    /// reference pages
    /// </a>
    /// for details on how to construct a CGPath.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/skshapenode?language=objc)
    #[unsafe(super(SKNode, NSResponder, NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    #[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
    #[cfg(target_os = "macos")]
    pub struct SKShapeNode;
);

#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSCoding for SKShapeNode {}
);

#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSCopying for SKShapeNode {}
);

#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
unsafe impl CopyingHelper for SKShapeNode {
    type Result = Self;
}

#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSObjectProtocol for SKShapeNode {}
);

#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
extern_conformance!(
    unsafe impl NSSecureCoding for SKShapeNode {}
);

#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
impl SKShapeNode {
    extern_methods!(
        #[cfg(feature = "objc2-core-graphics")]
        #[unsafe(method(shapeNodeWithPath:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithPath(path: &CGPath, mtm: MainThreadMarker) -> Retained<Self>;

        #[cfg(feature = "objc2-core-graphics")]
        #[unsafe(method(shapeNodeWithPath:centered:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithPath_centered(
            path: &CGPath,
            centered: bool,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(shapeNodeWithRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithRect(rect: CGRect, mtm: MainThreadMarker) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(shapeNodeWithRectOfSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithRectOfSize(
            size: CGSize,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(shapeNodeWithRect:cornerRadius:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithRect_cornerRadius(
            rect: CGRect,
            corner_radius: CGFloat,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(shapeNodeWithRectOfSize:cornerRadius:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithRectOfSize_cornerRadius(
            size: CGSize,
            corner_radius: CGFloat,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(shapeNodeWithCircleOfRadius:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithCircleOfRadius(
            radius: CGFloat,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(shapeNodeWithEllipseInRect:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithEllipseInRect(
            rect: CGRect,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(shapeNodeWithEllipseOfSize:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithEllipseOfSize(
            size: CGSize,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        /// # Safety
        ///
        /// `points` must be a valid pointer.
        #[unsafe(method(shapeNodeWithPoints:count:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithPoints_count(
            points: NonNull<CGPoint>,
            num_points: usize,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-foundation")]
        /// # Safety
        ///
        /// `points` must be a valid pointer.
        #[unsafe(method(shapeNodeWithSplinePoints:count:))]
        #[unsafe(method_family = none)]
        pub unsafe fn shapeNodeWithSplinePoints_count(
            points: NonNull<CGPoint>,
            num_points: usize,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[cfg(feature = "objc2-core-graphics")]
        /// The CGPath to be drawn (in the Node's coordinate space)
        #[unsafe(method(path))]
        #[unsafe(method_family = none)]
        pub unsafe fn path(&self) -> Option<Retained<CGPath>>;

        #[cfg(feature = "objc2-core-graphics")]
        /// Setter for [`path`][Self::path].
        #[unsafe(method(setPath:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPath(&self, path: Option<&CGPath>);

        /// The color to draw the path with. (for no stroke use [SKColor clearColor]). Defaults to [SKColor whiteColor].
        #[unsafe(method(strokeColor))]
        #[unsafe(method_family = none)]
        pub unsafe fn strokeColor(&self) -> Retained<NSColor>;

        /// Setter for [`strokeColor`][Self::strokeColor].
        #[unsafe(method(setStrokeColor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setStrokeColor(&self, stroke_color: &NSColor);

        /// The color to fill the path with. Defaults to [SKColor clearColor] (no fill).
        #[unsafe(method(fillColor))]
        #[unsafe(method_family = none)]
        pub unsafe fn fillColor(&self) -> Retained<NSColor>;

        /// Setter for [`fillColor`][Self::fillColor].
        #[unsafe(method(setFillColor:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFillColor(&self, fill_color: &NSColor);

        /// Sets the blend mode to use when composing the shape with the final framebuffer.
        ///
        /// See: SKNode.SKBlendMode
        #[unsafe(method(blendMode))]
        #[unsafe(method_family = none)]
        pub unsafe fn blendMode(&self) -> SKBlendMode;

        /// Setter for [`blendMode`][Self::blendMode].
        #[unsafe(method(setBlendMode:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBlendMode(&self, blend_mode: SKBlendMode);

        /// If set to YES, the path stroke edges and caps is smoothed (antialiased) when drawn.
        #[unsafe(method(isAntialiased))]
        #[unsafe(method_family = none)]
        pub unsafe fn isAntialiased(&self) -> bool;

        /// Setter for [`isAntialiased`][Self::isAntialiased].
        #[unsafe(method(setAntialiased:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAntialiased(&self, antialiased: bool);

        #[cfg(feature = "objc2-core-foundation")]
        /// The width used to stroke the path. Widths larger than 2.0 may result in artifacts. Defaults to 1.0.
        #[unsafe(method(lineWidth))]
        #[unsafe(method_family = none)]
        pub unsafe fn lineWidth(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`lineWidth`][Self::lineWidth].
        #[unsafe(method(setLineWidth:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLineWidth(&self, line_width: CGFloat);

        #[cfg(feature = "objc2-core-foundation")]
        /// Add a glow to the path stroke of the specified width. Defaults to 0.0 (no glow)
        #[unsafe(method(glowWidth))]
        #[unsafe(method_family = none)]
        pub unsafe fn glowWidth(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`glowWidth`][Self::glowWidth].
        #[unsafe(method(setGlowWidth:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setGlowWidth(&self, glow_width: CGFloat);

        #[cfg(feature = "objc2-core-graphics")]
        /// The cap type that should be used when stroking a non-closed path
        #[unsafe(method(lineCap))]
        #[unsafe(method_family = none)]
        pub unsafe fn lineCap(&self) -> CGLineCap;

        #[cfg(feature = "objc2-core-graphics")]
        /// Setter for [`lineCap`][Self::lineCap].
        #[unsafe(method(setLineCap:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLineCap(&self, line_cap: CGLineCap);

        #[cfg(feature = "objc2-core-graphics")]
        /// The join type that should be used when stroking a path
        #[unsafe(method(lineJoin))]
        #[unsafe(method_family = none)]
        pub unsafe fn lineJoin(&self) -> CGLineJoin;

        #[cfg(feature = "objc2-core-graphics")]
        /// Setter for [`lineJoin`][Self::lineJoin].
        #[unsafe(method(setLineJoin:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLineJoin(&self, line_join: CGLineJoin);

        #[cfg(feature = "objc2-core-foundation")]
        /// When a miter join is used, the maximum ratio of miter length to line with to be used
        #[unsafe(method(miterLimit))]
        #[unsafe(method_family = none)]
        pub unsafe fn miterLimit(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`miterLimit`][Self::miterLimit].
        #[unsafe(method(setMiterLimit:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setMiterLimit(&self, miter_limit: CGFloat);

        #[cfg(feature = "objc2-core-foundation")]
        /// The length of the node's path if it were to be stroked
        #[unsafe(method(lineLength))]
        #[unsafe(method_family = none)]
        pub unsafe fn lineLength(&self) -> CGFloat;

        #[cfg(feature = "SKTexture")]
        #[unsafe(method(fillTexture))]
        #[unsafe(method_family = none)]
        pub unsafe fn fillTexture(&self) -> Option<Retained<SKTexture>>;

        #[cfg(feature = "SKTexture")]
        /// Setter for [`fillTexture`][Self::fillTexture].
        #[unsafe(method(setFillTexture:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFillTexture(&self, fill_texture: Option<&SKTexture>);

        #[cfg(feature = "SKShader")]
        #[unsafe(method(fillShader))]
        #[unsafe(method_family = none)]
        pub unsafe fn fillShader(&self) -> Option<Retained<SKShader>>;

        #[cfg(feature = "SKShader")]
        /// Setter for [`fillShader`][Self::fillShader].
        #[unsafe(method(setFillShader:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFillShader(&self, fill_shader: Option<&SKShader>);

        #[cfg(feature = "SKTexture")]
        #[unsafe(method(strokeTexture))]
        #[unsafe(method_family = none)]
        pub unsafe fn strokeTexture(&self) -> Option<Retained<SKTexture>>;

        #[cfg(feature = "SKTexture")]
        /// Setter for [`strokeTexture`][Self::strokeTexture].
        #[unsafe(method(setStrokeTexture:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setStrokeTexture(&self, stroke_texture: Option<&SKTexture>);

        #[cfg(feature = "SKShader")]
        #[unsafe(method(strokeShader))]
        #[unsafe(method_family = none)]
        pub unsafe fn strokeShader(&self) -> Option<Retained<SKShader>>;

        #[cfg(feature = "SKShader")]
        /// Setter for [`strokeShader`][Self::strokeShader].
        #[unsafe(method(setStrokeShader:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setStrokeShader(&self, stroke_shader: Option<&SKShader>);

        #[cfg(feature = "SKAttribute")]
        /// Optional dictionary of SKAttributeValues
        /// Attributes can be used with custom SKShaders.
        #[unsafe(method(attributeValues))]
        #[unsafe(method_family = none)]
        pub unsafe fn attributeValues(&self) -> Retained<NSDictionary<NSString, SKAttributeValue>>;

        #[cfg(feature = "SKAttribute")]
        /// Setter for [`attributeValues`][Self::attributeValues].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setAttributeValues:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAttributeValues(
            &self,
            attribute_values: &NSDictionary<NSString, SKAttributeValue>,
        );

        #[cfg(feature = "SKAttribute")]
        #[unsafe(method(valueForAttributeNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn valueForAttributeNamed(
            &self,
            key: &NSString,
        ) -> Option<Retained<SKAttributeValue>>;

        #[cfg(feature = "SKAttribute")]
        #[unsafe(method(setValue:forAttributeNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setValue_forAttributeNamed(&self, value: &SKAttributeValue, key: &NSString);
    );
}

/// Methods declared on superclass `SKNode`.
#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
impl SKShapeNode {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        /// Support coding and decoding via NSKeyedArchiver.
        ///
        /// # Safety
        ///
        /// `a_decoder` possibly has further requirements.
        #[unsafe(method(initWithCoder:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithCoder(
            this: Allocated<Self>,
            a_decoder: &NSCoder,
        ) -> Option<Retained<Self>>;

        #[unsafe(method(node))]
        #[unsafe(method_family = none)]
        pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;

        #[unsafe(method(nodeWithFileNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn nodeWithFileNamed(
            filename: &NSString,
            mtm: MainThreadMarker,
        ) -> Option<Retained<Self>>;

        /// # Safety
        ///
        /// `classes` generic probably has further requirements.
        #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
        #[unsafe(method_family = none)]
        pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
            filename: &NSString,
            classes: &NSSet<AnyClass>,
            mtm: MainThreadMarker,
        ) -> Result<Retained<Self>, Retained<NSError>>;
    );
}

/// Methods declared on superclass `NSObject`.
#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
#[cfg(target_os = "macos")]
impl SKShapeNode {
    extern_methods!(
        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}