objc2-ui-kit 0.3.2

Bindings to the UIKit framework
Documentation
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;

use crate::*;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutpriority?language=objc)
// NS_TYPED_EXTENSIBLE_ENUM
pub type UILayoutPriority = c_float;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutpriorityrequired?language=objc)
pub static UILayoutPriorityRequired: UILayoutPriority = 1000 as _;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutprioritydefaulthigh?language=objc)
pub static UILayoutPriorityDefaultHigh: UILayoutPriority = 750 as _;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutprioritydragthatcanresizescene?language=objc)
pub static UILayoutPriorityDragThatCanResizeScene: UILayoutPriority = 510 as _;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutpriorityscenesizestayput?language=objc)
pub static UILayoutPrioritySceneSizeStayPut: UILayoutPriority = 500 as _;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutprioritydragthatcannotresizescene?language=objc)
pub static UILayoutPriorityDragThatCannotResizeScene: UILayoutPriority = 490 as _;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutprioritydefaultlow?language=objc)
pub static UILayoutPriorityDefaultLow: UILayoutPriority = 250 as _;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutpriorityfittingsizelevel?language=objc)
pub static UILayoutPriorityFittingSizeLevel: UILayoutPriority = 50 as _;

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nslayoutrelation?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSLayoutRelation(pub NSInteger);
impl NSLayoutRelation {
    #[doc(alias = "NSLayoutRelationLessThanOrEqual")]
    pub const LessThanOrEqual: Self = Self(-1);
    #[doc(alias = "NSLayoutRelationEqual")]
    pub const Equal: Self = Self(0);
    #[doc(alias = "NSLayoutRelationGreaterThanOrEqual")]
    pub const GreaterThanOrEqual: Self = Self(1);
}

unsafe impl Encode for NSLayoutRelation {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSLayoutRelation {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nslayoutattribute?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSLayoutAttribute(pub NSInteger);
impl NSLayoutAttribute {
    #[doc(alias = "NSLayoutAttributeLeft")]
    pub const Left: Self = Self(1);
    #[doc(alias = "NSLayoutAttributeRight")]
    pub const Right: Self = Self(2);
    #[doc(alias = "NSLayoutAttributeTop")]
    pub const Top: Self = Self(3);
    #[doc(alias = "NSLayoutAttributeBottom")]
    pub const Bottom: Self = Self(4);
    #[doc(alias = "NSLayoutAttributeLeading")]
    pub const Leading: Self = Self(5);
    #[doc(alias = "NSLayoutAttributeTrailing")]
    pub const Trailing: Self = Self(6);
    #[doc(alias = "NSLayoutAttributeWidth")]
    pub const Width: Self = Self(7);
    #[doc(alias = "NSLayoutAttributeHeight")]
    pub const Height: Self = Self(8);
    #[doc(alias = "NSLayoutAttributeCenterX")]
    pub const CenterX: Self = Self(9);
    #[doc(alias = "NSLayoutAttributeCenterY")]
    pub const CenterY: Self = Self(10);
    #[doc(alias = "NSLayoutAttributeLastBaseline")]
    pub const LastBaseline: Self = Self(11);
    #[doc(alias = "NSLayoutAttributeBaseline")]
    pub const Baseline: Self = Self(NSLayoutAttribute::LastBaseline.0);
    #[doc(alias = "NSLayoutAttributeFirstBaseline")]
    pub const FirstBaseline: Self = Self(12);
    #[doc(alias = "NSLayoutAttributeLeftMargin")]
    pub const LeftMargin: Self = Self(13);
    #[doc(alias = "NSLayoutAttributeRightMargin")]
    pub const RightMargin: Self = Self(14);
    #[doc(alias = "NSLayoutAttributeTopMargin")]
    pub const TopMargin: Self = Self(15);
    #[doc(alias = "NSLayoutAttributeBottomMargin")]
    pub const BottomMargin: Self = Self(16);
    #[doc(alias = "NSLayoutAttributeLeadingMargin")]
    pub const LeadingMargin: Self = Self(17);
    #[doc(alias = "NSLayoutAttributeTrailingMargin")]
    pub const TrailingMargin: Self = Self(18);
    #[doc(alias = "NSLayoutAttributeCenterXWithinMargins")]
    pub const CenterXWithinMargins: Self = Self(19);
    #[doc(alias = "NSLayoutAttributeCenterYWithinMargins")]
    pub const CenterYWithinMargins: Self = Self(20);
    #[doc(alias = "NSLayoutAttributeNotAnAttribute")]
    pub const NotAnAttribute: Self = Self(0);
}

unsafe impl Encode for NSLayoutAttribute {
    const ENCODING: Encoding = NSInteger::ENCODING;
}

unsafe impl RefEncode for NSLayoutAttribute {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

/// [Apple's documentation](https://developer.apple.com/documentation/uikit/nslayoutformatoptions?language=objc)
// NS_OPTIONS
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct NSLayoutFormatOptions(pub NSUInteger);
bitflags::bitflags! {
    impl NSLayoutFormatOptions: NSUInteger {
        #[doc(alias = "NSLayoutFormatAlignAllLeft")]
        const AlignAllLeft = 1<<NSLayoutAttribute::Left.0;
        #[doc(alias = "NSLayoutFormatAlignAllRight")]
        const AlignAllRight = 1<<NSLayoutAttribute::Right.0;
        #[doc(alias = "NSLayoutFormatAlignAllTop")]
        const AlignAllTop = 1<<NSLayoutAttribute::Top.0;
        #[doc(alias = "NSLayoutFormatAlignAllBottom")]
        const AlignAllBottom = 1<<NSLayoutAttribute::Bottom.0;
        #[doc(alias = "NSLayoutFormatAlignAllLeading")]
        const AlignAllLeading = 1<<NSLayoutAttribute::Leading.0;
        #[doc(alias = "NSLayoutFormatAlignAllTrailing")]
        const AlignAllTrailing = 1<<NSLayoutAttribute::Trailing.0;
        #[doc(alias = "NSLayoutFormatAlignAllCenterX")]
        const AlignAllCenterX = 1<<NSLayoutAttribute::CenterX.0;
        #[doc(alias = "NSLayoutFormatAlignAllCenterY")]
        const AlignAllCenterY = 1<<NSLayoutAttribute::CenterY.0;
        #[doc(alias = "NSLayoutFormatAlignAllLastBaseline")]
        const AlignAllLastBaseline = 1<<NSLayoutAttribute::LastBaseline.0;
        #[doc(alias = "NSLayoutFormatAlignAllFirstBaseline")]
        const AlignAllFirstBaseline = 1<<NSLayoutAttribute::FirstBaseline.0;
        #[doc(alias = "NSLayoutFormatAlignAllBaseline")]
        const AlignAllBaseline = NSLayoutFormatOptions::AlignAllLastBaseline.0;
        #[doc(alias = "NSLayoutFormatAlignmentMask")]
        const AlignmentMask = 0xFFFF;
        #[doc(alias = "NSLayoutFormatDirectionLeadingToTrailing")]
        const DirectionLeadingToTrailing = 0<<16;
        #[doc(alias = "NSLayoutFormatDirectionLeftToRight")]
        const DirectionLeftToRight = 1<<16;
        #[doc(alias = "NSLayoutFormatDirectionRightToLeft")]
        const DirectionRightToLeft = 2<<16;
        #[doc(alias = "NSLayoutFormatDirectionMask")]
        const DirectionMask = 0x3<<16;
        #[doc(alias = "NSLayoutFormatSpacingEdgeToEdge")]
        const SpacingEdgeToEdge = 0<<19;
        #[doc(alias = "NSLayoutFormatSpacingBaselineToBaseline")]
        const SpacingBaselineToBaseline = 1<<19;
        #[doc(alias = "NSLayoutFormatSpacingMask")]
        const SpacingMask = 0x1<<19;
    }
}

unsafe impl Encode for NSLayoutFormatOptions {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for NSLayoutFormatOptions {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/nslayoutconstraint?language=objc)
    #[unsafe(super(NSObject))]
    #[thread_kind = MainThreadOnly]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct NSLayoutConstraint;
);

extern_conformance!(
    unsafe impl NSObjectProtocol for NSLayoutConstraint {}
);

impl NSLayoutConstraint {
    extern_methods!(
        /// # Safety
        ///
        /// - `metrics` generic should be of the correct type.
        /// - `views` generic should be of the correct type.
        #[unsafe(method(constraintsWithVisualFormat:options:metrics:views:))]
        #[unsafe(method_family = none)]
        pub unsafe fn constraintsWithVisualFormat_options_metrics_views(
            format: &NSString,
            opts: NSLayoutFormatOptions,
            metrics: Option<&NSDictionary<NSString, AnyObject>>,
            views: &NSDictionary<NSString, AnyObject>,
            mtm: MainThreadMarker,
        ) -> Retained<NSArray<NSLayoutConstraint>>;

        #[cfg(feature = "objc2-core-foundation")]
        /// # Safety
        ///
        /// - `view1` should be of the correct type.
        /// - `view2` should be of the correct type.
        #[unsafe(method(constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:))]
        #[unsafe(method_family = none)]
        pub unsafe fn constraintWithItem_attribute_relatedBy_toItem_attribute_multiplier_constant(
            view1: &AnyObject,
            attr1: NSLayoutAttribute,
            relation: NSLayoutRelation,
            view2: Option<&AnyObject>,
            attr2: NSLayoutAttribute,
            multiplier: CGFloat,
            c: CGFloat,
            mtm: MainThreadMarker,
        ) -> Retained<Self>;

        #[unsafe(method(priority))]
        #[unsafe(method_family = none)]
        pub fn priority(&self) -> UILayoutPriority;

        /// Setter for [`priority`][Self::priority].
        #[unsafe(method(setPriority:))]
        #[unsafe(method_family = none)]
        pub fn setPriority(&self, priority: UILayoutPriority);

        #[unsafe(method(shouldBeArchived))]
        #[unsafe(method_family = none)]
        pub fn shouldBeArchived(&self) -> bool;

        /// Setter for [`shouldBeArchived`][Self::shouldBeArchived].
        #[unsafe(method(setShouldBeArchived:))]
        #[unsafe(method_family = none)]
        pub fn setShouldBeArchived(&self, should_be_archived: bool);

        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(firstItem))]
        #[unsafe(method_family = none)]
        pub unsafe fn firstItem(&self) -> Option<Retained<AnyObject>>;

        /// # Safety
        ///
        /// This is not retained internally, you must ensure the object is still alive.
        #[unsafe(method(secondItem))]
        #[unsafe(method_family = none)]
        pub unsafe fn secondItem(&self) -> Option<Retained<AnyObject>>;

        #[unsafe(method(firstAttribute))]
        #[unsafe(method_family = none)]
        pub fn firstAttribute(&self) -> NSLayoutAttribute;

        #[unsafe(method(secondAttribute))]
        #[unsafe(method_family = none)]
        pub fn secondAttribute(&self) -> NSLayoutAttribute;

        #[cfg(feature = "NSLayoutAnchor")]
        #[unsafe(method(firstAnchor))]
        #[unsafe(method_family = none)]
        pub fn firstAnchor(&self) -> Retained<NSLayoutAnchor>;

        #[cfg(feature = "NSLayoutAnchor")]
        #[unsafe(method(secondAnchor))]
        #[unsafe(method_family = none)]
        pub fn secondAnchor(&self) -> Option<Retained<NSLayoutAnchor>>;

        #[unsafe(method(relation))]
        #[unsafe(method_family = none)]
        pub fn relation(&self) -> NSLayoutRelation;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(multiplier))]
        #[unsafe(method_family = none)]
        pub fn multiplier(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(constant))]
        #[unsafe(method_family = none)]
        pub fn constant(&self) -> CGFloat;

        #[cfg(feature = "objc2-core-foundation")]
        /// Setter for [`constant`][Self::constant].
        #[unsafe(method(setConstant:))]
        #[unsafe(method_family = none)]
        pub fn setConstant(&self, constant: CGFloat);

        #[unsafe(method(isActive))]
        #[unsafe(method_family = none)]
        pub fn isActive(&self) -> bool;

        /// Setter for [`isActive`][Self::isActive].
        #[unsafe(method(setActive:))]
        #[unsafe(method_family = none)]
        pub fn setActive(&self, active: bool);

        #[unsafe(method(activateConstraints:))]
        #[unsafe(method_family = none)]
        pub fn activateConstraints(
            constraints: &NSArray<NSLayoutConstraint>,
            mtm: MainThreadMarker,
        );

        #[unsafe(method(deactivateConstraints:))]
        #[unsafe(method_family = none)]
        pub fn deactivateConstraints(
            constraints: &NSArray<NSLayoutConstraint>,
            mtm: MainThreadMarker,
        );
    );
}

/// Methods declared on superclass `NSObject`.
impl NSLayoutConstraint {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
    );
}

/// NSIdentifier.
impl NSLayoutConstraint {
    extern_methods!(
        #[unsafe(method(identifier))]
        #[unsafe(method_family = none)]
        pub fn identifier(&self) -> Option<Retained<NSString>>;

        /// Setter for [`identifier`][Self::identifier].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setIdentifier:))]
        #[unsafe(method_family = none)]
        pub fn setIdentifier(&self, identifier: Option<&NSString>);
    );
}

extern_protocol!(
    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uilayoutsupport?language=objc)
    pub unsafe trait UILayoutSupport: NSObjectProtocol + MainThreadOnly {
        #[cfg(feature = "objc2-core-foundation")]
        #[unsafe(method(length))]
        #[unsafe(method_family = none)]
        fn length(&self) -> CGFloat;

        #[cfg(feature = "NSLayoutAnchor")]
        #[unsafe(method(topAnchor))]
        #[unsafe(method_family = none)]
        fn topAnchor(&self) -> Retained<NSLayoutYAxisAnchor>;

        #[cfg(feature = "NSLayoutAnchor")]
        #[unsafe(method(bottomAnchor))]
        #[unsafe(method_family = none)]
        fn bottomAnchor(&self) -> Retained<NSLayoutYAxisAnchor>;

        #[cfg(feature = "NSLayoutAnchor")]
        #[unsafe(method(heightAnchor))]
        #[unsafe(method_family = none)]
        fn heightAnchor(&self) -> Retained<NSLayoutDimension>;
    }
);