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        #[unsafe(method(setFontName:))]
199        #[unsafe(method_family = none)]
200        pub unsafe fn setFontName(&self, font_name: Option<&NSString>);
201
202        #[unsafe(method(text))]
203        #[unsafe(method_family = none)]
204        pub unsafe fn text(&self) -> Option<Retained<NSString>>;
205
206        /// Setter for [`text`][Self::text].
207        #[unsafe(method(setText:))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn setText(&self, text: Option<&NSString>);
210
211        #[unsafe(method(attributedText))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn attributedText(&self) -> Option<Retained<NSAttributedString>>;
214
215        /// Setter for [`attributedText`][Self::attributedText].
216        #[unsafe(method(setAttributedText:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn setAttributedText(&self, attributed_text: Option<&NSAttributedString>);
219
220        #[cfg(feature = "objc2-core-foundation")]
221        #[unsafe(method(fontSize))]
222        #[unsafe(method_family = none)]
223        pub unsafe fn fontSize(&self) -> CGFloat;
224
225        #[cfg(feature = "objc2-core-foundation")]
226        /// Setter for [`fontSize`][Self::fontSize].
227        #[unsafe(method(setFontSize:))]
228        #[unsafe(method_family = none)]
229        pub unsafe fn setFontSize(&self, font_size: CGFloat);
230
231        /// Base color that the text is rendered with (if supported by the font)
232        #[unsafe(method(fontColor))]
233        #[unsafe(method_family = none)]
234        pub unsafe fn fontColor(&self) -> Option<Retained<NSColor>>;
235
236        /// Setter for [`fontColor`][Self::fontColor].
237        #[unsafe(method(setFontColor:))]
238        #[unsafe(method_family = none)]
239        pub unsafe fn setFontColor(&self, font_color: Option<&NSColor>);
240
241        #[cfg(feature = "objc2-core-foundation")]
242        /// 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.
243        #[unsafe(method(colorBlendFactor))]
244        #[unsafe(method_family = none)]
245        pub unsafe fn colorBlendFactor(&self) -> CGFloat;
246
247        #[cfg(feature = "objc2-core-foundation")]
248        /// Setter for [`colorBlendFactor`][Self::colorBlendFactor].
249        #[unsafe(method(setColorBlendFactor:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn setColorBlendFactor(&self, color_blend_factor: CGFloat);
252
253        /// Color to be blended with the text based on the colorBlendFactor
254        #[unsafe(method(color))]
255        #[unsafe(method_family = none)]
256        pub unsafe fn color(&self) -> Option<Retained<NSColor>>;
257
258        /// Setter for [`color`][Self::color].
259        #[unsafe(method(setColor:))]
260        #[unsafe(method_family = none)]
261        pub unsafe fn setColor(&self, color: Option<&NSColor>);
262
263        /// Sets the blend mode to use when composing the sprite with the final framebuffer.
264        ///
265        /// See: SKNode.SKBlendMode
266        #[unsafe(method(blendMode))]
267        #[unsafe(method_family = none)]
268        pub unsafe fn blendMode(&self) -> SKBlendMode;
269
270        /// Setter for [`blendMode`][Self::blendMode].
271        #[unsafe(method(setBlendMode:))]
272        #[unsafe(method_family = none)]
273        pub unsafe fn setBlendMode(&self, blend_mode: SKBlendMode);
274    );
275}
276
277/// Methods declared on superclass `SKNode`.
278#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
279#[cfg(target_os = "macos")]
280impl SKLabelNode {
281    extern_methods!(
282        #[unsafe(method(init))]
283        #[unsafe(method_family = init)]
284        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
285
286        /// Support coding and decoding via NSKeyedArchiver.
287        #[unsafe(method(initWithCoder:))]
288        #[unsafe(method_family = init)]
289        pub unsafe fn initWithCoder(
290            this: Allocated<Self>,
291            a_decoder: &NSCoder,
292        ) -> Option<Retained<Self>>;
293
294        #[unsafe(method(node))]
295        #[unsafe(method_family = none)]
296        pub unsafe fn node(mtm: MainThreadMarker) -> Retained<Self>;
297
298        #[unsafe(method(nodeWithFileNamed:))]
299        #[unsafe(method_family = none)]
300        pub unsafe fn nodeWithFileNamed(
301            filename: &NSString,
302            mtm: MainThreadMarker,
303        ) -> Option<Retained<Self>>;
304
305        #[unsafe(method(nodeWithFileNamed:securelyWithClasses:andError:_))]
306        #[unsafe(method_family = none)]
307        pub unsafe fn nodeWithFileNamed_securelyWithClasses_andError(
308            filename: &NSString,
309            classes: &NSSet<AnyClass>,
310            mtm: MainThreadMarker,
311        ) -> Result<Retained<Self>, Retained<NSError>>;
312    );
313}
314
315/// Methods declared on superclass `NSObject`.
316#[cfg(all(feature = "SKNode", feature = "objc2-app-kit"))]
317#[cfg(target_os = "macos")]
318impl SKLabelNode {
319    extern_methods!(
320        #[unsafe(method(new))]
321        #[unsafe(method_family = new)]
322        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
323    );
324}