objc2_sprite_kit/generated/
SKNode.rs1use 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::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15#[repr(transparent)]
20#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
21pub struct SKBlendMode(pub NSInteger);
22impl SKBlendMode {
23 #[doc(alias = "SKBlendModeAlpha")]
24 pub const Alpha: Self = Self(0);
25 #[doc(alias = "SKBlendModeAdd")]
26 pub const Add: Self = Self(1);
27 #[doc(alias = "SKBlendModeSubtract")]
28 pub const Subtract: Self = Self(2);
29 #[doc(alias = "SKBlendModeMultiply")]
30 pub const Multiply: Self = Self(3);
31 #[doc(alias = "SKBlendModeMultiplyX2")]
32 pub const MultiplyX2: Self = Self(4);
33 #[doc(alias = "SKBlendModeScreen")]
34 pub const Screen: Self = Self(5);
35 #[doc(alias = "SKBlendModeReplace")]
36 pub const Replace: Self = Self(6);
37 #[doc(alias = "SKBlendModeMultiplyAlpha")]
38 pub const MultiplyAlpha: Self = Self(7);
39}
40
41unsafe impl Encode for SKBlendMode {
42 const ENCODING: Encoding = NSInteger::ENCODING;
43}
44
45unsafe impl RefEncode for SKBlendMode {
46 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
47}
48
49#[repr(transparent)]
52#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
53pub struct SKNodeFocusBehavior(pub NSInteger);
54impl SKNodeFocusBehavior {
55 #[doc(alias = "SKNodeFocusBehaviorNone")]
56 pub const None: Self = Self(0);
57 #[doc(alias = "SKNodeFocusBehaviorOccluding")]
58 pub const Occluding: Self = Self(1);
59 #[doc(alias = "SKNodeFocusBehaviorFocusable")]
60 pub const Focusable: Self = Self(2);
61}
62
63unsafe impl Encode for SKNodeFocusBehavior {
64 const ENCODING: Encoding = NSInteger::ENCODING;
65}
66
67unsafe impl RefEncode for SKNodeFocusBehavior {
68 const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
69}
70
71extern_class!(
72 #[unsafe(super(NSResponder, NSObject))]
74 #[derive(Debug, PartialEq, Eq, Hash)]
75 #[cfg(feature = "objc2-app-kit")]
76 #[cfg(target_os = "macos")]
77 pub struct SKNode;
78);
79
80#[cfg(feature = "objc2-app-kit")]
81#[cfg(target_os = "macos")]
82extern_conformance!(
83 unsafe impl NSCoding for SKNode {}
84);
85
86#[cfg(feature = "objc2-app-kit")]
87#[cfg(target_os = "macos")]
88extern_conformance!(
89 unsafe impl NSCopying for SKNode {}
90);
91
92#[cfg(feature = "objc2-app-kit")]
93#[cfg(target_os = "macos")]
94unsafe impl CopyingHelper for SKNode {
95 type Result = Self;
96}
97
98#[cfg(feature = "objc2-app-kit")]
99#[cfg(target_os = "macos")]
100extern_conformance!(
101 unsafe impl NSObjectProtocol for SKNode {}
102);
103
104#[cfg(feature = "objc2-app-kit")]
105#[cfg(target_os = "macos")]
106extern_conformance!(
107 unsafe impl NSSecureCoding for SKNode {}
108);
109
110#[cfg(feature = "objc2-app-kit")]
111#[cfg(target_os = "macos")]
112impl SKNode {
113 extern_methods!(
114 #[unsafe(method(init))]
115 #[unsafe(method_family = init)]
116 pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
117
118 #[unsafe(method(initWithCoder:))]
120 #[unsafe(method_family = init)]
121 pub unsafe fn initWithCoder(
122 this: Allocated<Self>,
123 a_decoder: &NSCoder,
124 ) -> Option<Retained<Self>>;
125
126 #[unsafe(method(node))]
127 #[unsafe(method_family = none)]
128 pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
129
130 #[unsafe(method(nodeWithFileNamed:))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn nodeWithFileNamed(
133 filename: &NSString,
134 mtm: MainThreadMarker,
135 ) -> Option<Retained<Self>>;
136
137 #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
138 #[unsafe(method_family = none)]
139 pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
140 filename: &NSString,
141 classes: &NSSet<AnyClass>,
142 mtm: MainThreadMarker,
143 ) -> Result<Retained<Self>, Retained<NSError>>;
144
145 #[cfg(feature = "objc2-core-foundation")]
146 #[unsafe(method(frame))]
147 #[unsafe(method_family = none)]
148 pub unsafe fn frame(&self) -> CGRect;
149
150 #[cfg(feature = "objc2-core-foundation")]
151 #[unsafe(method(calculateAccumulatedFrame))]
153 #[unsafe(method_family = none)]
154 pub unsafe fn calculateAccumulatedFrame(&self) -> CGRect;
155
156 #[cfg(feature = "objc2-core-foundation")]
157 #[unsafe(method(position))]
159 #[unsafe(method_family = none)]
160 pub unsafe fn position(&self) -> CGPoint;
161
162 #[cfg(feature = "objc2-core-foundation")]
163 #[unsafe(method(setPosition:))]
165 #[unsafe(method_family = none)]
166 pub unsafe fn setPosition(&self, position: CGPoint);
167
168 #[cfg(feature = "objc2-core-foundation")]
169 #[unsafe(method(zPosition))]
171 #[unsafe(method_family = none)]
172 pub unsafe fn zPosition(&self) -> CGFloat;
173
174 #[cfg(feature = "objc2-core-foundation")]
175 #[unsafe(method(setZPosition:))]
177 #[unsafe(method_family = none)]
178 pub unsafe fn setZPosition(&self, z_position: CGFloat);
179
180 #[cfg(feature = "objc2-core-foundation")]
181 #[unsafe(method(zRotation))]
183 #[unsafe(method_family = none)]
184 pub unsafe fn zRotation(&self) -> CGFloat;
185
186 #[cfg(feature = "objc2-core-foundation")]
187 #[unsafe(method(setZRotation:))]
189 #[unsafe(method_family = none)]
190 pub unsafe fn setZRotation(&self, z_rotation: CGFloat);
191
192 #[cfg(feature = "objc2-core-foundation")]
193 #[unsafe(method(xScale))]
195 #[unsafe(method_family = none)]
196 pub unsafe fn xScale(&self) -> CGFloat;
197
198 #[cfg(feature = "objc2-core-foundation")]
199 #[unsafe(method(setXScale:))]
201 #[unsafe(method_family = none)]
202 pub unsafe fn setXScale(&self, x_scale: CGFloat);
203
204 #[cfg(feature = "objc2-core-foundation")]
205 #[unsafe(method(yScale))]
207 #[unsafe(method_family = none)]
208 pub unsafe fn yScale(&self) -> CGFloat;
209
210 #[cfg(feature = "objc2-core-foundation")]
211 #[unsafe(method(setYScale:))]
213 #[unsafe(method_family = none)]
214 pub unsafe fn setYScale(&self, y_scale: CGFloat);
215
216 #[cfg(feature = "objc2-core-foundation")]
217 #[unsafe(method(speed))]
219 #[unsafe(method_family = none)]
220 pub unsafe fn speed(&self) -> CGFloat;
221
222 #[cfg(feature = "objc2-core-foundation")]
223 #[unsafe(method(setSpeed:))]
225 #[unsafe(method_family = none)]
226 pub unsafe fn setSpeed(&self, speed: CGFloat);
227
228 #[cfg(feature = "objc2-core-foundation")]
229 #[unsafe(method(alpha))]
231 #[unsafe(method_family = none)]
232 pub unsafe fn alpha(&self) -> CGFloat;
233
234 #[cfg(feature = "objc2-core-foundation")]
235 #[unsafe(method(setAlpha:))]
237 #[unsafe(method_family = none)]
238 pub unsafe fn setAlpha(&self, alpha: CGFloat);
239
240 #[unsafe(method(isPaused))]
242 #[unsafe(method_family = none)]
243 pub unsafe fn isPaused(&self) -> bool;
244
245 #[unsafe(method(setPaused:))]
247 #[unsafe(method_family = none)]
248 pub unsafe fn setPaused(&self, paused: bool);
249
250 #[unsafe(method(isHidden))]
252 #[unsafe(method_family = none)]
253 pub unsafe fn isHidden(&self) -> bool;
254
255 #[unsafe(method(setHidden:))]
257 #[unsafe(method_family = none)]
258 pub unsafe fn setHidden(&self, hidden: bool);
259
260 #[unsafe(method(isUserInteractionEnabled))]
262 #[unsafe(method_family = none)]
263 pub unsafe fn isUserInteractionEnabled(&self) -> bool;
264
265 #[unsafe(method(setUserInteractionEnabled:))]
267 #[unsafe(method_family = none)]
268 pub unsafe fn setUserInteractionEnabled(&self, user_interaction_enabled: bool);
269
270 #[unsafe(method(focusBehavior))]
272 #[unsafe(method_family = none)]
273 pub unsafe fn focusBehavior(&self) -> SKNodeFocusBehavior;
274
275 #[unsafe(method(setFocusBehavior:))]
277 #[unsafe(method_family = none)]
278 pub unsafe fn setFocusBehavior(&self, focus_behavior: SKNodeFocusBehavior);
279
280 #[unsafe(method(parent))]
284 #[unsafe(method_family = none)]
285 pub unsafe fn parent(&self) -> Option<Retained<SKNode>>;
286
287 #[unsafe(method(children))]
289 #[unsafe(method_family = none)]
290 pub unsafe fn children(&self) -> Retained<NSArray<SKNode>>;
291
292 #[unsafe(method(name))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
298
299 #[unsafe(method(setName:))]
301 #[unsafe(method_family = none)]
302 pub unsafe fn setName(&self, name: Option<&NSString>);
303
304 #[cfg(all(feature = "SKEffectNode", feature = "SKScene"))]
305 #[unsafe(method(scene))]
307 #[unsafe(method_family = none)]
308 pub unsafe fn scene(&self) -> Option<Retained<SKScene>>;
309
310 #[cfg(feature = "SKPhysicsBody")]
311 #[unsafe(method(physicsBody))]
313 #[unsafe(method_family = none)]
314 pub unsafe fn physicsBody(&self) -> Option<Retained<SKPhysicsBody>>;
315
316 #[cfg(feature = "SKPhysicsBody")]
317 #[unsafe(method(setPhysicsBody:))]
319 #[unsafe(method_family = none)]
320 pub unsafe fn setPhysicsBody(&self, physics_body: Option<&SKPhysicsBody>);
321
322 #[unsafe(method(userData))]
324 #[unsafe(method_family = none)]
325 pub unsafe fn userData(&self) -> Option<Retained<NSMutableDictionary>>;
326
327 #[unsafe(method(setUserData:))]
329 #[unsafe(method_family = none)]
330 pub unsafe fn setUserData(&self, user_data: Option<&NSMutableDictionary>);
331
332 #[cfg(feature = "SKReachConstraints")]
333 #[unsafe(method(reachConstraints))]
335 #[unsafe(method_family = none)]
336 pub unsafe fn reachConstraints(&self) -> Option<Retained<SKReachConstraints>>;
337
338 #[cfg(feature = "SKReachConstraints")]
339 #[unsafe(method(setReachConstraints:))]
341 #[unsafe(method_family = none)]
342 pub unsafe fn setReachConstraints(&self, reach_constraints: Option<&SKReachConstraints>);
343
344 #[cfg(feature = "SKConstraint")]
345 #[unsafe(method(constraints))]
349 #[unsafe(method_family = none)]
350 pub unsafe fn constraints(&self) -> Option<Retained<NSArray<SKConstraint>>>;
351
352 #[cfg(feature = "SKConstraint")]
353 #[unsafe(method(setConstraints:))]
355 #[unsafe(method_family = none)]
356 pub unsafe fn setConstraints(&self, constraints: Option<&NSArray<SKConstraint>>);
357
358 #[cfg(feature = "SKAttribute")]
359 #[deprecated]
363 #[unsafe(method(attributeValues))]
364 #[unsafe(method_family = none)]
365 pub unsafe fn attributeValues(&self) -> Retained<NSDictionary<NSString, SKAttributeValue>>;
366
367 #[cfg(feature = "SKAttribute")]
368 #[deprecated]
370 #[unsafe(method(setAttributeValues:))]
371 #[unsafe(method_family = none)]
372 pub unsafe fn setAttributeValues(
373 &self,
374 attribute_values: &NSDictionary<NSString, SKAttributeValue>,
375 );
376
377 #[cfg(feature = "SKAttribute")]
378 #[deprecated]
379 #[unsafe(method(valueForAttributeNamed:))]
380 #[unsafe(method_family = none)]
381 pub unsafe fn valueForAttributeNamed(
382 &self,
383 key: &NSString,
384 ) -> Option<Retained<SKAttributeValue>>;
385
386 #[cfg(feature = "SKAttribute")]
387 #[deprecated]
388 #[unsafe(method(setValue:forAttributeNamed:))]
389 #[unsafe(method_family = none)]
390 pub unsafe fn setValue_forAttributeNamed(&self, value: &SKAttributeValue, key: &NSString);
391
392 #[cfg(feature = "objc2-core-foundation")]
393 #[unsafe(method(setScale:))]
400 #[unsafe(method_family = none)]
401 pub unsafe fn setScale(&self, scale: CGFloat);
402
403 #[unsafe(method(addChild:))]
410 #[unsafe(method_family = none)]
411 pub unsafe fn addChild(&self, node: &SKNode);
412
413 #[unsafe(method(insertChild:atIndex:))]
414 #[unsafe(method_family = none)]
415 pub unsafe fn insertChild_atIndex(&self, node: &SKNode, index: NSInteger);
416
417 #[unsafe(method(removeChildrenInArray:))]
418 #[unsafe(method_family = none)]
419 pub unsafe fn removeChildrenInArray(&self, nodes: &NSArray<SKNode>);
420
421 #[unsafe(method(removeAllChildren))]
422 #[unsafe(method_family = none)]
423 pub unsafe fn removeAllChildren(&self);
424
425 #[unsafe(method(removeFromParent))]
426 #[unsafe(method_family = none)]
427 pub unsafe fn removeFromParent(&self);
428
429 #[unsafe(method(moveToParent:))]
430 #[unsafe(method_family = none)]
431 pub unsafe fn moveToParent(&self, parent: &SKNode);
432
433 #[unsafe(method(childNodeWithName:))]
434 #[unsafe(method_family = none)]
435 pub unsafe fn childNodeWithName(&self, name: &NSString) -> Option<Retained<SKNode>>;
436
437 #[cfg(feature = "block2")]
438 #[unsafe(method(enumerateChildNodesWithName:usingBlock:))]
439 #[unsafe(method_family = none)]
440 pub unsafe fn enumerateChildNodesWithName_usingBlock(
441 &self,
442 name: &NSString,
443 block: &block2::DynBlock<dyn Fn(NonNull<SKNode>, NonNull<Bool>)>,
444 );
445
446 #[unsafe(method(objectForKeyedSubscript:))]
462 #[unsafe(method_family = none)]
463 pub unsafe fn objectForKeyedSubscript(&self, name: &NSString) -> Retained<NSArray<SKNode>>;
464
465 #[unsafe(method(inParentHierarchy:))]
466 #[unsafe(method_family = none)]
467 pub unsafe fn inParentHierarchy(&self, parent: &SKNode) -> bool;
468
469 #[cfg(feature = "SKAction")]
470 #[unsafe(method(runAction:))]
471 #[unsafe(method_family = none)]
472 pub unsafe fn runAction(&self, action: &SKAction);
473
474 #[cfg(all(feature = "SKAction", feature = "block2"))]
475 #[unsafe(method(runAction:completion:))]
476 #[unsafe(method_family = none)]
477 pub unsafe fn runAction_completion(
478 &self,
479 action: &SKAction,
480 block: &block2::DynBlock<dyn Fn()>,
481 );
482
483 #[cfg(feature = "SKAction")]
484 #[unsafe(method(runAction:withKey:))]
485 #[unsafe(method_family = none)]
486 pub unsafe fn runAction_withKey(&self, action: &SKAction, key: &NSString);
487
488 #[unsafe(method(hasActions))]
489 #[unsafe(method_family = none)]
490 pub unsafe fn hasActions(&self) -> bool;
491
492 #[cfg(feature = "SKAction")]
493 #[unsafe(method(actionForKey:))]
494 #[unsafe(method_family = none)]
495 pub unsafe fn actionForKey(&self, key: &NSString) -> Option<Retained<SKAction>>;
496
497 #[unsafe(method(removeActionForKey:))]
498 #[unsafe(method_family = none)]
499 pub unsafe fn removeActionForKey(&self, key: &NSString);
500
501 #[unsafe(method(removeAllActions))]
502 #[unsafe(method_family = none)]
503 pub unsafe fn removeAllActions(&self);
504
505 #[cfg(feature = "objc2-core-foundation")]
506 #[unsafe(method(containsPoint:))]
507 #[unsafe(method_family = none)]
508 pub unsafe fn containsPoint(&self, p: CGPoint) -> bool;
509
510 #[cfg(feature = "objc2-core-foundation")]
511 #[unsafe(method(nodeAtPoint:))]
516 #[unsafe(method_family = none)]
517 pub unsafe fn nodeAtPoint(&self, p: CGPoint) -> Retained<SKNode>;
518
519 #[cfg(feature = "objc2-core-foundation")]
520 #[unsafe(method(nodesAtPoint:))]
521 #[unsafe(method_family = none)]
522 pub unsafe fn nodesAtPoint(&self, p: CGPoint) -> Retained<NSArray<SKNode>>;
523
524 #[cfg(feature = "objc2-core-foundation")]
525 #[unsafe(method(convertPoint:fromNode:))]
526 #[unsafe(method_family = none)]
527 pub unsafe fn convertPoint_fromNode(&self, point: CGPoint, node: &SKNode) -> CGPoint;
528
529 #[cfg(feature = "objc2-core-foundation")]
530 #[unsafe(method(convertPoint:toNode:))]
531 #[unsafe(method_family = none)]
532 pub unsafe fn convertPoint_toNode(&self, point: CGPoint, node: &SKNode) -> CGPoint;
533
534 #[unsafe(method(intersectsNode:))]
535 #[unsafe(method_family = none)]
536 pub unsafe fn intersectsNode(&self, node: &SKNode) -> bool;
537
538 #[unsafe(method(isEqualToNode:))]
539 #[unsafe(method_family = none)]
540 pub unsafe fn isEqualToNode(&self, node: &SKNode) -> bool;
541 );
542}
543
544#[cfg(feature = "objc2-app-kit")]
546#[cfg(target_os = "macos")]
547impl SKNode {
548 extern_methods!(
549 #[unsafe(method(new))]
550 #[unsafe(method_family = new)]
551 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
552 );
553}
554
555mod private_NSEventSKNodeEvent {
556 pub trait Sealed {}
557}
558
559#[doc(alias = "SKNodeEvent")]
561pub unsafe trait NSEventSKNodeEvent:
562 ClassType + Sized + private_NSEventSKNodeEvent::Sealed
563{
564 extern_methods!(
565 #[cfg(all(feature = "objc2-app-kit", feature = "objc2-core-foundation"))]
566 #[cfg(target_os = "macos")]
567 #[unsafe(method(locationInNode:))]
568 #[unsafe(method_family = none)]
569 unsafe fn locationInNode(&self, node: &SKNode) -> CGPoint;
570 );
571}
572
573#[cfg(feature = "objc2-app-kit")]
574#[cfg(target_os = "macos")]
575impl private_NSEventSKNodeEvent::Sealed for NSEvent {}
576#[cfg(feature = "objc2-app-kit")]
577#[cfg(target_os = "macos")]
578unsafe impl NSEventSKNodeEvent for NSEvent {}