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