1use crate::{api, arc, ca, cf, cg, define_obj_type, define_opts, ns, objc};
2
3define_obj_type!(
4 #[doc(alias = "CALayerContentsGravity")]
5 pub ContentsGravity(ns::String)
6);
7
8define_obj_type!(
9 #[doc(alias = "CALayerContentsFormat")]
10 pub ContentsFormat(ns::String)
11);
12
13define_obj_type!(
14 #[doc(alias = "CALayerContentsFilter")]
15 pub ContentsFilter(ns::String)
16);
17
18define_obj_type!(
19 #[doc(alias = "CALayerCornerCurve")]
20 pub CornerCurve(ns::String)
21);
22
23define_obj_type!(
24 #[doc(alias = "CALayer.ToneMapMode")]
27 #[doc(alias = "CAToneMapMode")]
28 pub ToneMapMode(ns::String)
29);
30
31impl ToneMapMode {
32 #[api::available(
34 macos = 15.0,
35 maccatalyst = 18.0,
36 ios = 18.0,
37 tvos = 18.0,
38 visionos = 2.0
39 )]
40 pub fn automatic() -> &'static Self {
41 unsafe { CAToneMapModeAutomatic }
42 }
43
44 #[api::available(
46 macos = 15.0,
47 maccatalyst = 18.0,
48 ios = 18.0,
49 tvos = 18.0,
50 visionos = 2.0
51 )]
52 pub fn never() -> &'static Self {
53 unsafe { CAToneMapModeNever }
54 }
55
56 #[api::available(
60 macos = 15.0,
61 maccatalyst = 18.0,
62 ios = 18.0,
63 tvos = 18.0,
64 visionos = 2.0
65 )]
66 pub fn if_supported() -> &'static Self {
67 unsafe { CAToneMapModeIfSupported }
68 }
69}
70
71define_opts!(
72 #[doc(alias = "CAAutoresizingMask")]
73 pub AutoresizingMask(u32)
74);
75
76impl AutoresizingMask {
77 pub const NOT_SIZABLE: Self = Self(0);
78 pub const MIN_X_MARGIN: Self = Self(1 << 0);
79 pub const WIDTH_SIZABLE: Self = Self(1 << 1);
80 pub const MAX_X_MARGIN: Self = Self(1 << 2);
81 pub const MIN_Y_MARGIN: Self = Self(1 << 3);
82 pub const HEIGHT_SIZABLE: Self = Self(1 << 4);
83 pub const MAX_Y_MARGIN: Self = Self(1 << 5);
84}
85
86define_opts!(
87 #[doc(alias = "CAEdgeAntialiasingMask")]
88 pub EdgeAntialiasingMask(u32)
89);
90
91impl EdgeAntialiasingMask {
92 pub const LEFT: Self = Self(1 << 0);
94
95 pub const RIGHT: Self = Self(1 << 1);
97
98 pub const BOTTOM: Self = Self(1 << 2);
100
101 pub const TOP: Self = Self(1 << 3);
103}
104
105define_opts!(
106 #[doc(alias = "CACornerMask")]
107 pub CornerMask(usize)
108);
109impl CornerMask {
110 pub const MIN_X_MIN_Y: Self = Self(1 << 0);
111 pub const MAX_X_MIN_Y: Self = Self(1 << 1);
112 pub const MIN_X_MAX_Y: Self = Self(1 << 2);
113 pub const MAX_X_MAX_Y: Self = Self(1 << 3);
114}
115
116define_obj_type!(
117 #[doc(alias = "CALayer")]
118 pub Layer(ns::Id),
119 CA_LAYER
120);
121
122impl Layer {
123 #[objc::msg_send(bounds)]
124 pub fn bounds(&self) -> cg::Rect;
125
126 #[objc::msg_send(setBounds:)]
127 pub fn set_bounds(&mut self, val: cg::Rect);
128
129 #[objc::msg_send(position)]
130 pub fn pos(&self) -> cg::Point;
131
132 #[objc::msg_send(setPosition:)]
133 pub fn set_pos(&mut self, val: cg::Point);
134
135 #[objc::msg_send(zPosition)]
136 pub fn z_pos(&self) -> cg::Float;
137
138 #[objc::msg_send(setZPosition:)]
139 pub fn set_z_pos(&mut self, val: cg::Float);
140
141 #[objc::msg_send(anchorPoint)]
142 pub fn anchor_point(&self) -> cg::Point;
143
144 #[objc::msg_send(setAnchorPoint:)]
145 pub fn set_anchor_point(&mut self, val: cg::Point);
146
147 #[objc::msg_send(transform)]
148 pub fn transform(&self) -> ca::Transform3d;
149
150 #[objc::msg_send(setTransform:)]
151 pub fn set_transform(&mut self, val: ca::Transform3d);
152
153 #[objc::msg_send(affineTransform)]
155 pub fn affine_transform(&self) -> cg::AffineTransform;
156
157 #[objc::msg_send(setAffineTransform:)]
158 pub fn set_affine_transform(&self, val: cg::AffineTransform);
159
160 #[objc::msg_send(frame)]
161 pub fn frame(&self) -> cg::Rect;
162
163 #[objc::msg_send(setFrame:)]
164 pub fn set_frame(&mut self, val: cg::Rect);
165
166 #[objc::msg_send(isHidden)]
167 pub fn is_hidden(&self) -> bool;
168
169 #[objc::msg_send(setHidden:)]
170 pub fn set_hidden(&mut self, val: bool);
171
172 #[objc::msg_send(addSublayer:)]
173 pub fn add_sublayer(&mut self, layer: &Self);
174
175 #[objc::msg_send(insertSublayer:atIndex:)]
176 pub fn insert_sublayer_at(&mut self, layer: &Self, index: u32);
177
178 #[objc::msg_send(name)]
179 pub fn name(&self) -> Option<arc::R<ns::String>>;
180
181 #[objc::msg_send(setName:)]
182 pub fn set_name(&mut self, val: Option<&ns::String>);
183
184 #[objc::msg_send(delegate)]
185 pub fn delegate(&self) -> Option<arc::R<AnyLayerDelegate>>;
186
187 #[objc::msg_send(setDelegate:)]
188 pub fn set_delegate<D: LayerDelegate>(&mut self, val: Option<&D>);
189
190 #[objc::msg_send(needsLayout)]
191 pub fn needs_layout(&self) -> bool;
192
193 #[objc::msg_send(setNeedsLayout)]
194 pub fn set_needs_layout(&mut self);
195
196 #[objc::msg_send(layoutIfNeeded)]
197 pub fn layout_if_needed(&mut self);
198
199 #[objc::msg_send(layoutSublayers)]
200 pub fn layout_sublayers(&self);
201
202 #[objc::msg_send(resizeSublayersWithOldSize:)]
203 pub fn resize_sublayers_with_old_size(&self, size: cg::Size);
204
205 #[objc::msg_send(resizeWithOldSuperlayerSize:)]
206 pub fn resize_with_old_superlayer_size(&self, size: cg::Size);
207
208 #[objc::msg_send(removeAllAnimations)]
209 pub fn remove_all_animations(&mut self);
210
211 #[objc::msg_send(removeAnimationForKey:)]
212 pub fn remove_animation_for_key(&mut self, key: &ns::String);
213
214 #[objc::msg_send(animationKeys)]
215 pub fn animation_keys(&self) -> Option<arc::R<ns::Array<ns::String>>>;
216
217 #[objc::msg_send(contents)]
218 pub fn contents(&self) -> Option<arc::R<ns::Id>>;
219
220 #[objc::msg_send(setContents:)]
221 pub fn set_ns_contents(&mut self, contents: Option<&ns::Id>);
222
223 #[objc::msg_send(setContents:)]
224 pub fn set_cf_contents(&mut self, contents: Option<&cf::Type>);
225
226 #[objc::msg_send(contentsRect)]
227 pub fn contents_rect(&self) -> cg::Rect;
228
229 #[objc::msg_send(setContentsRect:)]
230 pub fn set_contents_rect(&mut self, val: cg::Rect);
231
232 #[objc::msg_send(contentsGravity)]
233 pub fn contents_gravity(&self) -> arc::R<ContentsGravity>;
234
235 #[objc::msg_send(setContentsGravity:)]
236 pub fn set_contents_gravity(&mut self, val: &ContentsGravity);
237
238 #[objc::msg_send(contentsScale)]
239 pub fn contents_scale(&self) -> cg::Float;
240
241 #[objc::msg_send(setContentsScale:)]
242 pub fn set_contents_scale(&mut self, val: cg::Float);
243
244 #[objc::msg_send(contentsCenter)]
245 pub fn contents_center(&self) -> cg::Rect;
246
247 #[objc::msg_send(setContentsCenter:)]
248 pub fn set_contents_center(&mut self, val: cg::Rect);
249
250 #[objc::msg_send(contentsFormat)]
251 pub fn contents_format(&self) -> arc::R<ContentsFormat>;
252
253 #[objc::msg_send(setContentsFormat:)]
254 pub fn set_contents_format(&mut self, val: &ContentsFormat);
255
256 #[objc::msg_send(toneMapMode)]
257 #[api::available(
258 macos = 15.0,
259 maccatalyst = 18.0,
260 ios = 18.0,
261 tvos = 18.0,
262 visionos = 2.0
263 )]
264 pub fn tone_map_mode(&self) -> arc::R<ToneMapMode>;
265
266 #[objc::msg_send(setToneMapMode:)]
267 #[api::available(
268 macos = 15.0,
269 maccatalyst = 18.0,
270 ios = 18.0,
271 tvos = 18.0,
272 visionos = 2.0
273 )]
274 pub fn set_tone_map_mode(&mut self, val: &ToneMapMode);
275
276 #[objc::msg_send(wantsExtendedDynamicRangeContent)]
277 pub fn wants_extended_dynamic_range_content(&self) -> bool;
278
279 #[objc::msg_send(setWantsExtendedDynamicRangeContent:)]
280 pub fn set_wants_extended_dynamic_range_content(&mut self, val: bool);
281}
282
283#[objc::protocol(CAAction)]
284pub trait Action: objc::Obj {
285 #[objc::msg_send(runActionForKey:object:arguments:)]
286 fn run_action_for_key(
287 &mut self,
288 event: &ns::String,
289 obj: &ns::Id,
290 args: Option<&ns::Dictionary<ns::String, ns::Id>>,
291 );
292}
293
294impl Action for ns::Null {}
295
296define_obj_type!(
297 pub AnyAction(ns::Id)
298);
299
300impl Action for AnyAction {}
301
302#[objc::protocol(CALayerDelegate)]
303pub trait LayerDelegate: objc::Obj {
304 #[objc::optional]
305 #[objc::msg_send(displayLayer:)]
306 fn display_layer(&mut self, layer: &mut Layer);
307
308 #[objc::optional]
309 #[objc::msg_send(drawLayer:inContext:)]
310 fn draw_layer(&mut self, layer: &mut Layer, context: &mut cg::Context);
311
312 #[objc::optional]
313 #[objc::msg_send(layerWillDraw:)]
314 fn layer_will_draw(&mut self, layer: &mut Layer);
315
316 #[objc::optional]
317 #[objc::msg_send(layoutSublayersOfLayer:)]
318 fn layout_sublayers_of_layer(&mut self, layer: &mut Layer);
319
320 #[objc::optional]
321 #[objc::msg_send(actionForLayer:forKey:)]
322 fn action_for_layer_for_key(
323 &mut self,
324 layer: &mut Layer,
325 key: &ns::String,
326 ) -> Option<arc::R<AnyAction>>;
327}
328
329define_obj_type!(
330 pub AnyLayerDelegate(ns::Id)
331);
332
333impl LayerDelegate for AnyLayerDelegate {}
334
335unsafe extern "C" {
336 static CA_LAYER: &'static objc::Class<Layer>;
337}
338
339#[api::weak]
340unsafe extern "C" {
341 #[api::available(
342 macos = 15.0,
343 maccatalyst = 18.0,
344 ios = 18.0,
345 tvos = 18.0,
346 visionos = 2.0
347 )]
348 static CAToneMapModeAutomatic: &'static ToneMapMode;
349
350 #[api::available(
351 macos = 15.0,
352 maccatalyst = 18.0,
353 ios = 18.0,
354 tvos = 18.0,
355 visionos = 2.0
356 )]
357 static CAToneMapModeNever: &'static ToneMapMode;
358
359 #[api::available(
360 macos = 15.0,
361 maccatalyst = 18.0,
362 ios = 18.0,
363 tvos = 18.0,
364 visionos = 2.0
365 )]
366 static CAToneMapModeIfSupported: &'static ToneMapMode;
367}