objc2_ui_kit/generated/UIHoverEffectLayer.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::*;
6use objc2_foundation::*;
7#[cfg(feature = "objc2-quartz-core")]
8#[cfg(not(target_os = "watchos"))]
9use objc2_quartz_core::*;
10
11use crate::*;
12
13extern_class!(
14 /// A layer type that can be used to apply a hover effect to its sublayers.
15 ///
16 /// This layer type is useful for adding hover effects to an existing
17 /// ``CALayer`` hierarchy. Where possible, use ``UIView.hoverStyle`` instead.
18 ///
19 /// A ``UIHoverEffectLayer`` is configured with:
20 ///
21 /// 1. A container ``UIView``, which is used to infer some properties of the
22 /// hover effect from its trait collection and to allow some aspects of the
23 /// hover effect to behave correctly. This view's layer should be an ancestor
24 /// layer of the ``UIHoverEffectLayer``.
25 /// 2. A ``UIHoverStyle``, which describes the effect to use and the shape of
26 /// that effect. You then add your content layers that should receive a hover
27 /// effect as sublayers of this layer.
28 ///
29 /// ``UIHoverEffectLayer`` may add its own internal sublayers as background or
30 /// overlay layers relative to your content sublayers. To preserve the correct
31 /// appearance of the effect, these internal sublayers are automatically sorted
32 /// accordingly within the layer's layout pass. As such, do not assume that the
33 /// indices of your content sublayers will remain stable throughout the lifetime
34 /// of the layer.
35 ///
36 /// - Note: Not all ``UIHoverStyle``s may be supported by
37 /// ``UIHoverEffectLayer``. If the provided style is not supported, a fallback
38 /// style will be selected instead.
39 ///
40 /// See also [Apple's documentation](https://developer.apple.com/documentation/uikit/uihovereffectlayer?language=objc)
41 #[unsafe(super(CALayer, NSObject))]
42 #[thread_kind = MainThreadOnly]
43 #[derive(Debug, PartialEq, Eq, Hash)]
44 #[cfg(feature = "objc2-quartz-core")]
45 #[cfg(not(target_os = "watchos"))]
46 pub struct UIHoverEffectLayer;
47);
48
49#[cfg(feature = "objc2-quartz-core")]
50#[cfg(not(target_os = "watchos"))]
51extern_conformance!(
52 unsafe impl CAMediaTiming for UIHoverEffectLayer {}
53);
54
55#[cfg(feature = "objc2-quartz-core")]
56#[cfg(not(target_os = "watchos"))]
57extern_conformance!(
58 unsafe impl NSCoding for UIHoverEffectLayer {}
59);
60
61#[cfg(feature = "objc2-quartz-core")]
62#[cfg(not(target_os = "watchos"))]
63extern_conformance!(
64 unsafe impl NSObjectProtocol for UIHoverEffectLayer {}
65);
66
67#[cfg(feature = "objc2-quartz-core")]
68#[cfg(not(target_os = "watchos"))]
69extern_conformance!(
70 unsafe impl NSSecureCoding for UIHoverEffectLayer {}
71);
72
73#[cfg(feature = "objc2-quartz-core")]
74#[cfg(not(target_os = "watchos"))]
75impl UIHoverEffectLayer {
76 extern_methods!(
77 #[cfg(feature = "UIHoverStyle")]
78 /// The hover style to apply to the sublayers of this layer when this layer
79 /// is hovered (e.g., when the user looks at this layer). Defaults to the
80 /// automatic style.
81 ///
82 /// - Note: Not all ``UIHoverStyle``s may be supported by
83 /// ``UIHoverEffectLayer``. If the provided style is not supported, a fallback
84 /// style will be selected instead.
85 #[unsafe(method(hoverStyle))]
86 #[unsafe(method_family = none)]
87 pub fn hoverStyle(&self) -> Retained<UIHoverStyle>;
88
89 #[cfg(feature = "UIHoverStyle")]
90 /// Setter for [`hoverStyle`][Self::hoverStyle].
91 ///
92 /// This is [copied][objc2_foundation::NSCopying::copy] when set.
93 #[unsafe(method(setHoverStyle:))]
94 #[unsafe(method_family = none)]
95 pub fn setHoverStyle(&self, hover_style: &UIHoverStyle);
96
97 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
98 /// The ``UIView`` in which this layer is contained. This view is used to
99 /// derive traits and other properties for applying the correct hover effect
100 /// to the layer. It may also be used to assist with applying some kinds of
101 /// hover effects to the layer.
102 ///
103 /// The ``containerView`` should be an ancestor of this layer (once it has
104 /// been added to a layer hierarchy) to behave correctly, but does not need
105 /// to be the immediate parent of this layer. If the ``containerView`` is
106 /// set to nil or is deallocated, some aspects of this layer's hover effect
107 /// may no longer work correctly.
108 #[unsafe(method(containerView))]
109 #[unsafe(method_family = none)]
110 pub fn containerView(&self) -> Option<Retained<UIView>>;
111
112 #[cfg(all(feature = "UIResponder", feature = "UIView"))]
113 /// Setter for [`containerView`][Self::containerView].
114 ///
115 /// This is a [weak property][objc2::topics::weak_property].
116 #[unsafe(method(setContainerView:))]
117 #[unsafe(method_family = none)]
118 pub fn setContainerView(&self, container_view: Option<&UIView>);
119
120 #[cfg(all(feature = "UIHoverStyle", feature = "UIResponder", feature = "UIView"))]
121 /// Creates a ``UIHoverEffectLayer`` with the provided `containerView`
122 /// and `style`. If a `nil` `style` is provided, the automatic style will
123 /// be used instead.
124 #[unsafe(method(initWithContainerView:style:))]
125 #[unsafe(method_family = init)]
126 pub fn initWithContainerView_style(
127 this: Allocated<Self>,
128 container_view: &UIView,
129 style: Option<&UIHoverStyle>,
130 ) -> Retained<Self>;
131 );
132}
133
134/// Methods declared on superclass `CALayer`.
135#[cfg(feature = "objc2-quartz-core")]
136#[cfg(not(target_os = "watchos"))]
137impl UIHoverEffectLayer {
138 extern_methods!(
139 /// Layer creation and initialization. *
140 #[unsafe(method(layer))]
141 #[unsafe(method_family = none)]
142 pub fn layer(mtm: MainThreadMarker) -> Retained<Self>;
143
144 #[unsafe(method(init))]
145 #[unsafe(method_family = init)]
146 pub fn init(this: Allocated<Self>) -> Retained<Self>;
147
148 /// # Safety
149 ///
150 /// `layer` should be of the correct type.
151 #[unsafe(method(initWithLayer:))]
152 #[unsafe(method_family = init)]
153 pub unsafe fn initWithLayer(this: Allocated<Self>, layer: &AnyObject) -> Retained<Self>;
154 );
155}
156
157/// Methods declared on superclass `NSObject`.
158#[cfg(feature = "objc2-quartz-core")]
159#[cfg(not(target_os = "watchos"))]
160impl UIHoverEffectLayer {
161 extern_methods!(
162 #[unsafe(method(new))]
163 #[unsafe(method_family = new)]
164 pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
165 );
166}