objc2_ui_kit/generated/
UIUpdateLink.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-quartz-core")]
7#[cfg(not(target_os = "watchos"))]
8use objc2_quartz_core::*;
9
10use crate::*;
11
12extern_class!(
13    /// Allows to formally participate in UI updates and influence UI update behavior.
14    ///
15    /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiupdatelink?language=objc)
16    #[unsafe(super(NSObject))]
17    #[thread_kind = MainThreadOnly]
18    #[derive(Debug, PartialEq, Eq, Hash)]
19    pub struct UIUpdateLink;
20);
21
22unsafe impl NSObjectProtocol for UIUpdateLink {}
23
24impl UIUpdateLink {
25    extern_methods!(
26        #[unsafe(method(new))]
27        #[unsafe(method_family = new)]
28        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
29
30        #[unsafe(method(init))]
31        #[unsafe(method_family = init)]
32        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
33
34        #[cfg(all(
35            feature = "UIResponder",
36            feature = "UIScene",
37            feature = "UIWindowScene"
38        ))]
39        #[unsafe(method(updateLinkForWindowScene:))]
40        #[unsafe(method_family = none)]
41        pub unsafe fn updateLinkForWindowScene(
42            window_scene: &UIWindowScene,
43        ) -> Retained<UIUpdateLink>;
44
45        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
46        #[unsafe(method(updateLinkForView:))]
47        #[unsafe(method_family = none)]
48        pub unsafe fn updateLinkForView(view: &UIView) -> Retained<UIUpdateLink>;
49
50        #[cfg(all(
51            feature = "UIUpdateActionPhase",
52            feature = "UIUpdateInfo",
53            feature = "block2"
54        ))]
55        #[unsafe(method(addActionToPhase:handler:))]
56        #[unsafe(method_family = none)]
57        pub unsafe fn addActionToPhase_handler(
58            &self,
59            phase: &UIUpdateActionPhase,
60            handler: &block2::Block<dyn Fn(NonNull<UIUpdateLink>, NonNull<UIUpdateInfo>)>,
61        );
62
63        #[cfg(feature = "UIUpdateActionPhase")]
64        #[unsafe(method(addActionToPhase:target:selector:))]
65        #[unsafe(method_family = none)]
66        pub unsafe fn addActionToPhase_target_selector(
67            &self,
68            phase: &UIUpdateActionPhase,
69            target: &AnyObject,
70            selector: Sel,
71        );
72
73        /// It's required to enable the Update Link for it to have effect and for its actions to be invoked.
74        #[unsafe(method(isEnabled))]
75        #[unsafe(method_family = none)]
76        pub unsafe fn isEnabled(&self) -> bool;
77
78        /// Setter for [`isEnabled`][Self::isEnabled].
79        #[unsafe(method(setEnabled:))]
80        #[unsafe(method_family = none)]
81        pub unsafe fn setEnabled(&self, enabled: bool);
82
83        /// By default, `UIUpdateLink` is a passive UI update observer. Its actions will only be called when UI update is being
84        /// produced. When this property is set to `YES`, `UIUpdateLink` will request continuous UI updates by itself.
85        #[unsafe(method(requiresContinuousUpdates))]
86        #[unsafe(method_family = none)]
87        pub unsafe fn requiresContinuousUpdates(&self) -> bool;
88
89        /// Setter for [`requiresContinuousUpdates`][Self::requiresContinuousUpdates].
90        #[unsafe(method(setRequiresContinuousUpdates:))]
91        #[unsafe(method_family = none)]
92        pub unsafe fn setRequiresContinuousUpdates(&self, requires_continuous_updates: bool);
93
94        /// Request dispatch of low-latency eligible events in `LowLatencyEventDispatch` phase. Low latency eligible events are
95        /// dispatch in the middle of the UI update, meaning that to handle them application has half the time, compared to
96        /// events dispatched normally. Consult `-[UIUpdateInfo completionDeadlineTime]` for exact completion deadline time.
97        #[unsafe(method(wantsLowLatencyEventDispatch))]
98        #[unsafe(method_family = none)]
99        pub unsafe fn wantsLowLatencyEventDispatch(&self) -> bool;
100
101        /// Setter for [`wantsLowLatencyEventDispatch`][Self::wantsLowLatencyEventDispatch].
102        #[unsafe(method(setWantsLowLatencyEventDispatch:))]
103        #[unsafe(method_family = none)]
104        pub unsafe fn setWantsLowLatencyEventDispatch(
105            &self,
106            wants_low_latency_event_dispatch: bool,
107        );
108
109        /// Request immediate frame presentation. When enabled, system will request immediate rendering of the display frame
110        /// after last `CATransaction` commit for the current UI update. This allows to reduce input to display latency, as
111        /// rendered display frame will be presented one frame duration sooner. However, for this to happen amount of work
112        /// submitted to render server should be minimal, otherwise it will not be able to submit frame for presentation in
113        /// time. This capability is primarily useful for pencil drawing applications where low input to display latency is
114        /// critical for good user experience. Applications that request immediate presentation must be profiled thoroughly to
115        /// ensure that amount of application and render server work is adequate. When application requests immediate
116        /// presentation, but fails to keep work complexity at minimum, user will experience on screen judder, as frames will
117        /// not be presented at their intended time.
118        #[unsafe(method(wantsImmediatePresentation))]
119        #[unsafe(method_family = none)]
120        pub unsafe fn wantsImmediatePresentation(&self) -> bool;
121
122        /// Setter for [`wantsImmediatePresentation`][Self::wantsImmediatePresentation].
123        #[unsafe(method(setWantsImmediatePresentation:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setWantsImmediatePresentation(&self, wants_immediate_presentation: bool);
126
127        #[cfg(feature = "objc2-quartz-core")]
128        #[cfg(not(target_os = "watchos"))]
129        /// Preferred frame rate range. Even when not forcing periodic updates, this will still express intention to the system.
130        /// Use `CAFrameRateRangeDefault` (default value) to not request any specific frame rate range.
131        #[unsafe(method(preferredFrameRateRange))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn preferredFrameRateRange(&self) -> CAFrameRateRange;
134
135        #[cfg(feature = "objc2-quartz-core")]
136        #[cfg(not(target_os = "watchos"))]
137        /// Setter for [`preferredFrameRateRange`][Self::preferredFrameRateRange].
138        #[unsafe(method(setPreferredFrameRateRange:))]
139        #[unsafe(method_family = none)]
140        pub unsafe fn setPreferredFrameRateRange(
141            &self,
142            preferred_frame_rate_range: CAFrameRateRange,
143        );
144
145        #[cfg(feature = "UIUpdateInfo")]
146        /// During UI update, returns `UIUpdateInfo` instance describing current UI update state. Returns `nil` outside of UI
147        /// update.
148        #[unsafe(method(currentUpdateInfo))]
149        #[unsafe(method_family = none)]
150        pub unsafe fn currentUpdateInfo(&self) -> Option<Retained<UIUpdateInfo>>;
151    );
152}
153
154/// Convenience.
155impl UIUpdateLink {
156    extern_methods!(
157        #[cfg(all(feature = "UIUpdateInfo", feature = "block2"))]
158        /// Adds action to `UIUpdateActionPhase.beforeCADisplayLinkDispatch` phase.
159        #[unsafe(method(addActionWithHandler:))]
160        #[unsafe(method_family = none)]
161        pub unsafe fn addActionWithHandler(
162            &self,
163            handler: &block2::Block<dyn Fn(NonNull<UIUpdateLink>, NonNull<UIUpdateInfo>)>,
164        );
165
166        /// Adds action to `UIUpdateActionPhase.beforeCADisplayLinkDispatch` phase.
167        #[unsafe(method(addActionWithTarget:selector:))]
168        #[unsafe(method_family = none)]
169        pub unsafe fn addActionWithTarget_selector(&self, target: &AnyObject, selector: Sel);
170
171        #[cfg(all(
172            feature = "UIResponder",
173            feature = "UIScene",
174            feature = "UIUpdateInfo",
175            feature = "UIWindowScene",
176            feature = "block2"
177        ))]
178        /// Adds action to `UIUpdateActionPhase.beforeCADisplayLinkDispatch` phase.
179        #[unsafe(method(updateLinkForWindowScene:actionHandler:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn updateLinkForWindowScene_actionHandler(
182            window_scene: &UIWindowScene,
183            handler: &block2::Block<dyn Fn(NonNull<UIUpdateLink>, NonNull<UIUpdateInfo>)>,
184        ) -> Retained<UIUpdateLink>;
185
186        #[cfg(all(
187            feature = "UIResponder",
188            feature = "UIScene",
189            feature = "UIWindowScene"
190        ))]
191        /// Adds action to `UIUpdateActionPhase.beforeCADisplayLinkDispatch` phase.
192        #[unsafe(method(updateLinkForWindowScene:actionTarget:selector:))]
193        #[unsafe(method_family = none)]
194        pub unsafe fn updateLinkForWindowScene_actionTarget_selector(
195            window_scene: &UIWindowScene,
196            target: &AnyObject,
197            selector: Sel,
198        ) -> Retained<UIUpdateLink>;
199
200        #[cfg(all(
201            feature = "UIResponder",
202            feature = "UIUpdateInfo",
203            feature = "UIView",
204            feature = "block2"
205        ))]
206        /// Adds action to `UIUpdateActionPhase.beforeCADisplayLinkDispatch` phase.
207        #[unsafe(method(updateLinkForView:actionHandler:))]
208        #[unsafe(method_family = none)]
209        pub unsafe fn updateLinkForView_actionHandler(
210            view: &UIView,
211            handler: &block2::Block<dyn Fn(NonNull<UIUpdateLink>, NonNull<UIUpdateInfo>)>,
212        ) -> Retained<UIUpdateLink>;
213
214        #[cfg(all(feature = "UIResponder", feature = "UIView"))]
215        /// Adds action to `UIUpdateActionPhase.beforeCADisplayLinkDispatch` phase.
216        #[unsafe(method(updateLinkForView:actionTarget:selector:))]
217        #[unsafe(method_family = none)]
218        pub unsafe fn updateLinkForView_actionTarget_selector(
219            view: &UIView,
220            target: &AnyObject,
221            selector: Sel,
222        ) -> Retained<UIUpdateLink>;
223    );
224}