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
43unsafe impl NSObjectProtocol for UIBandSelectionInteraction {}
44
45#[cfg(feature = "UIInteraction")]
46unsafe impl UIInteraction for UIBandSelectionInteraction {}
47
48impl UIBandSelectionInteraction {
49    extern_methods!(
50        /// Indicates whether the interaction is enabled. Defaults to YES.
51        #[unsafe(method(isEnabled))]
52        #[unsafe(method_family = none)]
53        pub unsafe fn isEnabled(&self) -> bool;
54
55        /// Setter for [`isEnabled`][Self::isEnabled].
56        #[unsafe(method(setEnabled:))]
57        #[unsafe(method_family = none)]
58        pub unsafe fn setEnabled(&self, enabled: bool);
59
60        /// The interaction's current state.
61        #[unsafe(method(state))]
62        #[unsafe(method_family = none)]
63        pub unsafe fn state(&self) -> UIBandSelectionInteractionState;
64
65        #[cfg(feature = "objc2-core-foundation")]
66        /// The current selection rect. Returns CGRectNull when the interaction is inactive.
67        #[unsafe(method(selectionRect))]
68        #[unsafe(method_family = none)]
69        pub unsafe fn selectionRect(&self) -> CGRect;
70
71        #[cfg(feature = "UICommand")]
72        /// Modifier keys held at the beginning of the interaction.
73        #[unsafe(method(initialModifierFlags))]
74        #[unsafe(method_family = none)]
75        pub unsafe fn initialModifierFlags(&self) -> UIKeyModifierFlags;
76
77        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
78        /// Called when the interaction is about to begin.
79        /// Return a boolean indicating whether the interaction should begin at the given location.
80        #[unsafe(method(shouldBeginHandler))]
81        #[unsafe(method_family = none)]
82        pub unsafe fn shouldBeginHandler(
83            &self,
84        ) -> *mut block2::Block<dyn Fn(NonNull<UIBandSelectionInteraction>, CGPoint) -> Bool>;
85
86        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
87        /// Setter for [`shouldBeginHandler`][Self::shouldBeginHandler].
88        #[unsafe(method(setShouldBeginHandler:))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn setShouldBeginHandler(
91            &self,
92            should_begin_handler: Option<
93                &block2::Block<dyn Fn(NonNull<UIBandSelectionInteraction>, CGPoint) -> Bool>,
94            >,
95        );
96
97        #[cfg(feature = "block2")]
98        /// Creates a UIBandSelectionInteraction with the given selection handler.
99        ///
100        ///
101        /// Parameter `selectionHandler`: Called when the interaction's state and/or selection rect change.
102        #[unsafe(method(initWithSelectionHandler:))]
103        #[unsafe(method_family = init)]
104        pub unsafe fn initWithSelectionHandler(
105            this: Allocated<Self>,
106            selection_handler: &block2::Block<dyn Fn(NonNull<UIBandSelectionInteraction>)>,
107        ) -> Retained<Self>;
108
109        #[unsafe(method(init))]
110        #[unsafe(method_family = init)]
111        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
112
113        #[unsafe(method(new))]
114        #[unsafe(method_family = new)]
115        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
116    );
117}