objc2_ui_kit/generated/
UIBandSelectionInteraction.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-core-foundation")]
7use objc2_core_foundation::*;
8
9use crate::*;
10
11/// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibandselectioninteractionstate?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct UIBandSelectionInteractionState(pub NSInteger);
16impl UIBandSelectionInteractionState {
17    #[doc(alias = "UIBandSelectionInteractionStatePossible")]
18    pub const Possible: Self = Self(0);
19    #[doc(alias = "UIBandSelectionInteractionStateBegan")]
20    pub const Began: Self = Self(1);
21    #[doc(alias = "UIBandSelectionInteractionStateSelecting")]
22    pub const Selecting: Self = Self(2);
23    #[doc(alias = "UIBandSelectionInteractionStateEnded")]
24    pub const Ended: Self = Self(3);
25}
26
27unsafe impl Encode for UIBandSelectionInteractionState {
28    const ENCODING: Encoding = NSInteger::ENCODING;
29}
30
31unsafe impl RefEncode for UIBandSelectionInteractionState {
32    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
33}
34
35extern_class!(
36    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uibandselectioninteraction?language=objc)
37    #[unsafe(super(NSObject))]
38    #[thread_kind = MainThreadOnly]
39    #[derive(Debug, PartialEq, Eq, Hash)]
40    pub struct UIBandSelectionInteraction;
41);
42
43extern_conformance!(
44    unsafe impl NSObjectProtocol for UIBandSelectionInteraction {}
45);
46
47#[cfg(feature = "UIInteraction")]
48extern_conformance!(
49    unsafe impl UIInteraction for UIBandSelectionInteraction {}
50);
51
52impl UIBandSelectionInteraction {
53    extern_methods!(
54        /// Indicates whether the interaction is enabled. Defaults to YES.
55        #[unsafe(method(isEnabled))]
56        #[unsafe(method_family = none)]
57        pub fn isEnabled(&self) -> bool;
58
59        /// Setter for [`isEnabled`][Self::isEnabled].
60        #[unsafe(method(setEnabled:))]
61        #[unsafe(method_family = none)]
62        pub fn setEnabled(&self, enabled: bool);
63
64        /// The interaction's current state.
65        #[unsafe(method(state))]
66        #[unsafe(method_family = none)]
67        pub fn state(&self) -> UIBandSelectionInteractionState;
68
69        #[cfg(feature = "objc2-core-foundation")]
70        /// The current selection rect. Returns CGRectNull when the interaction is inactive.
71        #[unsafe(method(selectionRect))]
72        #[unsafe(method_family = none)]
73        pub fn selectionRect(&self) -> CGRect;
74
75        #[cfg(feature = "UICommand")]
76        /// Modifier keys held at the beginning of the interaction.
77        #[unsafe(method(initialModifierFlags))]
78        #[unsafe(method_family = none)]
79        pub fn initialModifierFlags(&self) -> UIKeyModifierFlags;
80
81        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
82        /// Called when the interaction is about to begin.
83        /// Return a boolean indicating whether the interaction should begin at the given location.
84        ///
85        /// # Safety
86        ///
87        /// The returned block's argument 1 must be a valid pointer.
88        #[unsafe(method(shouldBeginHandler))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn shouldBeginHandler(
91            &self,
92        ) -> *mut block2::DynBlock<dyn Fn(NonNull<UIBandSelectionInteraction>, CGPoint) -> Bool>;
93
94        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
95        /// Setter for [`shouldBeginHandler`][Self::shouldBeginHandler].
96        ///
97        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
98        #[unsafe(method(setShouldBeginHandler:))]
99        #[unsafe(method_family = none)]
100        pub fn setShouldBeginHandler(
101            &self,
102            should_begin_handler: Option<
103                &block2::DynBlock<dyn Fn(NonNull<UIBandSelectionInteraction>, CGPoint) -> Bool>,
104            >,
105        );
106
107        #[cfg(feature = "block2")]
108        /// Creates a UIBandSelectionInteraction with the given selection handler.
109        ///
110        ///
111        /// Parameter `selectionHandler`: Called when the interaction's state and/or selection rect change.
112        #[unsafe(method(initWithSelectionHandler:))]
113        #[unsafe(method_family = init)]
114        pub fn initWithSelectionHandler(
115            this: Allocated<Self>,
116            selection_handler: &block2::DynBlock<dyn Fn(NonNull<UIBandSelectionInteraction>)>,
117        ) -> Retained<Self>;
118
119        #[unsafe(method(init))]
120        #[unsafe(method_family = init)]
121        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
122
123        #[unsafe(method(new))]
124        #[unsafe(method_family = new)]
125        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
126    );
127}