objc2_ui_kit/generated/
UIViewPropertyAnimator.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::*;
8use objc2_foundation::*;
9
10use crate::*;
11
12extern_class!(
13    /// [Apple's documentation](https://developer.apple.com/documentation/uikit/uiviewpropertyanimator?language=objc)
14    #[unsafe(super(NSObject))]
15    #[thread_kind = MainThreadOnly]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    pub struct UIViewPropertyAnimator;
18);
19
20extern_conformance!(
21    unsafe impl NSCopying for UIViewPropertyAnimator {}
22);
23
24unsafe impl CopyingHelper for UIViewPropertyAnimator {
25    type Result = Self;
26}
27
28extern_conformance!(
29    unsafe impl NSObjectProtocol for UIViewPropertyAnimator {}
30);
31
32#[cfg(feature = "UIViewAnimating")]
33extern_conformance!(
34    unsafe impl UIViewAnimating for UIViewPropertyAnimator {}
35);
36
37#[cfg(feature = "UIViewAnimating")]
38extern_conformance!(
39    unsafe impl UIViewImplicitlyAnimating for UIViewPropertyAnimator {}
40);
41
42impl UIViewPropertyAnimator {
43    extern_methods!(
44        #[cfg(feature = "UITimingCurveProvider")]
45        #[unsafe(method(timingParameters))]
46        #[unsafe(method_family = none)]
47        pub fn timingParameters(
48            &self,
49        ) -> Option<Retained<ProtocolObject<dyn UITimingCurveProvider>>>;
50
51        #[unsafe(method(duration))]
52        #[unsafe(method_family = none)]
53        pub fn duration(&self) -> NSTimeInterval;
54
55        /// Defaults to 0. This property is set when calling -[UIView startAnimationAfterDelay:].
56        #[unsafe(method(delay))]
57        #[unsafe(method_family = none)]
58        pub fn delay(&self) -> NSTimeInterval;
59
60        /// Defaults to YES. Raises if set on an active animator.
61        #[unsafe(method(isUserInteractionEnabled))]
62        #[unsafe(method_family = none)]
63        pub fn isUserInteractionEnabled(&self) -> bool;
64
65        /// Setter for [`isUserInteractionEnabled`][Self::isUserInteractionEnabled].
66        #[unsafe(method(setUserInteractionEnabled:))]
67        #[unsafe(method_family = none)]
68        pub fn setUserInteractionEnabled(&self, user_interaction_enabled: bool);
69
70        /// Defaults to NO. Set if you need to manage the the hit-testing of animating view hierarchies
71        #[unsafe(method(isManualHitTestingEnabled))]
72        #[unsafe(method_family = none)]
73        pub fn isManualHitTestingEnabled(&self) -> bool;
74
75        /// Setter for [`isManualHitTestingEnabled`][Self::isManualHitTestingEnabled].
76        #[unsafe(method(setManualHitTestingEnabled:))]
77        #[unsafe(method_family = none)]
78        pub fn setManualHitTestingEnabled(&self, manual_hit_testing_enabled: bool);
79
80        /// Defaults to YES. Raises if set on an active animator.
81        #[unsafe(method(isInterruptible))]
82        #[unsafe(method_family = none)]
83        pub fn isInterruptible(&self) -> bool;
84
85        /// Setter for [`isInterruptible`][Self::isInterruptible].
86        #[unsafe(method(setInterruptible:))]
87        #[unsafe(method_family = none)]
88        pub fn setInterruptible(&self, interruptible: bool);
89
90        /// Defaults to YES. Provides the ability for an animator to pause and scrub either linearly or using the animator’s current timing.
91        #[unsafe(method(scrubsLinearly))]
92        #[unsafe(method_family = none)]
93        pub fn scrubsLinearly(&self) -> bool;
94
95        /// Setter for [`scrubsLinearly`][Self::scrubsLinearly].
96        #[unsafe(method(setScrubsLinearly:))]
97        #[unsafe(method_family = none)]
98        pub fn setScrubsLinearly(&self, scrubs_linearly: bool);
99
100        /// Defaults to NO. Provides the ability for an animator to pause on completion instead of transitioning to the .inactive state.
101        #[unsafe(method(pausesOnCompletion))]
102        #[unsafe(method_family = none)]
103        pub fn pausesOnCompletion(&self) -> bool;
104
105        /// Setter for [`pausesOnCompletion`][Self::pausesOnCompletion].
106        #[unsafe(method(setPausesOnCompletion:))]
107        #[unsafe(method_family = none)]
108        pub fn setPausesOnCompletion(&self, pauses_on_completion: bool);
109
110        /// Flush all pending updates (including traits, properties, and layout) whenever the animation context changes.
111        /// This includes flushing updates:
112        /// - Before entering an animation scope, for invalidations that happened previously without animation.
113        /// - Before entering a nested animation scope, for invalidations that happened in the outer animation scope.
114        /// - Before exiting any animation scope, for invalidations that happened in that animation scope.
115        /// - Before disabling animations, for invalidations that happened in the animation scope with animations enabled.
116        /// - Before re-enabling animations, for invalidations that happened in the scope with animations disabled.
117        /// This behavior implicitly applies to any nested animation scopes, even if they don't explicitly specify this.
118        #[unsafe(method(flushUpdates))]
119        #[unsafe(method_family = none)]
120        pub fn flushUpdates(&self) -> bool;
121
122        /// Setter for [`flushUpdates`][Self::flushUpdates].
123        #[unsafe(method(setFlushUpdates:))]
124        #[unsafe(method_family = none)]
125        pub fn setFlushUpdates(&self, flush_updates: bool);
126
127        #[cfg(feature = "UITimingCurveProvider")]
128        #[unsafe(method(initWithDuration:timingParameters:))]
129        #[unsafe(method_family = init)]
130        pub fn initWithDuration_timingParameters(
131            this: Allocated<Self>,
132            duration: NSTimeInterval,
133            parameters: &ProtocolObject<dyn UITimingCurveProvider>,
134        ) -> Retained<Self>;
135
136        #[cfg(all(feature = "UIView", feature = "block2"))]
137        /// All convenience initializers return an animator which is not running.
138        #[unsafe(method(initWithDuration:curve:animations:))]
139        #[unsafe(method_family = init)]
140        pub fn initWithDuration_curve_animations(
141            this: Allocated<Self>,
142            duration: NSTimeInterval,
143            curve: UIViewAnimationCurve,
144            animations: Option<&block2::DynBlock<dyn Fn()>>,
145        ) -> Retained<Self>;
146
147        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
148        #[unsafe(method(initWithDuration:controlPoint1:controlPoint2:animations:))]
149        #[unsafe(method_family = init)]
150        pub fn initWithDuration_controlPoint1_controlPoint2_animations(
151            this: Allocated<Self>,
152            duration: NSTimeInterval,
153            point1: CGPoint,
154            point2: CGPoint,
155            animations: Option<&block2::DynBlock<dyn Fn()>>,
156        ) -> Retained<Self>;
157
158        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
159        #[unsafe(method(initWithDuration:dampingRatio:animations:))]
160        #[unsafe(method_family = init)]
161        pub fn initWithDuration_dampingRatio_animations(
162            this: Allocated<Self>,
163            duration: NSTimeInterval,
164            ratio: CGFloat,
165            animations: Option<&block2::DynBlock<dyn Fn()>>,
166        ) -> Retained<Self>;
167
168        #[cfg(all(feature = "UIView", feature = "UIViewAnimating", feature = "block2"))]
169        /// This method provides compatibility with the old style [UIView
170        /// animationWithDuration:...]  method. It is also useful for controlling
171        /// how animations options are inherited.
172        ///
173        /// Creates a UIViewPropertyAnimator, sets the duration, options, etc. And starts the
174        /// animation with the associated animation and completion blocks. The animator
175        /// returned is interruptible only if it is not called from within the execution
176        /// block of another animation (animator or legacy). Note that if it is called
177        /// within the execution block of another animation it will inherit the duration
178        /// and other characteristics of that animation UNLESS the appropriate override
179        /// options have been specified. Also note that if is called within the execution
180        /// block of another propertyAnimator that is interruptible, the implicit
181        /// animations defined by this call will be tracked by the outer
182        /// propertyAnimator.
183        #[unsafe(method(runningPropertyAnimatorWithDuration:delay:options:animations:completion:))]
184        #[unsafe(method_family = none)]
185        pub fn runningPropertyAnimatorWithDuration_delay_options_animations_completion(
186            duration: NSTimeInterval,
187            delay: NSTimeInterval,
188            options: UIViewAnimationOptions,
189            animations: &block2::DynBlock<dyn Fn()>,
190            completion: Option<&block2::DynBlock<dyn Fn(UIViewAnimatingPosition)>>,
191            mtm: MainThreadMarker,
192        ) -> Retained<Self>;
193
194        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
195        /// Animatable view properties that are set by the animation block will be
196        /// animated to their new values. The animations will commence at delayFactor *
197        /// animator.duration seconds into the animation. The duration of the animation
198        /// will be (1 - delayFactor) * animator.duration seconds.
199        #[unsafe(method(addAnimations:delayFactor:))]
200        #[unsafe(method_family = none)]
201        pub fn addAnimations_delayFactor(
202            &self,
203            animation: &block2::DynBlock<dyn Fn()>,
204            delay_factor: CGFloat,
205        );
206
207        #[cfg(feature = "block2")]
208        /// Animatable view properties that are set by the animation block will be
209        /// animated to their new values. Starting an animator that does not contain any animation blocks
210        /// will start the animator in a transient paused state. While in this state, submitting an animation
211        /// block will automatically start animating any animatable view properties set therein. When the
212        /// animator is stopped, either naturally completing or explicitly, any animation blocks and completion
213        /// handlers are invalidated. Immediately calling `startAnimation` again on the animator, since there
214        /// are no animation blocks, will start the animator in a transient paused state.
215        #[unsafe(method(addAnimations:))]
216        #[unsafe(method_family = none)]
217        pub fn addAnimations(&self, animation: &block2::DynBlock<dyn Fn()>);
218
219        #[cfg(all(feature = "UIViewAnimating", feature = "block2"))]
220        #[unsafe(method(addCompletion:))]
221        #[unsafe(method_family = none)]
222        pub fn addCompletion(&self, completion: &block2::DynBlock<dyn Fn(UIViewAnimatingPosition)>);
223
224        #[cfg(all(feature = "UITimingCurveProvider", feature = "objc2-core-foundation"))]
225        /// Provides a means to continue an animation in either the forward or reversed
226        /// directions with new timing parameters and duration.  The durationFactor is in
227        /// terms of a unit duration defined by the originally specified duration of the
228        /// animator. It is used to specify the remaining time for the animation. When
229        /// called, it behaves as if the animation was started from its current position
230        /// with a new duration and timing parameters.
231        #[unsafe(method(continueAnimationWithTimingParameters:durationFactor:))]
232        #[unsafe(method_family = none)]
233        pub fn continueAnimationWithTimingParameters_durationFactor(
234            &self,
235            parameters: Option<&ProtocolObject<dyn UITimingCurveProvider>>,
236            duration_factor: CGFloat,
237        );
238    );
239}
240
241/// Methods declared on superclass `NSObject`.
242impl UIViewPropertyAnimator {
243    extern_methods!(
244        #[unsafe(method(init))]
245        #[unsafe(method_family = init)]
246        pub fn init(this: Allocated<Self>) -> Retained<Self>;
247
248        #[unsafe(method(new))]
249        #[unsafe(method_family = new)]
250        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
251    );
252}