objc2_ui_kit/generated/
UIDragItem.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::*;
6use objc2_foundation::*;
7
8use crate::*;
9
10extern_class!(
11    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uidragitem?language=objc)
12    #[unsafe(super(NSObject))]
13    #[thread_kind = MainThreadOnly]
14    #[derive(Debug, PartialEq, Eq, Hash)]
15    pub struct UIDragItem;
16);
17
18extern_conformance!(
19    unsafe impl NSObjectProtocol for UIDragItem {}
20);
21
22impl UIDragItem {
23    extern_methods!(
24        #[unsafe(method(initWithItemProvider:))]
25        #[unsafe(method_family = init)]
26        pub fn initWithItemProvider(
27            this: Allocated<Self>,
28            item_provider: &NSItemProvider,
29        ) -> Retained<Self>;
30
31        #[unsafe(method(init))]
32        #[unsafe(method_family = init)]
33        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
34
35        #[unsafe(method(new))]
36        #[unsafe(method_family = new)]
37        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
38
39        #[unsafe(method(itemProvider))]
40        #[unsafe(method_family = none)]
41        pub fn itemProvider(&self) -> Retained<NSItemProvider>;
42
43        /// Use `localObject` to attach additional information to
44        /// this drag item, visible only inside the app that started the drag.
45        #[unsafe(method(localObject))]
46        #[unsafe(method_family = none)]
47        pub fn localObject(&self) -> Option<Retained<AnyObject>>;
48
49        /// Setter for [`localObject`][Self::localObject].
50        ///
51        /// # Safety
52        ///
53        /// `local_object` should be of the correct type.
54        #[unsafe(method(setLocalObject:))]
55        #[unsafe(method_family = none)]
56        pub unsafe fn setLocalObject(&self, local_object: Option<&AnyObject>);
57
58        #[cfg(all(feature = "UIDragPreview", feature = "block2"))]
59        /// Use `previewProvider` to change the preview for an item.
60        ///
61        /// Each item is usually given a preview when the drag begins,
62        /// either by the UIDragInteractionDelegate's `-dragInteraction:previewForLiftingItem:session:`
63        /// method, or by creating a preview from the dragging view.
64        ///
65        /// During the drag, applications may attempt to change the item's preview,
66        /// by setting `previewProvider` to a block that returns a preview.
67        /// It will be called when and if the system requests it.
68        ///
69        /// To use the default preview, set `previewProvider` to nil.
70        /// To hide the preview, set `previewProvider` to a block that returns nil.
71        #[unsafe(method(previewProvider))]
72        #[unsafe(method_family = none)]
73        pub fn previewProvider(&self) -> *mut block2::DynBlock<dyn Fn() -> *mut UIDragPreview>;
74
75        #[cfg(all(feature = "UIDragPreview", feature = "block2"))]
76        /// Setter for [`previewProvider`][Self::previewProvider].
77        ///
78        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
79        ///
80        /// # Safety
81        ///
82        /// `preview_provider` block's return must be a valid pointer or null.
83        #[unsafe(method(setPreviewProvider:))]
84        #[unsafe(method_family = none)]
85        pub unsafe fn setPreviewProvider(
86            &self,
87            preview_provider: Option<&block2::DynBlock<dyn Fn() -> *mut UIDragPreview>>,
88        );
89
90        /// Requests for the drop preview to be updated if an active drop animation is in progress, and can handle updates.
91        /// If no active drop animation is in progress for the specified item, then nothing happens.
92        #[unsafe(method(setNeedsDropPreviewUpdate))]
93        #[unsafe(method_family = none)]
94        pub fn setNeedsDropPreviewUpdate(&self);
95    );
96}