objc2_ui_kit/generated/
UIFieldBehavior.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/uifieldbehavior?language=objc)
14    #[unsafe(super(UIDynamicBehavior, NSObject))]
15    #[thread_kind = MainThreadOnly]
16    #[derive(Debug, PartialEq, Eq, Hash)]
17    #[cfg(feature = "UIDynamicBehavior")]
18    pub struct UIFieldBehavior;
19);
20
21#[cfg(feature = "UIDynamicBehavior")]
22extern_conformance!(
23    unsafe impl NSObjectProtocol for UIFieldBehavior {}
24);
25
26#[cfg(feature = "UIDynamicBehavior")]
27impl UIFieldBehavior {
28    extern_methods!(
29        #[unsafe(method(init))]
30        #[unsafe(method_family = init)]
31        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
32
33        #[unsafe(method(addItem:))]
34        #[unsafe(method_family = none)]
35        pub unsafe fn addItem(&self, item: &ProtocolObject<dyn UIDynamicItem>);
36
37        #[unsafe(method(removeItem:))]
38        #[unsafe(method_family = none)]
39        pub unsafe fn removeItem(&self, item: &ProtocolObject<dyn UIDynamicItem>);
40
41        #[unsafe(method(items))]
42        #[unsafe(method_family = none)]
43        pub unsafe fn items(&self) -> Retained<NSArray<ProtocolObject<dyn UIDynamicItem>>>;
44
45        #[cfg(feature = "objc2-core-foundation")]
46        /// The position (origin) of the field in the reference coordinate system
47        #[unsafe(method(position))]
48        #[unsafe(method_family = none)]
49        pub unsafe fn position(&self) -> CGPoint;
50
51        #[cfg(feature = "objc2-core-foundation")]
52        /// Setter for [`position`][Self::position].
53        #[unsafe(method(setPosition:))]
54        #[unsafe(method_family = none)]
55        pub unsafe fn setPosition(&self, position: CGPoint);
56
57        #[cfg(feature = "UIRegion")]
58        /// The region property is the domain of the field's effect. No force is applied to objects outside the region.
59        /// The default region is the infiniteRegion
60        #[unsafe(method(region))]
61        #[unsafe(method_family = none)]
62        pub unsafe fn region(&self) -> Retained<UIRegion>;
63
64        #[cfg(feature = "UIRegion")]
65        /// Setter for [`region`][Self::region].
66        #[unsafe(method(setRegion:))]
67        #[unsafe(method_family = none)]
68        pub unsafe fn setRegion(&self, region: &UIRegion);
69
70        #[cfg(feature = "objc2-core-foundation")]
71        /// Strength scaling value. default 1.0
72        #[unsafe(method(strength))]
73        #[unsafe(method_family = none)]
74        pub unsafe fn strength(&self) -> CGFloat;
75
76        #[cfg(feature = "objc2-core-foundation")]
77        /// Setter for [`strength`][Self::strength].
78        #[unsafe(method(setStrength:))]
79        #[unsafe(method_family = none)]
80        pub unsafe fn setStrength(&self, strength: CGFloat);
81
82        #[cfg(feature = "objc2-core-foundation")]
83        /// The falloff exponent used to calculate field strength at a distance.
84        /// Falloff starts at the minimum radius.
85        /// The default exponent is zero, which results in a uniform field with no falloff.
86        ///
87        /// See: minimumRadius
88        #[unsafe(method(falloff))]
89        #[unsafe(method_family = none)]
90        pub unsafe fn falloff(&self) -> CGFloat;
91
92        #[cfg(feature = "objc2-core-foundation")]
93        /// Setter for [`falloff`][Self::falloff].
94        #[unsafe(method(setFalloff:))]
95        #[unsafe(method_family = none)]
96        pub unsafe fn setFalloff(&self, falloff: CGFloat);
97
98        #[cfg(feature = "objc2-core-foundation")]
99        /// Minimum radius of effect. Default is very small.
100        #[unsafe(method(minimumRadius))]
101        #[unsafe(method_family = none)]
102        pub unsafe fn minimumRadius(&self) -> CGFloat;
103
104        #[cfg(feature = "objc2-core-foundation")]
105        /// Setter for [`minimumRadius`][Self::minimumRadius].
106        #[unsafe(method(setMinimumRadius:))]
107        #[unsafe(method_family = none)]
108        pub unsafe fn setMinimumRadius(&self, minimum_radius: CGFloat);
109
110        #[cfg(feature = "objc2-core-foundation")]
111        /// The direction of the field.
112        /// If the field is non-directional, a zero vector will be returned
113        ///
114        /// See: linearGravityFieldWithVector:direction
115        ///
116        /// See: velocityFieldWithVector:direction
117        #[unsafe(method(direction))]
118        #[unsafe(method_family = none)]
119        pub unsafe fn direction(&self) -> CGVector;
120
121        #[cfg(feature = "objc2-core-foundation")]
122        /// Setter for [`direction`][Self::direction].
123        #[unsafe(method(setDirection:))]
124        #[unsafe(method_family = none)]
125        pub unsafe fn setDirection(&self, direction: CGVector);
126
127        #[cfg(feature = "objc2-core-foundation")]
128        /// Fields without a smoothness component will return 0
129        ///
130        /// See: noiseFieldWithSmoothness:smoothness:animationSpeed
131        ///
132        /// See: turbulenceFieldWithSmoothness:smoothness:animationSpeed
133        #[unsafe(method(smoothness))]
134        #[unsafe(method_family = none)]
135        pub unsafe fn smoothness(&self) -> CGFloat;
136
137        #[cfg(feature = "objc2-core-foundation")]
138        /// Setter for [`smoothness`][Self::smoothness].
139        #[unsafe(method(setSmoothness:))]
140        #[unsafe(method_family = none)]
141        pub unsafe fn setSmoothness(&self, smoothness: CGFloat);
142
143        #[cfg(feature = "objc2-core-foundation")]
144        /// Fields that can be animated can have non zero values. A value of 2 will animate twice as fast as a value of 1.
145        ///
146        /// See: noiseFieldWithSmoothness:smoothness:animationSpeed
147        ///
148        /// See: turbulenceFieldWithSmoothness:smoothness:animationSpeed
149        #[unsafe(method(animationSpeed))]
150        #[unsafe(method_family = none)]
151        pub unsafe fn animationSpeed(&self) -> CGFloat;
152
153        #[cfg(feature = "objc2-core-foundation")]
154        /// Setter for [`animationSpeed`][Self::animationSpeed].
155        #[unsafe(method(setAnimationSpeed:))]
156        #[unsafe(method_family = none)]
157        pub unsafe fn setAnimationSpeed(&self, animation_speed: CGFloat);
158
159        /// Slows an object proportionally to the object’s velocity.
160        /// Use this to simulate effects such as friction from motion through the air.
161        #[unsafe(method(dragField))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn dragField(mtm: MainThreadMarker) -> Retained<Self>;
164
165        /// Applies a force tangential to the direction from the sample point to the field's position.
166        /// The force will be CCW to the direction. Make the strength negative to apply force in the CW direction.
167        /// Amount is proportional to distance from center and the object's mass. This can be used to create rotational effects.
168        #[unsafe(method(vortexField))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn vortexField(mtm: MainThreadMarker) -> Retained<Self>;
171
172        #[cfg(feature = "objc2-core-foundation")]
173        /// Applies a force in the direction of the origin of the field in local space. To repel objects, use a negative strength.
174        /// The force is proportional to the distance from the field origin. Varies with the mass of the object according to F = ma
175        ///
176        /// Parameter `position`: the origin of the field
177        ///
178        /// See: position
179        #[unsafe(method(radialGravityFieldWithPosition:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn radialGravityFieldWithPosition(
182            position: CGPoint,
183            mtm: MainThreadMarker,
184        ) -> Retained<Self>;
185
186        #[cfg(feature = "objc2-core-foundation")]
187        /// Applies a force in the direction of the vector in the local space. To repel objects, use a negative strength.
188        /// The force is the same everywhere in the field. Varies with the mass of the object according to F = ma
189        ///
190        /// Parameter `direction`: The direction the force is applied in the x,y plane. The length of the direction vector is multiplied by
191        /// the field's strength property to get the final calculated force. All components of the direction vector are used to calculate the length.
192        ///
193        /// See: direction
194        #[unsafe(method(linearGravityFieldWithVector:))]
195        #[unsafe(method_family = none)]
196        pub unsafe fn linearGravityFieldWithVector(
197            direction: CGVector,
198            mtm: MainThreadMarker,
199        ) -> Retained<Self>;
200
201        #[cfg(feature = "objc2-core-foundation")]
202        /// Uses the supplied velocity vector for any object entering the field’s region of effect.
203        /// Velocity fields override the effect of any other acceleration applied to the body.
204        ///
205        /// Parameter `direction`: The directed velocity that will be applied to the body.
206        ///
207        /// See: direction
208        #[unsafe(method(velocityFieldWithVector:))]
209        #[unsafe(method_family = none)]
210        pub unsafe fn velocityFieldWithVector(
211            direction: CGVector,
212            mtm: MainThreadMarker,
213        ) -> Retained<Self>;
214
215        #[cfg(feature = "objc2-core-foundation")]
216        /// A time varying differentiable Perlin simplex noise field. By default a smooth noise is calculated,
217        /// and the field is time varying. To freeze the noise in place, set animationSpeed to 0.0. Mass is ignored.
218        ///
219        /// Parameter `smoothness`: value of 0 means as noisy as possible, 1 means as smooth as possible
220        ///
221        /// Parameter `animationSpeed`: is the general field rate of change in Hz
222        ///
223        /// See: smoothness
224        ///
225        /// See: animationSpeed
226        #[unsafe(method(noiseFieldWithSmoothness:animationSpeed:))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn noiseFieldWithSmoothness_animationSpeed(
229            smoothness: CGFloat,
230            speed: CGFloat,
231            mtm: MainThreadMarker,
232        ) -> Retained<Self>;
233
234        #[cfg(feature = "objc2-core-foundation")]
235        /// Just like Noise, except the strength of the noise is proportional to the velocity of the object in the field.
236        ///
237        /// Parameter `smoothness`: value of 0 means as noisy as possible, 1 means as smooth as possible
238        ///
239        /// Parameter `animationSpeed`: is the general field rate of change in Hz
240        ///
241        /// See: smoothness
242        ///
243        /// See: animationSpeed
244        #[unsafe(method(turbulenceFieldWithSmoothness:animationSpeed:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn turbulenceFieldWithSmoothness_animationSpeed(
247            smoothness: CGFloat,
248            speed: CGFloat,
249            mtm: MainThreadMarker,
250        ) -> Retained<Self>;
251
252        /// A Hooke’s law force - a force linearly proportional to distance from the center of the field. An object in this
253        /// field will oscillate with a period proportional to the inverse of the mass.
254        /// An example use is to keep objects confined to a particular region.
255        #[unsafe(method(springField))]
256        #[unsafe(method_family = none)]
257        pub unsafe fn springField(mtm: MainThreadMarker) -> Retained<Self>;
258
259        /// A force proportional to the charge on the object. A charge property has been
260        /// added to UIDynamicItemBehavior to accomplish this. An example use of this field is to make objects behavior differently
261        /// from one another when they enter a region, or to make an object's behavior different than its mass based behavior
262        /// This field models the first part of the Lorentz equation, F = qE
263        #[unsafe(method(electricField))]
264        #[unsafe(method_family = none)]
265        pub unsafe fn electricField(mtm: MainThreadMarker) -> Retained<Self>;
266
267        /// The magnetic field is a uniform field in the positive-z direction (coming out of the screen). When the velocity
268        /// of a charged dynamic item is perpendicular to the uniform magnetic field, the item feels a resulting force normal
269        /// to both the velocity and the B field. This results CCW circular motion. You can adjust the strength of the B field
270        /// to be negative which will result in circular motion being CW instead of CCW. An example use of this field is to make
271        /// objects behavior differently from one another when they enter a region, or to make an object's behavior different
272        /// than its mass based behavior. This field models the second part of the Lorentz equation, F = qvB
273        #[unsafe(method(magneticField))]
274        #[unsafe(method_family = none)]
275        pub unsafe fn magneticField(mtm: MainThreadMarker) -> Retained<Self>;
276
277        #[cfg(all(feature = "block2", feature = "objc2-core-foundation"))]
278        /// A field force with a custom force evaluator.
279        ///
280        /// Parameter `field`: the field being evaluated
281        ///
282        /// Parameter `position`: The location to evaluate the force at
283        ///
284        /// Parameter `velocity`: The velocity to be considered during force evaluation. Useful for calculating drag.
285        ///
286        /// Parameter `mass`: The mass to be taken into account during force evaluation
287        ///
288        /// Parameter `charge`: The charge to be taken into account during force evaluation
289        ///
290        /// Parameter `deltaTime`: The current time step
291        #[unsafe(method(fieldWithEvaluationBlock:))]
292        #[unsafe(method_family = none)]
293        pub unsafe fn fieldWithEvaluationBlock(
294            block: &block2::DynBlock<
295                dyn Fn(
296                    NonNull<UIFieldBehavior>,
297                    CGPoint,
298                    CGVector,
299                    CGFloat,
300                    CGFloat,
301                    NSTimeInterval,
302                ) -> CGVector,
303            >,
304            mtm: MainThreadMarker,
305        ) -> Retained<Self>;
306    );
307}
308
309/// Methods declared on superclass `NSObject`.
310#[cfg(feature = "UIDynamicBehavior")]
311impl UIFieldBehavior {
312    extern_methods!(
313        #[unsafe(method(new))]
314        #[unsafe(method_family = new)]
315        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
316    );
317}