objc2_app_kit/
text.rs

1use objc2::encode::{Encode, Encoding, RefEncode};
2use objc2::ffi::NSInteger;
3
4use super::TARGET_ABI_USES_IOS_VALUES;
5
6// NS_ENUM
7#[repr(transparent)]
8#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
9pub struct NSTextAlignment(pub NSInteger);
10
11unsafe impl Encode for NSTextAlignment {
12    const ENCODING: Encoding = NSInteger::ENCODING;
13}
14
15unsafe impl RefEncode for NSTextAlignment {
16    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
17}
18
19#[allow(non_upper_case_globals)]
20#[allow(clippy::bool_to_int_with_if)]
21impl NSTextAlignment {
22    #[doc(alias = "NSTextAlignmentLeft")]
23    pub const Left: Self = Self(0);
24    #[doc(alias = "NSTextAlignmentRight")]
25    pub const Right: Self = Self(if TARGET_ABI_USES_IOS_VALUES { 2 } else { 1 });
26    #[doc(alias = "NSTextAlignmentCenter")]
27    pub const Center: Self = Self(if TARGET_ABI_USES_IOS_VALUES { 1 } else { 2 });
28    #[doc(alias = "NSTextAlignmentJustified")]
29    pub const Justified: Self = Self(3);
30    #[doc(alias = "NSTextAlignmentNatural")]
31    pub const Natural: Self = Self(4);
32}