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:))]
124 #[unsafe(method_family = init)]
125 pub unsafe fn initWithCoder(
126 this: Allocated<Self>,
127 a_decoder: &NSCoder,
128 ) -> Option<Retained<Self>>;
129
130 #[unsafe(method(node))]
131 #[unsafe(method_family = none)]
132 pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
133
134 #[unsafe(method(nodeWithFileNamed:))]
135 #[unsafe(method_family = none)]
136 pub unsafe fn nodeWithFileNamed(
137 filename: &NSString,
138 mtm: MainThreadMarker,
139 ) -> Option<Retained<Self>>;
140
141 #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
145 #[unsafe(method_family = none)]
146 pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
147 filename: &NSString,
148 classes: &NSSet<AnyClass>,
149 mtm: MainThreadMarker,
150 ) -> Result<Retained<Self>, Retained<NSError>>;
151
152 #[cfg(feature = "objc2-core-foundation")]
153 #[unsafe(method(frame))]
154 #[unsafe(method_family = none)]
155 pub unsafe fn frame(&self) -> CGRect;
156
157 #[cfg(feature = "objc2-core-foundation")]
158 #[unsafe(method(calculateAccumulatedFrame))]
160 #[unsafe(method_family = none)]
161 pub unsafe fn calculateAccumulatedFrame(&self) -> CGRect;
162
163 #[cfg(feature = "objc2-core-foundation")]
164 #[unsafe(method(position))]
166 #[unsafe(method_family = none)]
167 pub unsafe fn position(&self) -> CGPoint;
168
169 #[cfg(feature = "objc2-core-foundation")]
170 #[unsafe(method(setPosition:))]
172 #[unsafe(method_family = none)]
173 pub unsafe fn setPosition(&self, position: CGPoint);
174
175 #[cfg(feature = "objc2-core-foundation")]
176 #[unsafe(method(zPosition))]
178 #[unsafe(method_family = none)]
179 pub unsafe fn zPosition(&self) -> CGFloat;
180
181 #[cfg(feature = "objc2-core-foundation")]
182 #[unsafe(method(setZPosition:))]
184 #[unsafe(method_family = none)]
185 pub unsafe fn setZPosition(&self, z_position: CGFloat);
186
187 #[cfg(feature = "objc2-core-foundation")]
188 #[unsafe(method(zRotation))]
190 #[unsafe(method_family = none)]
191 pub unsafe fn zRotation(&self) -> CGFloat;
192
193 #[cfg(feature = "objc2-core-foundation")]
194 #[unsafe(method(setZRotation:))]
196 #[unsafe(method_family = none)]
197 pub unsafe fn setZRotation(&self, z_rotation: CGFloat);
198
199 #[cfg(feature = "objc2-core-foundation")]
200 #[unsafe(method(xScale))]
202 #[unsafe(method_family = none)]
203 pub unsafe fn xScale(&self) -> CGFloat;
204
205 #[cfg(feature = "objc2-core-foundation")]
206 #[unsafe(method(setXScale:))]
208 #[unsafe(method_family = none)]
209 pub unsafe fn setXScale(&self, x_scale: CGFloat);
210
211 #[cfg(feature = "objc2-core-foundation")]
212 #[unsafe(method(yScale))]
214 #[unsafe(method_family = none)]
215 pub unsafe fn yScale(&self) -> CGFloat;
216
217 #[cfg(feature = "objc2-core-foundation")]
218 #[unsafe(method(setYScale:))]
220 #[unsafe(method_family = none)]
221 pub unsafe fn setYScale(&self, y_scale: CGFloat);
222
223 #[cfg(feature = "objc2-core-foundation")]
224 #[unsafe(method(speed))]
226 #[unsafe(method_family = none)]
227 pub unsafe fn speed(&self) -> CGFloat;
228
229 #[cfg(feature = "objc2-core-foundation")]
230 #[unsafe(method(setSpeed:))]
232 #[unsafe(method_family = none)]
233 pub unsafe fn setSpeed(&self, speed: CGFloat);
234
235 #[cfg(feature = "objc2-core-foundation")]
236 #[unsafe(method(alpha))]
238 #[unsafe(method_family = none)]
239 pub unsafe fn alpha(&self) -> CGFloat;
240
241 #[cfg(feature = "objc2-core-foundation")]
242 #[unsafe(method(setAlpha:))]
244 #[unsafe(method_family = none)]
245 pub unsafe fn setAlpha(&self, alpha: CGFloat);
246
247 #[unsafe(method(isPaused))]
249 #[unsafe(method_family = none)]
250 pub unsafe fn isPaused(&self) -> bool;
251
252 #[unsafe(method(setPaused:))]
254 #[unsafe(method_family = none)]
255 pub unsafe fn setPaused(&self, paused: bool);
256
257 #[unsafe(method(isHidden))]
259 #[unsafe(method_family = none)]
260 pub unsafe fn isHidden(&self) -> bool;
261
262 #[unsafe(method(setHidden:))]
264 #[unsafe(method_family = none)]
265 pub unsafe fn setHidden(&self, hidden: bool);
266
267 #[unsafe(method(isUserInteractionEnabled))]
269 #[unsafe(method_family = none)]
270 pub unsafe fn isUserInteractionEnabled(&self) -> bool;
271
272 #[unsafe(method(setUserInteractionEnabled:))]
274 #[unsafe(method_family = none)]
275 pub unsafe fn setUserInteractionEnabled(&self, user_interaction_enabled: bool);
276
277 #[unsafe(method(focusBehavior))]
279 #[unsafe(method_family = none)]
280 pub unsafe fn focusBehavior(&self) -> SKNodeFocusBehavior;
281
282 #[unsafe(method(setFocusBehavior:))]
284 #[unsafe(method_family = none)]
285 pub unsafe fn setFocusBehavior(&self, focus_behavior: SKNodeFocusBehavior);
286
287 #[unsafe(method(parent))]
291 #[unsafe(method_family = none)]
292 pub unsafe fn parent(&self) -> Option<Retained<SKNode>>;
293
294 #[unsafe(method(children))]
296 #[unsafe(method_family = none)]
297 pub unsafe fn children(&self) -> Retained<NSArray<SKNode>>;
298
299 #[unsafe(method(name))]
303 #[unsafe(method_family = none)]
304 pub unsafe fn name(&self) -> Option<Retained<NSString>>;
305
306 #[unsafe(method(setName:))]
310 #[unsafe(method_family = none)]
311 pub unsafe fn setName(&self, name: Option<&NSString>);
312
313 #[cfg(all(feature = "SKEffectNode", feature = "SKScene"))]
314 #[unsafe(method(scene))]
316 #[unsafe(method_family = none)]
317 pub unsafe fn scene(&self) -> Option<Retained<SKScene>>;
318
319 #[cfg(feature = "SKPhysicsBody")]
320 #[unsafe(method(physicsBody))]
322 #[unsafe(method_family = none)]
323 pub unsafe fn physicsBody(&self) -> Option<Retained<SKPhysicsBody>>;
324
325 #[cfg(feature = "SKPhysicsBody")]
326 #[unsafe(method(setPhysicsBody:))]
328 #[unsafe(method_family = none)]
329 pub unsafe fn setPhysicsBody(&self, physics_body: Option<&SKPhysicsBody>);
330
331 #[unsafe(method(userData))]
337 #[unsafe(method_family = none)]
338 pub unsafe fn userData(&self) -> Option<Retained<NSMutableDictionary>>;
339
340 #[unsafe(method(setUserData:))]
346 #[unsafe(method_family = none)]
347 pub unsafe fn setUserData(&self, user_data: Option<&NSMutableDictionary>);
348
349 #[cfg(feature = "SKReachConstraints")]
350 #[unsafe(method(reachConstraints))]
352 #[unsafe(method_family = none)]
353 pub unsafe fn reachConstraints(&self) -> Option<Retained<SKReachConstraints>>;
354
355 #[cfg(feature = "SKReachConstraints")]
356 #[unsafe(method(setReachConstraints:))]
360 #[unsafe(method_family = none)]
361 pub unsafe fn setReachConstraints(&self, reach_constraints: Option<&SKReachConstraints>);
362
363 #[cfg(feature = "SKConstraint")]
364 #[unsafe(method(constraints))]
368 #[unsafe(method_family = none)]
369 pub unsafe fn constraints(&self) -> Option<Retained<NSArray<SKConstraint>>>;
370
371 #[cfg(feature = "SKConstraint")]
372 #[unsafe(method(setConstraints:))]
376 #[unsafe(method_family = none)]
377 pub unsafe fn setConstraints(&self, constraints: Option<&NSArray<SKConstraint>>);
378
379 #[cfg(feature = "SKAttribute")]
380 #[deprecated]
384 #[unsafe(method(attributeValues))]
385 #[unsafe(method_family = none)]
386 pub unsafe fn attributeValues(&self) -> Retained<NSDictionary<NSString, SKAttributeValue>>;
387
388 #[cfg(feature = "SKAttribute")]
389 #[deprecated]
393 #[unsafe(method(setAttributeValues:))]
394 #[unsafe(method_family = none)]
395 pub unsafe fn setAttributeValues(
396 &self,
397 attribute_values: &NSDictionary<NSString, SKAttributeValue>,
398 );
399
400 #[cfg(feature = "SKAttribute")]
401 #[deprecated]
402 #[unsafe(method(valueForAttributeNamed:))]
403 #[unsafe(method_family = none)]
404 pub unsafe fn valueForAttributeNamed(
405 &self,
406 key: &NSString,
407 ) -> Option<Retained<SKAttributeValue>>;
408
409 #[cfg(feature = "SKAttribute")]
410 #[deprecated]
411 #[unsafe(method(setValue:forAttributeNamed:))]
412 #[unsafe(method_family = none)]
413 pub unsafe fn setValue_forAttributeNamed(&self, value: &SKAttributeValue, key: &NSString);
414
415 #[cfg(feature = "objc2-core-foundation")]
416 #[unsafe(method(setScale:))]
423 #[unsafe(method_family = none)]
424 pub unsafe fn setScale(&self, scale: CGFloat);
425
426 #[unsafe(method(addChild:))]
433 #[unsafe(method_family = none)]
434 pub unsafe fn addChild(&self, node: &SKNode);
435
436 #[unsafe(method(insertChild:atIndex:))]
437 #[unsafe(method_family = none)]
438 pub unsafe fn insertChild_atIndex(&self, node: &SKNode, index: NSInteger);
439
440 #[unsafe(method(removeChildrenInArray:))]
441 #[unsafe(method_family = none)]
442 pub unsafe fn removeChildrenInArray(&self, nodes: &NSArray<SKNode>);
443
444 #[unsafe(method(removeAllChildren))]
445 #[unsafe(method_family = none)]
446 pub unsafe fn removeAllChildren(&self);
447
448 #[unsafe(method(removeFromParent))]
449 #[unsafe(method_family = none)]
450 pub unsafe fn removeFromParent(&self);
451
452 #[unsafe(method(moveToParent:))]
453 #[unsafe(method_family = none)]
454 pub unsafe fn moveToParent(&self, parent: &SKNode);
455
456 #[unsafe(method(childNodeWithName:))]
457 #[unsafe(method_family = none)]
458 pub unsafe fn childNodeWithName(&self, name: &NSString) -> Option<Retained<SKNode>>;
459
460 #[cfg(feature = "block2")]
461 #[unsafe(method(enumerateChildNodesWithName:usingBlock:))]
462 #[unsafe(method_family = none)]
463 pub unsafe fn enumerateChildNodesWithName_usingBlock(
464 &self,
465 name: &NSString,
466 block: &block2::DynBlock<dyn Fn(NonNull<SKNode>, NonNull<Bool>)>,
467 );
468
469 #[unsafe(method(objectForKeyedSubscript:))]
485 #[unsafe(method_family = none)]
486 pub unsafe fn objectForKeyedSubscript(&self, name: &NSString) -> Retained<NSArray<SKNode>>;
487
488 #[unsafe(method(inParentHierarchy:))]
489 #[unsafe(method_family = none)]
490 pub unsafe fn inParentHierarchy(&self, parent: &SKNode) -> bool;
491
492 #[cfg(feature = "SKAction")]
493 #[unsafe(method(runAction:))]
494 #[unsafe(method_family = none)]
495 pub unsafe fn runAction(&self, action: &SKAction);
496
497 #[cfg(all(feature = "SKAction", feature = "block2"))]
498 #[unsafe(method(runAction:completion:))]
499 #[unsafe(method_family = none)]
500 pub unsafe fn runAction_completion(
501 &self,
502 action: &SKAction,
503 block: &block2::DynBlock<dyn Fn()>,
504 );
505
506 #[cfg(feature = "SKAction")]
507 #[unsafe(method(runAction:withKey:))]
508 #[unsafe(method_family = none)]
509 pub unsafe fn runAction_withKey(&self, action: &SKAction, key: &NSString);
510
511 #[unsafe(method(hasActions))]
512 #[unsafe(method_family = none)]
513 pub unsafe fn hasActions(&self) -> bool;
514
515 #[cfg(feature = "SKAction")]
516 #[unsafe(method(actionForKey:))]
517 #[unsafe(method_family = none)]
518 pub unsafe fn actionForKey(&self, key: &NSString) -> Option<Retained<SKAction>>;
519
520 #[unsafe(method(removeActionForKey:))]
521 #[unsafe(method_family = none)]
522 pub unsafe fn removeActionForKey(&self, key: &NSString);
523
524 #[unsafe(method(removeAllActions))]
525 #[unsafe(method_family = none)]
526 pub unsafe fn removeAllActions(&self);
527
528 #[cfg(feature = "objc2-core-foundation")]
529 #[unsafe(method(containsPoint:))]
530 #[unsafe(method_family = none)]
531 pub unsafe fn containsPoint(&self, p: CGPoint) -> bool;
532
533 #[cfg(feature = "objc2-core-foundation")]
534 #[unsafe(method(nodeAtPoint:))]
539 #[unsafe(method_family = none)]
540 pub unsafe fn nodeAtPoint(&self, p: CGPoint) -> Retained<SKNode>;
541
542 #[cfg(feature = "objc2-core-foundation")]
543 #[unsafe(method(nodesAtPoint:))]
544 #[unsafe(method_family = none)]
545 pub unsafe fn nodesAtPoint(&self, p: CGPoint) -> Retained<NSArray<SKNode>>;
546
547 #[cfg(feature = "objc2-core-foundation")]
548 #[unsafe(method(convertPoint:fromNode:))]
549 #[unsafe(method_family = none)]
550 pub unsafe fn convertPoint_fromNode(&self, point: CGPoint, node: &SKNode) -> CGPoint;
551
552 #[cfg(feature = "objc2-core-foundation")]
553 #[unsafe(method(convertPoint:toNode:))]
554 #[unsafe(method_family = none)]
555 pub unsafe fn convertPoint_toNode(&self, point: CGPoint, node: &SKNode) -> CGPoint;
556
557 #[unsafe(method(intersectsNode:))]
558 #[unsafe(method_family = none)]
559 pub unsafe fn intersectsNode(&self, node: &SKNode) -> bool;
560
561 #[unsafe(method(isEqualToNode:))]
562 #[unsafe(method_family = none)]
563 pub unsafe fn isEqualToNode(&self, node: &SKNode) -> bool;
564 );
565}
566
567#[cfg(feature = "objc2-app-kit")]
569#[cfg(target_os = "macos")]
570impl SKNode {
571 extern_methods!(
572 #[unsafe(method(new))]
573 #[unsafe(method_family = new)]
574 pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
575 );
576}
577
578mod private_NSEventSKNodeEvent {
579 pub trait Sealed {}
580}
581
582#[doc(alias = "SKNodeEvent")]
584pub unsafe trait NSEventSKNodeEvent:
585 ClassType + Sized + private_NSEventSKNodeEvent::Sealed
586{
587 extern_methods!(
588 #[cfg(all(feature = "objc2-app-kit", feature = "objc2-core-foundation"))]
589 #[cfg(target_os = "macos")]
590 #[unsafe(method(locationInNode:))]
591 #[unsafe(method_family = none)]
592 unsafe fn locationInNode(&self, node: &SKNode) -> CGPoint;
593 );
594}
595
596#[cfg(feature = "objc2-app-kit")]
597#[cfg(target_os = "macos")]
598impl private_NSEventSKNodeEvent::Sealed for NSEvent {}
599#[cfg(feature = "objc2-app-kit")]
600#[cfg(target_os = "macos")]
601unsafe impl NSEventSKNodeEvent for NSEvent {}