1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
#[cfg(feature = "objc2-core-foundation")]
use objc2_core_foundation::*;
use objc2_foundation::*;
use crate::*;
/// The corner curve to apply to a view.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uicornercurve?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct UICornerCurve(pub NSInteger);
impl UICornerCurve {
/// Select the corner style automatically.
#[doc(alias = "UICornerCurveAutomatic")]
pub const Automatic: Self = Self(0);
/// Always use a circular corner style.
#[doc(alias = "UICornerCurveCircular")]
pub const Circular: Self = Self(1);
/// Always use a continuous corner style.
#[doc(alias = "UICornerCurveContinuous")]
pub const Continuous: Self = Self(2);
}
unsafe impl Encode for UICornerCurve {
const ENCODING: Encoding = NSInteger::ENCODING;
}
unsafe impl RefEncode for UICornerCurve {
const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}
extern_protocol!(
/// A type that can provide a custom `UIShape`, resolved dynamically based on
/// context.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uishapeprovider?language=objc)
pub unsafe trait UIShapeProvider: NSObjectProtocol {
/// Resolves this shape in the provided `context`.
#[unsafe(method(resolvedShapeInContext:))]
#[unsafe(method_family = none)]
fn resolvedShapeInContext(
&self,
context: &UIShapeResolutionContext,
) -> Retained<UIResolvedShape>;
}
);
extern_class!(
/// An abstract representation of a shape.
///
/// A `UIShape` can represent a simple shape such as a rectangle or circle that
/// are later "resolved" into a concrete shape based on context like a size and
/// position for the shape. A `UIShape` can also represent more complex shapes
/// like paths and even "dynamic" shapes that are resolved using a custom
/// closure.
///
/// You typically use a `UIShape` with APIs like `UIHoverStyle` to represent the
/// shape of an effect.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uishape?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIShape;
);
extern_conformance!(
unsafe impl NSCopying for UIShape {}
);
unsafe impl CopyingHelper for UIShape {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for UIShape {}
);
extern_conformance!(
unsafe impl UIShapeProvider for UIShape {}
);
impl UIShape {
extern_methods!(
/// A rectangular shape.
#[unsafe(method(rectShape))]
#[unsafe(method_family = none)]
pub fn rectShape() -> Retained<UIShape>;
/// A capsule shape, equivalent to a rounded rectangle where the corner
/// radius is chosen as half the length of the rectangle’s smallest edge.
#[unsafe(method(capsuleShape))]
#[unsafe(method_family = none)]
pub fn capsuleShape() -> Retained<UIShape>;
/// A circular shape, with a radius equals half the length of the frame
/// rectangle’s smallest edge.
#[unsafe(method(circleShape))]
#[unsafe(method_family = none)]
pub fn circleShape() -> Retained<UIShape>;
#[cfg(feature = "objc2-core-foundation")]
/// A rectangular shape with rounded corners, aligned inside the frame of
/// in which it is contained.
#[unsafe(method(rectShapeWithCornerRadius:))]
#[unsafe(method_family = none)]
pub fn rectShapeWithCornerRadius(corner_radius: CGFloat) -> Retained<Self>;
#[cfg(feature = "objc2-core-foundation")]
/// A rectangular shape with rounded corners, aligned inside the frame of
/// in which it is contained.
#[unsafe(method(rectShapeWithCornerRadius:cornerCurve:))]
#[unsafe(method_family = none)]
pub fn rectShapeWithCornerRadius_cornerCurve(
corner_radius: CGFloat,
corner_curve: UICornerCurve,
) -> Retained<Self>;
#[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
/// A rectangular shape with rounded corners, aligned inside the frame of
/// in which it is contained.
#[unsafe(method(rectShapeWithCornerRadius:cornerCurve:maskedCorners:))]
#[unsafe(method_family = none)]
pub fn rectShapeWithCornerRadius_cornerCurve_maskedCorners(
corner_radius: CGFloat,
corner_curve: UICornerCurve,
masked_corners: UIRectCorner,
) -> Retained<Self>;
#[cfg(feature = "objc2-core-foundation")]
/// A fixed rectangle shape using `rect` as its shape, regardless of the
/// frame in which it is contained.
#[unsafe(method(fixedRectShapeWithRect:))]
#[unsafe(method_family = none)]
pub fn fixedRectShapeWithRect(rect: CGRect) -> Retained<Self>;
#[cfg(feature = "objc2-core-foundation")]
/// A fixed rectangle shape using `rect` as its shape, regardless of the
/// frame in which it is contained, with rounded corners using `cornerRadius`.
#[unsafe(method(fixedRectShapeWithRect:cornerRadius:))]
#[unsafe(method_family = none)]
pub fn fixedRectShapeWithRect_cornerRadius(
rect: CGRect,
corner_radius: CGFloat,
) -> Retained<Self>;
#[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
/// A fixed rectangle shape using `rect` as its shape, regardless of the
/// frame in which it is contained, with rounded corners using `cornerRadius`.
#[unsafe(method(fixedRectShapeWithRect:cornerRadius:cornerCurve:maskedCorners:))]
#[unsafe(method_family = none)]
pub fn fixedRectShapeWithRect_cornerRadius_cornerCurve_maskedCorners(
rect: CGRect,
corner_radius: CGFloat,
corner_curve: UICornerCurve,
masked_corners: UIRectCorner,
) -> Retained<Self>;
#[cfg(feature = "UIBezierPath")]
/// A shape with a custom bezier path.
#[unsafe(method(shapeWithBezierPath:))]
#[unsafe(method_family = none)]
pub fn shapeWithBezierPath(path: &UIBezierPath) -> Retained<Self>;
/// Creates a dynamic shape that can be resolved using the provided
/// `UIShapeProvider` based on context like its containing rect.
#[unsafe(method(shapeWithProvider:))]
#[unsafe(method_family = none)]
pub fn shapeWithProvider(provider: &ProtocolObject<dyn UIShapeProvider>) -> Retained<Self>;
#[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
/// Insets this shape by the provided `insets`, returning a new modified
/// shape.
///
/// Negative values can be used to add inner padding to a shape. If this
/// shape is not insettable (e.g., if it is a custom path), this has no
/// effect. For some shapes like rounded rectangles, this can also modify
/// the corner radii of the shape to ensure the resulting corners are
/// concentric.
#[unsafe(method(shapeByApplyingInsets:))]
#[unsafe(method_family = none)]
pub fn shapeByApplyingInsets(&self, insets: UIEdgeInsets) -> Retained<UIShape>;
#[cfg(feature = "objc2-core-foundation")]
/// Insets this shape by the provided `inset`, returning a new modified
/// shape.
///
/// Negative values can be used to add inner padding to a shape. If this
/// shape is not insettable (e.g., if it is a custom path), this has no
/// effect. For some shapes like rounded rectangles, this can also modify
/// the corner radii of the shape to ensure the resulting corners are
/// concentric.
#[unsafe(method(shapeByApplyingInset:))]
#[unsafe(method_family = none)]
pub fn shapeByApplyingInset(&self, inset: CGFloat) -> Retained<UIShape>;
/// Resolves this shape in the provided `context`.
#[unsafe(method(resolvedShapeInContext:))]
#[unsafe(method_family = none)]
pub fn resolvedShapeInContext(
&self,
context: &UIShapeResolutionContext,
) -> Retained<UIResolvedShape>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// A shape that has been resolved based on a `ResolutionContext`.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uiresolvedshape?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIResolvedShape;
);
extern_conformance!(
unsafe impl NSCopying for UIResolvedShape {}
);
unsafe impl CopyingHelper for UIResolvedShape {
type Result = Self;
}
extern_conformance!(
unsafe impl NSObjectProtocol for UIResolvedShape {}
);
impl UIResolvedShape {
extern_methods!(
/// The abstract shape that produced this resolved shape.
#[unsafe(method(shape))]
#[unsafe(method_family = none)]
pub fn shape(&self) -> Retained<UIShape>;
#[cfg(feature = "objc2-core-foundation")]
/// The bounding rect in which the shape is framed.
#[unsafe(method(boundingRect))]
#[unsafe(method_family = none)]
pub fn boundingRect(&self) -> CGRect;
#[cfg(feature = "UIBezierPath")]
/// The bezier path representing this shape.
#[unsafe(method(path))]
#[unsafe(method_family = none)]
pub fn path(&self) -> Retained<UIBezierPath>;
#[cfg(all(feature = "UIGeometry", feature = "objc2-core-foundation"))]
/// Insets this shape by the provided `insets`, returning a new modified
/// shape.
///
/// Negative values can be used to add inner padding to a shape. If this
/// shape is not insettable (e.g., if it is a custom path), this has no
/// effect. For some shapes like rounded rectangles, this can also modify
/// the corner radii of the shape to ensure the resulting corners are
/// concentric.
#[unsafe(method(shapeByApplyingInsets:))]
#[unsafe(method_family = none)]
pub fn shapeByApplyingInsets(&self, insets: UIEdgeInsets) -> Retained<UIResolvedShape>;
#[cfg(feature = "objc2-core-foundation")]
/// Insets this shape by the provided `inset`, returning a new modified
/// shape.
///
/// Negative values can be used to add inner padding to a shape. If this
/// shape is not insettable (e.g., if it is a custom path), this has no
/// effect. For some shapes like rounded rectangles, this can also modify
/// the corner radii of the shape to ensure the resulting corners are
/// concentric.
#[unsafe(method(shapeByApplyingInset:))]
#[unsafe(method_family = none)]
pub fn shapeByApplyingInset(&self, inset: CGFloat) -> Retained<UIResolvedShape>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}
extern_class!(
/// The context used for resolving a `dynamic` `UIShape`.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uishaperesolutioncontext?language=objc)
#[unsafe(super(NSObject))]
#[derive(Debug, PartialEq, Eq, Hash)]
pub struct UIShapeResolutionContext;
);
extern_conformance!(
unsafe impl NSObjectProtocol for UIShapeResolutionContext {}
);
impl UIShapeResolutionContext {
extern_methods!(
/// The resolved shape of the content to which this shape may be
/// applied. For example, if this shape will be used to apply an effect
/// to a button, the `contentShape` could represent the bounding shape
/// of that button's background. You should typically size a dynamic
/// shape relative to the bounding `rect` of the `contentShape`.
#[unsafe(method(contentShape))]
#[unsafe(method_family = none)]
pub fn contentShape(&self) -> Retained<UIResolvedShape>;
#[unsafe(method(init))]
#[unsafe(method_family = init)]
pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
#[unsafe(method(new))]
#[unsafe(method_family = new)]
pub unsafe fn new() -> Retained<Self>;
);
}