objc2_ui_kit/generated/
UIImpactFeedbackGenerator.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/uiimpactfeedbackstyle?language=objc)
12// NS_ENUM
13#[repr(transparent)]
14#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
15pub struct UIImpactFeedbackStyle(pub NSInteger);
16impl UIImpactFeedbackStyle {
17    #[doc(alias = "UIImpactFeedbackStyleLight")]
18    pub const Light: Self = Self(0);
19    #[doc(alias = "UIImpactFeedbackStyleMedium")]
20    pub const Medium: Self = Self(1);
21    #[doc(alias = "UIImpactFeedbackStyleHeavy")]
22    pub const Heavy: Self = Self(2);
23    #[doc(alias = "UIImpactFeedbackStyleSoft")]
24    pub const Soft: Self = Self(3);
25    #[doc(alias = "UIImpactFeedbackStyleRigid")]
26    pub const Rigid: Self = Self(4);
27}
28
29unsafe impl Encode for UIImpactFeedbackStyle {
30    const ENCODING: Encoding = NSInteger::ENCODING;
31}
32
33unsafe impl RefEncode for UIImpactFeedbackStyle {
34    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
35}
36
37extern_class!(
38    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiimpactfeedbackgenerator?language=objc)
39    #[unsafe(super(UIFeedbackGenerator, NSObject))]
40    #[thread_kind = MainThreadOnly]
41    #[derive(Debug, PartialEq, Eq, Hash)]
42    #[cfg(feature = "UIFeedbackGenerator")]
43    pub struct UIImpactFeedbackGenerator;
44);
45
46#[cfg(feature = "UIFeedbackGenerator")]
47extern_conformance!(
48    unsafe impl NSObjectProtocol for UIImpactFeedbackGenerator {}
49);
50
51#[cfg(feature = "UIFeedbackGenerator")]
52impl UIImpactFeedbackGenerator {
53    extern_methods!(
54        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
55        /// set a style on the feedback generator and attach it to the provided view as an interaction.
56        #[unsafe(method(feedbackGeneratorWithStyle:forView:))]
57        #[unsafe(method_family = none)]
58        pub fn feedbackGeneratorWithStyle_forView(
59            style: UIImpactFeedbackStyle,
60            view: &UIView,
61        ) -> Retained<Self>;
62
63        /// call when your UI element impacts something else
64        #[unsafe(method(impactOccurred))]
65        #[unsafe(method_family = none)]
66        pub fn impactOccurred(&self);
67
68        #[cfg(feature = "objc2-core-foundation")]
69        #[unsafe(method(impactOccurredAtLocation:))]
70        #[unsafe(method_family = none)]
71        pub fn impactOccurredAtLocation(&self, location: CGPoint);
72
73        #[cfg(feature = "objc2-core-foundation")]
74        /// call when your UI element impacts something else with a specific intensity [0.0, 1.0]
75        #[unsafe(method(impactOccurredWithIntensity:))]
76        #[unsafe(method_family = none)]
77        pub fn impactOccurredWithIntensity(&self, intensity: CGFloat);
78
79        #[cfg(feature = "objc2-core-foundation")]
80        #[unsafe(method(impactOccurredWithIntensity:atLocation:))]
81        #[unsafe(method_family = none)]
82        pub fn impactOccurredWithIntensity_atLocation(&self, intensity: CGFloat, location: CGPoint);
83
84        #[deprecated]
85        #[unsafe(method(initWithStyle:))]
86        #[unsafe(method_family = init)]
87        pub fn initWithStyle(this: Allocated<Self>, style: UIImpactFeedbackStyle)
88            -> Retained<Self>;
89    );
90}
91
92/// Methods declared on superclass `UIFeedbackGenerator`.
93#[cfg(feature = "UIFeedbackGenerator")]
94impl UIImpactFeedbackGenerator {
95    extern_methods!(
96        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
97        /// initalize the generator with a view to attach it to the provided view as an interaction.
98        #[unsafe(method(feedbackGeneratorForView:))]
99        #[unsafe(method_family = none)]
100        pub fn feedbackGeneratorForView(view: &UIView) -> Retained<Self>;
101
102        #[deprecated]
103        #[unsafe(method(init))]
104        #[unsafe(method_family = init)]
105        pub fn init(this: Allocated<Self>) -> Retained<Self>;
106    );
107}
108
109/// Methods declared on superclass `NSObject`.
110#[cfg(feature = "UIFeedbackGenerator")]
111impl UIImpactFeedbackGenerator {
112    extern_methods!(
113        #[unsafe(method(new))]
114        #[unsafe(method_family = new)]
115        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
116    );
117}