objc2_sprite_kit/generated/
SKShapeNode.rs

1//! This file has been automatically generated by `objc2`'s `header-translator`.
2//! DO NOT EDIT
3use core::ffi::*;
4use core::ptr::NonNull;
5use objc2::__framework_prelude::*;
6#[cfg(feature = "objc2-app-kit")]
7#[cfg(target_os = "macos")]
8use objc2_app_kit::*;
9#[cfg(feature = "objc2-core-foundation")]
10use objc2_core_foundation::*;
11#[cfg(feature = "objc2-core-graphics")]
12use objc2_core_graphics::*;
13use objc2_foundation::*;
14
15use crate::*;
16
17extern_class!(
18    /// A SpriteKit Node used to stroke or fill a shape. CGPaths are used to supply the path.
19    ///
20    /// See CGPath
21    /// <a href="http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGPath/Reference/reference.html">
22    /// reference pages
23    /// </a>
24    /// for details on how to construct a CGPath.
25    ///
26    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/skshapenode?language=objc)
27    #[unsafe(super(SKNode, NSResponder, NSObject))]
28    #[derive(Debug, PartialEq, Eq, Hash)]
29    #[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
30    #[cfg(target_os = "macos")]
31    pub struct SKShapeNode;
32);
33
34#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
35#[cfg(target_os = "macos")]
36extern_conformance!(
37    unsafe impl NSCoding for SKShapeNode {}
38);
39
40#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
41#[cfg(target_os = "macos")]
42extern_conformance!(
43    unsafe impl NSCopying for SKShapeNode {}
44);
45
46#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
47#[cfg(target_os = "macos")]
48unsafe impl CopyingHelper for SKShapeNode {
49    type Result = Self;
50}
51
52#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
53#[cfg(target_os = "macos")]
54extern_conformance!(
55    unsafe impl NSObjectProtocol for SKShapeNode {}
56);
57
58#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
59#[cfg(target_os = "macos")]
60extern_conformance!(
61    unsafe impl NSSecureCoding for SKShapeNode {}
62);
63
64#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
65#[cfg(target_os = "macos")]
66impl SKShapeNode {
67    extern_methods!(
68        #[cfg(feature = "objc2-core-graphics")]
69        #[unsafe(method(shapeNodeWithPath:))]
70        #[unsafe(method_family = none)]
71        pub unsafe fn shapeNodeWithPath(path: &CGPath, mtm: MainThreadMarker) -> Retained<Self>;
72
73        #[cfg(feature = "objc2-core-graphics")]
74        #[unsafe(method(shapeNodeWithPath:centered:))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn shapeNodeWithPath_centered(
77            path: &CGPath,
78            centered: bool,
79            mtm: MainThreadMarker,
80        ) -> Retained<Self>;
81
82        #[cfg(feature = "objc2-core-foundation")]
83        #[unsafe(method(shapeNodeWithRect:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn shapeNodeWithRect(rect: CGRect, mtm: MainThreadMarker) -> Retained<Self>;
86
87        #[cfg(feature = "objc2-core-foundation")]
88        #[unsafe(method(shapeNodeWithRectOfSize:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn shapeNodeWithRectOfSize(
91            size: CGSize,
92            mtm: MainThreadMarker,
93        ) -> Retained<Self>;
94
95        #[cfg(feature = "objc2-core-foundation")]
96        #[unsafe(method(shapeNodeWithRect:cornerRadius:))]
97        #[unsafe(method_family = none)]
98        pub unsafe fn shapeNodeWithRect_cornerRadius(
99            rect: CGRect,
100            corner_radius: CGFloat,
101            mtm: MainThreadMarker,
102        ) -> Retained<Self>;
103
104        #[cfg(feature = "objc2-core-foundation")]
105        #[unsafe(method(shapeNodeWithRectOfSize:cornerRadius:))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn shapeNodeWithRectOfSize_cornerRadius(
108            size: CGSize,
109            corner_radius: CGFloat,
110            mtm: MainThreadMarker,
111        ) -> Retained<Self>;
112
113        #[cfg(feature = "objc2-core-foundation")]
114        #[unsafe(method(shapeNodeWithCircleOfRadius:))]
115        #[unsafe(method_family = none)]
116        pub unsafe fn shapeNodeWithCircleOfRadius(
117            radius: CGFloat,
118            mtm: MainThreadMarker,
119        ) -> Retained<Self>;
120
121        #[cfg(feature = "objc2-core-foundation")]
122        #[unsafe(method(shapeNodeWithEllipseInRect:))]
123        #[unsafe(method_family = none)]
124        pub unsafe fn shapeNodeWithEllipseInRect(
125            rect: CGRect,
126            mtm: MainThreadMarker,
127        ) -> Retained<Self>;
128
129        #[cfg(feature = "objc2-core-foundation")]
130        #[unsafe(method(shapeNodeWithEllipseOfSize:))]
131        #[unsafe(method_family = none)]
132        pub unsafe fn shapeNodeWithEllipseOfSize(
133            size: CGSize,
134            mtm: MainThreadMarker,
135        ) -> Retained<Self>;
136
137        #[cfg(feature = "objc2-core-foundation")]
138        /// # Safety
139        ///
140        /// `points` must be a valid pointer.
141        #[unsafe(method(shapeNodeWithPoints:count:))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn shapeNodeWithPoints_count(
144            points: NonNull<CGPoint>,
145            num_points: usize,
146            mtm: MainThreadMarker,
147        ) -> Retained<Self>;
148
149        #[cfg(feature = "objc2-core-foundation")]
150        /// # Safety
151        ///
152        /// `points` must be a valid pointer.
153        #[unsafe(method(shapeNodeWithSplinePoints:count:))]
154        #[unsafe(method_family = none)]
155        pub unsafe fn shapeNodeWithSplinePoints_count(
156            points: NonNull<CGPoint>,
157            num_points: usize,
158            mtm: MainThreadMarker,
159        ) -> Retained<Self>;
160
161        #[cfg(feature = "objc2-core-graphics")]
162        /// The CGPath to be drawn (in the Node's coordinate space)
163        #[unsafe(method(path))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn path(&self) -> Option<Retained<CGPath>>;
166
167        #[cfg(feature = "objc2-core-graphics")]
168        /// Setter for [`path`][Self::path].
169        #[unsafe(method(setPath:))]
170        #[unsafe(method_family = none)]
171        pub unsafe fn setPath(&self, path: Option<&CGPath>);
172
173        /// The color to draw the path with. (for no stroke use [SKColor clearColor]). Defaults to [SKColor whiteColor].
174        #[unsafe(method(strokeColor))]
175        #[unsafe(method_family = none)]
176        pub unsafe fn strokeColor(&self) -> Retained<NSColor>;
177
178        /// Setter for [`strokeColor`][Self::strokeColor].
179        #[unsafe(method(setStrokeColor:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setStrokeColor(&self, stroke_color: &NSColor);
182
183        /// The color to fill the path with. Defaults to [SKColor clearColor] (no fill).
184        #[unsafe(method(fillColor))]
185        #[unsafe(method_family = none)]
186        pub unsafe fn fillColor(&self) -> Retained<NSColor>;
187
188        /// Setter for [`fillColor`][Self::fillColor].
189        #[unsafe(method(setFillColor:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn setFillColor(&self, fill_color: &NSColor);
192
193        /// Sets the blend mode to use when composing the shape with the final framebuffer.
194        ///
195        /// See: SKNode.SKBlendMode
196        #[unsafe(method(blendMode))]
197        #[unsafe(method_family = none)]
198        pub unsafe fn blendMode(&self) -> SKBlendMode;
199
200        /// Setter for [`blendMode`][Self::blendMode].
201        #[unsafe(method(setBlendMode:))]
202        #[unsafe(method_family = none)]
203        pub unsafe fn setBlendMode(&self, blend_mode: SKBlendMode);
204
205        /// If set to YES, the path stroke edges and caps is smoothed (antialiased) when drawn.
206        #[unsafe(method(isAntialiased))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn isAntialiased(&self) -> bool;
209
210        /// Setter for [`isAntialiased`][Self::isAntialiased].
211        #[unsafe(method(setAntialiased:))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn setAntialiased(&self, antialiased: bool);
214
215        #[cfg(feature = "objc2-core-foundation")]
216        /// The width used to stroke the path. Widths larger than 2.0 may result in artifacts. Defaults to 1.0.
217        #[unsafe(method(lineWidth))]
218        #[unsafe(method_family = none)]
219        pub unsafe fn lineWidth(&self) -> CGFloat;
220
221        #[cfg(feature = "objc2-core-foundation")]
222        /// Setter for [`lineWidth`][Self::lineWidth].
223        #[unsafe(method(setLineWidth:))]
224        #[unsafe(method_family = none)]
225        pub unsafe fn setLineWidth(&self, line_width: CGFloat);
226
227        #[cfg(feature = "objc2-core-foundation")]
228        /// Add a glow to the path stroke of the specified width. Defaults to 0.0 (no glow)
229        #[unsafe(method(glowWidth))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn glowWidth(&self) -> CGFloat;
232
233        #[cfg(feature = "objc2-core-foundation")]
234        /// Setter for [`glowWidth`][Self::glowWidth].
235        #[unsafe(method(setGlowWidth:))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn setGlowWidth(&self, glow_width: CGFloat);
238
239        #[cfg(feature = "objc2-core-graphics")]
240        /// The cap type that should be used when stroking a non-closed path
241        #[unsafe(method(lineCap))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn lineCap(&self) -> CGLineCap;
244
245        #[cfg(feature = "objc2-core-graphics")]
246        /// Setter for [`lineCap`][Self::lineCap].
247        #[unsafe(method(setLineCap:))]
248        #[unsafe(method_family = none)]
249        pub unsafe fn setLineCap(&self, line_cap: CGLineCap);
250
251        #[cfg(feature = "objc2-core-graphics")]
252        /// The join type that should be used when stroking a path
253        #[unsafe(method(lineJoin))]
254        #[unsafe(method_family = none)]
255        pub unsafe fn lineJoin(&self) -> CGLineJoin;
256
257        #[cfg(feature = "objc2-core-graphics")]
258        /// Setter for [`lineJoin`][Self::lineJoin].
259        #[unsafe(method(setLineJoin:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn setLineJoin(&self, line_join: CGLineJoin);
262
263        #[cfg(feature = "objc2-core-foundation")]
264        /// When a miter join is used, the maximum ratio of miter length to line with to be used
265        #[unsafe(method(miterLimit))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn miterLimit(&self) -> CGFloat;
268
269        #[cfg(feature = "objc2-core-foundation")]
270        /// Setter for [`miterLimit`][Self::miterLimit].
271        #[unsafe(method(setMiterLimit:))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn setMiterLimit(&self, miter_limit: CGFloat);
274
275        #[cfg(feature = "objc2-core-foundation")]
276        /// The length of the node's path if it were to be stroked
277        #[unsafe(method(lineLength))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn lineLength(&self) -> CGFloat;
280
281        #[cfg(feature = "SKTexture")]
282        #[unsafe(method(fillTexture))]
283        #[unsafe(method_family = none)]
284        pub unsafe fn fillTexture(&self) -> Option<Retained<SKTexture>>;
285
286        #[cfg(feature = "SKTexture")]
287        /// Setter for [`fillTexture`][Self::fillTexture].
288        #[unsafe(method(setFillTexture:))]
289        #[unsafe(method_family = none)]
290        pub unsafe fn setFillTexture(&self, fill_texture: Option<&SKTexture>);
291
292        #[cfg(feature = "SKShader")]
293        #[unsafe(method(fillShader))]
294        #[unsafe(method_family = none)]
295        pub unsafe fn fillShader(&self) -> Option<Retained<SKShader>>;
296
297        #[cfg(feature = "SKShader")]
298        /// Setter for [`fillShader`][Self::fillShader].
299        #[unsafe(method(setFillShader:))]
300        #[unsafe(method_family = none)]
301        pub unsafe fn setFillShader(&self, fill_shader: Option<&SKShader>);
302
303        #[cfg(feature = "SKTexture")]
304        #[unsafe(method(strokeTexture))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn strokeTexture(&self) -> Option<Retained<SKTexture>>;
307
308        #[cfg(feature = "SKTexture")]
309        /// Setter for [`strokeTexture`][Self::strokeTexture].
310        #[unsafe(method(setStrokeTexture:))]
311        #[unsafe(method_family = none)]
312        pub unsafe fn setStrokeTexture(&self, stroke_texture: Option<&SKTexture>);
313
314        #[cfg(feature = "SKShader")]
315        #[unsafe(method(strokeShader))]
316        #[unsafe(method_family = none)]
317        pub unsafe fn strokeShader(&self) -> Option<Retained<SKShader>>;
318
319        #[cfg(feature = "SKShader")]
320        /// Setter for [`strokeShader`][Self::strokeShader].
321        #[unsafe(method(setStrokeShader:))]
322        #[unsafe(method_family = none)]
323        pub unsafe fn setStrokeShader(&self, stroke_shader: Option<&SKShader>);
324
325        #[cfg(feature = "SKAttribute")]
326        /// Optional dictionary of SKAttributeValues
327        /// Attributes can be used with custom SKShaders.
328        #[unsafe(method(attributeValues))]
329        #[unsafe(method_family = none)]
330        pub unsafe fn attributeValues(&self) -> Retained<NSDictionary<NSString, SKAttributeValue>>;
331
332        #[cfg(feature = "SKAttribute")]
333        /// Setter for [`attributeValues`][Self::attributeValues].
334        ///
335        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
336        #[unsafe(method(setAttributeValues:))]
337        #[unsafe(method_family = none)]
338        pub unsafe fn setAttributeValues(
339            &self,
340            attribute_values: &NSDictionary<NSString, SKAttributeValue>,
341        );
342
343        #[cfg(feature = "SKAttribute")]
344        #[unsafe(method(valueForAttributeNamed:))]
345        #[unsafe(method_family = none)]
346        pub unsafe fn valueForAttributeNamed(
347            &self,
348            key: &NSString,
349        ) -> Option<Retained<SKAttributeValue>>;
350
351        #[cfg(feature = "SKAttribute")]
352        #[unsafe(method(setValue:forAttributeNamed:))]
353        #[unsafe(method_family = none)]
354        pub unsafe fn setValue_forAttributeNamed(&self, value: &SKAttributeValue, key: &NSString);
355    );
356}
357
358/// Methods declared on superclass `SKNode`.
359#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
360#[cfg(target_os = "macos")]
361impl SKShapeNode {
362    extern_methods!(
363        #[unsafe(method(init))]
364        #[unsafe(method_family = init)]
365        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
366
367        /// Support coding and decoding via NSKeyedArchiver.
368        ///
369        /// # Safety
370        ///
371        /// `a_decoder` possibly has further requirements.
372        #[unsafe(method(initWithCoder:))]
373        #[unsafe(method_family = init)]
374        pub unsafe fn initWithCoder(
375            this: Allocated<Self>,
376            a_decoder: &NSCoder,
377        ) -> Option<Retained<Self>>;
378
379        #[unsafe(method(node))]
380        #[unsafe(method_family = none)]
381        pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
382
383        #[unsafe(method(nodeWithFileNamed:))]
384        #[unsafe(method_family = none)]
385        pub unsafe fn nodeWithFileNamed(
386            filename: &NSString,
387            mtm: MainThreadMarker,
388        ) -> Option<Retained<Self>>;
389
390        /// # Safety
391        ///
392        /// `classes` generic probably has further requirements.
393        #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
394        #[unsafe(method_family = none)]
395        pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
396            filename: &NSString,
397            classes: &NSSet<AnyClass>,
398            mtm: MainThreadMarker,
399        ) -> Result<Retained<Self>, Retained<NSError>>;
400    );
401}
402
403/// Methods declared on superclass `NSObject`.
404#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
405#[cfg(target_os = "macos")]
406impl SKShapeNode {
407    extern_methods!(
408        #[unsafe(method(new))]
409        #[unsafe(method_family = new)]
410        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
411    );
412}