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