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")]
74extern_conformance!(
75    unsafe impl NSCoding for SKLabelNode {}
76);
77
78#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
79#[cfg(target_os = "macos")]
80extern_conformance!(
81    unsafe impl NSCopying for SKLabelNode {}
82);
83
84#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
85#[cfg(target_os = "macos")]
86unsafe impl CopyingHelper for SKLabelNode {
87    type Result = Self;
88}
89
90#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
91#[cfg(target_os = "macos")]
92extern_conformance!(
93    unsafe impl NSObjectProtocol for SKLabelNode {}
94);
95
96#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
97#[cfg(target_os = "macos")]
98extern_conformance!(
99    unsafe impl NSSecureCoding for SKLabelNode {}
100);
101
102#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
103#[cfg(target_os = "macos")]
104impl SKLabelNode {
105    extern_methods!(
106        #[unsafe(method(labelNodeWithText:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn labelNodeWithText(
109            text: Option<&NSString>,
110            mtm: MainThreadMarker,
111        ) -> Retained<Self>;
112
113        #[unsafe(method(labelNodeWithAttributedText:))]
114        #[unsafe(method_family = none)]
115        pub unsafe fn labelNodeWithAttributedText(
116            attributed_text: Option<&NSAttributedString>,
117            mtm: MainThreadMarker,
118        ) -> Retained<Self>;
119
120        #[unsafe(method(labelNodeWithFontNamed:))]
121        #[unsafe(method_family = none)]
122        pub unsafe fn labelNodeWithFontNamed(
123            font_name: Option<&NSString>,
124            mtm: MainThreadMarker,
125        ) -> Retained<Self>;
126
127        #[unsafe(method(initWithFontNamed:))]
128        #[unsafe(method_family = init)]
129        pub unsafe fn initWithFontNamed(
130            this: Allocated<Self>,
131            font_name: Option<&NSString>,
132        ) -> Retained<Self>;
133
134        #[unsafe(method(verticalAlignmentMode))]
135        #[unsafe(method_family = none)]
136        pub unsafe fn verticalAlignmentMode(&self) -> SKLabelVerticalAlignmentMode;
137
138        /// Setter for [`verticalAlignmentMode`][Self::verticalAlignmentMode].
139        #[unsafe(method(setVerticalAlignmentMode:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn setVerticalAlignmentMode(
142            &self,
143            vertical_alignment_mode: SKLabelVerticalAlignmentMode,
144        );
145
146        #[unsafe(method(horizontalAlignmentMode))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn horizontalAlignmentMode(&self) -> SKLabelHorizontalAlignmentMode;
149
150        /// Setter for [`horizontalAlignmentMode`][Self::horizontalAlignmentMode].
151        #[unsafe(method(setHorizontalAlignmentMode:))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn setHorizontalAlignmentMode(
154            &self,
155            horizontal_alignment_mode: SKLabelHorizontalAlignmentMode,
156        );
157
158        /// Determines the number of lines to draw. The default value is 1 (single line). A value of 0 means no limit.
159        /// If the height of the text reaches the # of lines the text will be truncated using the line break mode.
160        #[unsafe(method(numberOfLines))]
161        #[unsafe(method_family = none)]
162        pub unsafe fn numberOfLines(&self) -> NSInteger;
163
164        /// Setter for [`numberOfLines`][Self::numberOfLines].
165        #[unsafe(method(setNumberOfLines:))]
166        #[unsafe(method_family = none)]
167        pub unsafe fn setNumberOfLines(&self, number_of_lines: NSInteger);
168
169        /// Determines the line break mode for multiple lines.
170        /// Default is NSLineBreakByTruncatingTail
171        #[unsafe(method(lineBreakMode))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn lineBreakMode(&self) -> NSLineBreakMode;
174
175        /// Setter for [`lineBreakMode`][Self::lineBreakMode].
176        #[unsafe(method(setLineBreakMode:))]
177        #[unsafe(method_family = none)]
178        pub unsafe fn setLineBreakMode(&self, line_break_mode: NSLineBreakMode);
179
180        #[cfg(feature = "objc2-core-foundation")]
181        /// If nonzero, this is used when determining layout width for multiline labels.
182        /// Default is zero.
183        #[unsafe(method(preferredMaxLayoutWidth))]
184        #[unsafe(method_family = none)]
185        pub unsafe fn preferredMaxLayoutWidth(&self) -> CGFloat;
186
187        #[cfg(feature = "objc2-core-foundation")]
188        /// Setter for [`preferredMaxLayoutWidth`][Self::preferredMaxLayoutWidth].
189        #[unsafe(method(setPreferredMaxLayoutWidth:))]
190        #[unsafe(method_family = none)]
191        pub unsafe fn setPreferredMaxLayoutWidth(&self, preferred_max_layout_width: CGFloat);
192
193        #[unsafe(method(fontName))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn fontName(&self) -> Option<Retained<NSString>>;
196
197        /// Setter for [`fontName`][Self::fontName].
198        ///
199        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
200        #[unsafe(method(setFontName:))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn setFontName(&self, font_name: Option<&NSString>);
203
204        #[unsafe(method(text))]
205        #[unsafe(method_family = none)]
206        pub unsafe fn text(&self) -> Option<Retained<NSString>>;
207
208        /// Setter for [`text`][Self::text].
209        ///
210        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
211        #[unsafe(method(setText:))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn setText(&self, text: Option<&NSString>);
214
215        #[unsafe(method(attributedText))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn attributedText(&self) -> Option<Retained<NSAttributedString>>;
218
219        /// Setter for [`attributedText`][Self::attributedText].
220        ///
221        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
222        #[unsafe(method(setAttributedText:))]
223        #[unsafe(method_family = none)]
224        pub unsafe fn setAttributedText(&self, attributed_text: Option<&NSAttributedString>);
225
226        #[cfg(feature = "objc2-core-foundation")]
227        #[unsafe(method(fontSize))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn fontSize(&self) -> CGFloat;
230
231        #[cfg(feature = "objc2-core-foundation")]
232        /// Setter for [`fontSize`][Self::fontSize].
233        #[unsafe(method(setFontSize:))]
234        #[unsafe(method_family = none)]
235        pub unsafe fn setFontSize(&self, font_size: CGFloat);
236
237        /// Base color that the text is rendered with (if supported by the font)
238        #[unsafe(method(fontColor))]
239        #[unsafe(method_family = none)]
240        pub unsafe fn fontColor(&self) -> Option<Retained<NSColor>>;
241
242        /// Setter for [`fontColor`][Self::fontColor].
243        #[unsafe(method(setFontColor:))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn setFontColor(&self, font_color: Option<&NSColor>);
246
247        #[cfg(feature = "objc2-core-foundation")]
248        /// 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.
249        #[unsafe(method(colorBlendFactor))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn colorBlendFactor(&self) -> CGFloat;
252
253        #[cfg(feature = "objc2-core-foundation")]
254        /// Setter for [`colorBlendFactor`][Self::colorBlendFactor].
255        #[unsafe(method(setColorBlendFactor:))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn setColorBlendFactor(&self, color_blend_factor: CGFloat);
258
259        /// Color to be blended with the text based on the colorBlendFactor
260        #[unsafe(method(color))]
261        #[unsafe(method_family = none)]
262        pub unsafe fn color(&self) -> Option<Retained<NSColor>>;
263
264        /// Setter for [`color`][Self::color].
265        #[unsafe(method(setColor:))]
266        #[unsafe(method_family = none)]
267        pub unsafe fn setColor(&self, color: Option<&NSColor>);
268
269        /// Sets the blend mode to use when composing the sprite with the final framebuffer.
270        ///
271        /// See: SKNode.SKBlendMode
272        #[unsafe(method(blendMode))]
273        #[unsafe(method_family = none)]
274        pub unsafe fn blendMode(&self) -> SKBlendMode;
275
276        /// Setter for [`blendMode`][Self::blendMode].
277        #[unsafe(method(setBlendMode:))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn setBlendMode(&self, blend_mode: SKBlendMode);
280    );
281}
282
283/// Methods declared on superclass `SKNode`.
284#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
285#[cfg(target_os = "macos")]
286impl SKLabelNode {
287    extern_methods!(
288        #[unsafe(method(init))]
289        #[unsafe(method_family = init)]
290        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
291
292        /// Support coding and decoding via NSKeyedArchiver.
293        ///
294        /// # Safety
295        ///
296        /// `a_decoder` possibly has further requirements.
297        #[unsafe(method(initWithCoder:))]
298        #[unsafe(method_family = init)]
299        pub unsafe fn initWithCoder(
300            this: Allocated<Self>,
301            a_decoder: &NSCoder,
302        ) -> Option<Retained<Self>>;
303
304        #[unsafe(method(node))]
305        #[unsafe(method_family = none)]
306        pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
307
308        #[unsafe(method(nodeWithFileNamed:))]
309        #[unsafe(method_family = none)]
310        pub unsafe fn nodeWithFileNamed(
311            filename: &NSString,
312            mtm: MainThreadMarker,
313        ) -> Option<Retained<Self>>;
314
315        /// # Safety
316        ///
317        /// `classes` generic probably has further requirements.
318        #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
319        #[unsafe(method_family = none)]
320        pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
321            filename: &NSString,
322            classes: &NSSet<AnyClass>,
323            mtm: MainThreadMarker,
324        ) -> Result<Retained<Self>, Retained<NSError>>;
325    );
326}
327
328/// Methods declared on superclass `NSObject`.
329#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
330#[cfg(target_os = "macos")]
331impl SKLabelNode {
332    extern_methods!(
333        #[unsafe(method(new))]
334        #[unsafe(method_family = new)]
335        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
336    );
337}