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