objc2_sprite_kit/generated/
SKLabelNode.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::*;
11use objc2_foundation::*;
12
13use crate::*;
14
15/// [Apple's documentation](https://developer.apple.com/documentation/spritekit/sklabelverticalalignmentmode?language=objc)
16// NS_ENUM
17#[repr(transparent)]
18#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
19pub struct SKLabelVerticalAlignmentMode(pub NSInteger);
20impl SKLabelVerticalAlignmentMode {
21    #[doc(alias = "SKLabelVerticalAlignmentModeBaseline")]
22    pub const Baseline: Self = Self(0);
23    #[doc(alias = "SKLabelVerticalAlignmentModeCenter")]
24    pub const Center: Self = Self(1);
25    #[doc(alias = "SKLabelVerticalAlignmentModeTop")]
26    pub const Top: Self = Self(2);
27    #[doc(alias = "SKLabelVerticalAlignmentModeBottom")]
28    pub const Bottom: Self = Self(3);
29}
30
31unsafe impl Encode for SKLabelVerticalAlignmentMode {
32    const ENCODING: Encoding = NSInteger::ENCODING;
33}
34
35unsafe impl RefEncode for SKLabelVerticalAlignmentMode {
36    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39/// [Apple's documentation](https://developer.apple.com/documentation/spritekit/sklabelhorizontalalignmentmode?language=objc)
40// NS_ENUM
41#[repr(transparent)]
42#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
43pub struct SKLabelHorizontalAlignmentMode(pub NSInteger);
44impl SKLabelHorizontalAlignmentMode {
45    #[doc(alias = "SKLabelHorizontalAlignmentModeCenter")]
46    pub const Center: Self = Self(0);
47    #[doc(alias = "SKLabelHorizontalAlignmentModeLeft")]
48    pub const Left: Self = Self(1);
49    #[doc(alias = "SKLabelHorizontalAlignmentModeRight")]
50    pub const Right: Self = Self(2);
51}
52
53unsafe impl Encode for SKLabelHorizontalAlignmentMode {
54    const ENCODING: Encoding = NSInteger::ENCODING;
55}
56
57unsafe impl RefEncode for SKLabelHorizontalAlignmentMode {
58    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
59}
60
61extern_class!(
62    /// A node that displays a text label with a given font.
63    ///
64    /// See also [Apple's documentation](https://developer.apple.com/documentation/spritekit/sklabelnode?language=objc)
65    #[unsafe(super(SKNode, NSResponder, NSObject))]
66    #[derive(Debug, PartialEq, Eq, Hash)]
67    #[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
68    #[cfg(target_os = "macos")]
69    pub struct SKLabelNode;
70);
71
72#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
73#[cfg(target_os = "macos")]
74unsafe impl NSCoding for SKLabelNode {}
75
76#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
77#[cfg(target_os = "macos")]
78unsafe impl NSCopying for SKLabelNode {}
79
80#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
81#[cfg(target_os = "macos")]
82unsafe impl CopyingHelper for SKLabelNode {
83    type Result = Self;
84}
85
86#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
87#[cfg(target_os = "macos")]
88unsafe impl NSObjectProtocol for SKLabelNode {}
89
90#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
91#[cfg(target_os = "macos")]
92unsafe impl NSSecureCoding for SKLabelNode {}
93
94#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
95#[cfg(target_os = "macos")]
96impl SKLabelNode {
97    extern_methods!(
98        #[unsafe(method(labelNodeWithText:))]
99        #[unsafe(method_family = none)]
100        pub unsafe fn labelNodeWithText(
101            text: Option<&NSString>,
102            mtm: MainThreadMarker,
103        ) -> Retained<Self>;
104
105        #[unsafe(method(labelNodeWithAttributedText:))]
106        #[unsafe(method_family = none)]
107        pub unsafe fn labelNodeWithAttributedText(
108            attributed_text: Option<&NSAttributedString>,
109            mtm: MainThreadMarker,
110        ) -> Retained<Self>;
111
112        #[unsafe(method(labelNodeWithFontNamed:))]
113        #[unsafe(method_family = none)]
114        pub unsafe fn labelNodeWithFontNamed(
115            font_name: Option<&NSString>,
116            mtm: MainThreadMarker,
117        ) -> Retained<Self>;
118
119        #[unsafe(method(initWithFontNamed:))]
120        #[unsafe(method_family = init)]
121        pub unsafe fn initWithFontNamed(
122            this: Allocated<Self>,
123            font_name: Option<&NSString>,
124        ) -> Retained<Self>;
125
126        #[unsafe(method(verticalAlignmentMode))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn verticalAlignmentMode(&self) -> SKLabelVerticalAlignmentMode;
129
130        /// Setter for [`verticalAlignmentMode`][Self::verticalAlignmentMode].
131        #[unsafe(method(setVerticalAlignmentMode:))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn setVerticalAlignmentMode(
134            &self,
135            vertical_alignment_mode: SKLabelVerticalAlignmentMode,
136        );
137
138        #[unsafe(method(horizontalAlignmentMode))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn horizontalAlignmentMode(&self) -> SKLabelHorizontalAlignmentMode;
141
142        /// Setter for [`horizontalAlignmentMode`][Self::horizontalAlignmentMode].
143        #[unsafe(method(setHorizontalAlignmentMode:))]
144        #[unsafe(method_family = none)]
145        pub unsafe fn setHorizontalAlignmentMode(
146            &self,
147            horizontal_alignment_mode: SKLabelHorizontalAlignmentMode,
148        );
149
150        /// Determines the number of lines to draw. The default value is 1 (single line). A value of 0 means no limit.
151        /// If the height of the text reaches the # of lines the text will be truncated using the line break mode.
152        #[unsafe(method(numberOfLines))]
153        #[unsafe(method_family = none)]
154        pub unsafe fn numberOfLines(&self) -> NSInteger;
155
156        /// Setter for [`numberOfLines`][Self::numberOfLines].
157        #[unsafe(method(setNumberOfLines:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setNumberOfLines(&self, number_of_lines: NSInteger);
160
161        /// Determines the line break mode for multiple lines.
162        /// Default is NSLineBreakByTruncatingTail
163        #[unsafe(method(lineBreakMode))]
164        #[unsafe(method_family = none)]
165        pub unsafe fn lineBreakMode(&self) -> NSLineBreakMode;
166
167        /// Setter for [`lineBreakMode`][Self::lineBreakMode].
168        #[unsafe(method(setLineBreakMode:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn setLineBreakMode(&self, line_break_mode: NSLineBreakMode);
171
172        #[cfg(feature = "objc2-core-foundation")]
173        /// If nonzero, this is used when determining layout width for multiline labels.
174        /// Default is zero.
175        #[unsafe(method(preferredMaxLayoutWidth))]
176        #[unsafe(method_family = none)]
177        pub unsafe fn preferredMaxLayoutWidth(&self) -> CGFloat;
178
179        #[cfg(feature = "objc2-core-foundation")]
180        /// Setter for [`preferredMaxLayoutWidth`][Self::preferredMaxLayoutWidth].
181        #[unsafe(method(setPreferredMaxLayoutWidth:))]
182        #[unsafe(method_family = none)]
183        pub unsafe fn setPreferredMaxLayoutWidth(&self, preferred_max_layout_width: CGFloat);
184
185        #[unsafe(method(fontName))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn fontName(&self) -> Option<Retained<NSString>>;
188
189        /// Setter for [`fontName`][Self::fontName].
190        #[unsafe(method(setFontName:))]
191        #[unsafe(method_family = none)]
192        pub unsafe fn setFontName(&self, font_name: Option<&NSString>);
193
194        #[unsafe(method(text))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn text(&self) -> Option<Retained<NSString>>;
197
198        /// Setter for [`text`][Self::text].
199        #[unsafe(method(setText:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn setText(&self, text: Option<&NSString>);
202
203        #[unsafe(method(attributedText))]
204        #[unsafe(method_family = none)]
205        pub unsafe fn attributedText(&self) -> Option<Retained<NSAttributedString>>;
206
207        /// Setter for [`attributedText`][Self::attributedText].
208        #[unsafe(method(setAttributedText:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn setAttributedText(&self, attributed_text: Option<&NSAttributedString>);
211
212        #[cfg(feature = "objc2-core-foundation")]
213        #[unsafe(method(fontSize))]
214        #[unsafe(method_family = none)]
215        pub unsafe fn fontSize(&self) -> CGFloat;
216
217        #[cfg(feature = "objc2-core-foundation")]
218        /// Setter for [`fontSize`][Self::fontSize].
219        #[unsafe(method(setFontSize:))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn setFontSize(&self, font_size: CGFloat);
222
223        /// Base color that the text is rendered with (if supported by the font)
224        #[unsafe(method(fontColor))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn fontColor(&self) -> Option<Retained<NSColor>>;
227
228        /// Setter for [`fontColor`][Self::fontColor].
229        #[unsafe(method(setFontColor:))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn setFontColor(&self, font_color: Option<&NSColor>);
232
233        #[cfg(feature = "objc2-core-foundation")]
234        /// Controls the blending between the rendered text and a color. The valid interval of values is from 0.0 up to and including 1.0. A value above or below that interval is clamped to the minimum (0.0) if below or the maximum (1.0) if above.
235        #[unsafe(method(colorBlendFactor))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn colorBlendFactor(&self) -> CGFloat;
238
239        #[cfg(feature = "objc2-core-foundation")]
240        /// Setter for [`colorBlendFactor`][Self::colorBlendFactor].
241        #[unsafe(method(setColorBlendFactor:))]
242        #[unsafe(method_family = none)]
243        pub unsafe fn setColorBlendFactor(&self, color_blend_factor: CGFloat);
244
245        /// Color to be blended with the text based on the colorBlendFactor
246        #[unsafe(method(color))]
247        #[unsafe(method_family = none)]
248        pub unsafe fn color(&self) -> Option<Retained<NSColor>>;
249
250        /// Setter for [`color`][Self::color].
251        #[unsafe(method(setColor:))]
252        #[unsafe(method_family = none)]
253        pub unsafe fn setColor(&self, color: Option<&NSColor>);
254
255        /// Sets the blend mode to use when composing the sprite with the final framebuffer.
256        ///
257        /// See: SKNode.SKBlendMode
258        #[unsafe(method(blendMode))]
259        #[unsafe(method_family = none)]
260        pub unsafe fn blendMode(&self) -> SKBlendMode;
261
262        /// Setter for [`blendMode`][Self::blendMode].
263        #[unsafe(method(setBlendMode:))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn setBlendMode(&self, blend_mode: SKBlendMode);
266    );
267}
268
269/// Methods declared on superclass `SKNode`.
270#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
271#[cfg(target_os = "macos")]
272impl SKLabelNode {
273    extern_methods!(
274        #[unsafe(method(init))]
275        #[unsafe(method_family = init)]
276        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
277
278        /// Support coding and decoding via NSKeyedArchiver.
279        #[unsafe(method(initWithCoder:))]
280        #[unsafe(method_family = init)]
281        pub unsafe fn initWithCoder(
282            this: Allocated<Self>,
283            a_decoder: &NSCoder,
284        ) -> Option<Retained<Self>>;
285
286        #[unsafe(method(node))]
287        #[unsafe(method_family = none)]
288        pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
289
290        #[unsafe(method(nodeWithFileNamed:))]
291        #[unsafe(method_family = none)]
292        pub unsafe fn nodeWithFileNamed(
293            filename: &NSString,
294            mtm: MainThreadMarker,
295        ) -> Option<Retained<Self>>;
296
297        #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
298        #[unsafe(method_family = none)]
299        pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
300            filename: &NSString,
301            classes: &NSSet<AnyClass>,
302            mtm: MainThreadMarker,
303        ) -> Result<Retained<Self>, Retained<NSError>>;
304    );
305}
306
307/// Methods declared on superclass `NSObject`.
308#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
309#[cfg(target_os = "macos")]
310impl SKLabelNode {
311    extern_methods!(
312        #[unsafe(method(new))]
313        #[unsafe(method_family = new)]
314        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
315    );
316}