objc2_app_kit/generated/
NSImageView.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
8use crate::*;
9
10/// Values that can be used to enable or constrain display of High Dynamic Range (HDR) content in NSImageViews. Displaying HDR content in an NSImageView requires that the assigned NSImage has HDR content in the ITU-R 2100 color space and also that the output device has Extended Dynamic Range (EDR) capabilities.
11///
12/// See also [Apple's documentation](https://developer.apple.com/documentation/appkit/nsimagedynamicrange?language=objc)
13// NS_ENUM
14#[repr(transparent)]
15#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
16pub struct NSImageDynamicRange(pub NSInteger);
17impl NSImageDynamicRange {
18    #[doc(alias = "NSImageDynamicRangeUnspecified")]
19    pub const Unspecified: Self = Self(-1);
20    /// Restrict the image content dynamic range to the standard range regardless of the actual range of the image content.
21    #[doc(alias = "NSImageDynamicRangeStandard")]
22    pub const Standard: Self = Self(0);
23    /// Allow constrained HDR image content. Useful when mixing HDR and SDR content.
24    #[doc(alias = "NSImageDynamicRangeConstrainedHigh")]
25    pub const ConstrainedHigh: Self = Self(1);
26    /// Allow image content to use extended dynamic range if it has high dynamic range content.
27    #[doc(alias = "NSImageDynamicRangeHigh")]
28    pub const High: Self = Self(2);
29}
30
31unsafe impl Encode for NSImageDynamicRange {
32    const ENCODING: Encoding = NSInteger::ENCODING;
33}
34
35unsafe impl RefEncode for NSImageDynamicRange {
36    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
37}
38
39extern_class!(
40    /// [Apple's documentation](https://developer.apple.com/documentation/appkit/nsimageview?language=objc)
41    #[unsafe(super(NSControl, NSView, NSResponder, NSObject))]
42    #[derive(Debug, PartialEq, Eq, Hash)]
43    #[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
44    pub struct NSImageView;
45);
46
47#[cfg(all(
48    feature = "NSAccessibilityProtocols",
49    feature = "NSControl",
50    feature = "NSResponder",
51    feature = "NSView"
52))]
53extern_conformance!(
54    unsafe impl NSAccessibility for NSImageView {}
55);
56
57#[cfg(all(
58    feature = "NSAccessibilityProtocols",
59    feature = "NSControl",
60    feature = "NSResponder",
61    feature = "NSView"
62))]
63extern_conformance!(
64    unsafe impl NSAccessibilityElementProtocol for NSImageView {}
65);
66
67#[cfg(all(
68    feature = "NSAccessibilityProtocols",
69    feature = "NSControl",
70    feature = "NSResponder",
71    feature = "NSView"
72))]
73extern_conformance!(
74    unsafe impl NSAccessibilityImage for NSImageView {}
75);
76
77#[cfg(all(
78    feature = "NSAnimation",
79    feature = "NSControl",
80    feature = "NSResponder",
81    feature = "NSView"
82))]
83extern_conformance!(
84    unsafe impl NSAnimatablePropertyContainer for NSImageView {}
85);
86
87#[cfg(all(
88    feature = "NSAppearance",
89    feature = "NSControl",
90    feature = "NSResponder",
91    feature = "NSView"
92))]
93extern_conformance!(
94    unsafe impl NSAppearanceCustomization for NSImageView {}
95);
96
97#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
98extern_conformance!(
99    unsafe impl NSCoding for NSImageView {}
100);
101
102#[cfg(all(
103    feature = "NSControl",
104    feature = "NSDragging",
105    feature = "NSResponder",
106    feature = "NSView"
107))]
108extern_conformance!(
109    unsafe impl NSDraggingDestination for NSImageView {}
110);
111
112#[cfg(all(
113    feature = "NSControl",
114    feature = "NSMenu",
115    feature = "NSResponder",
116    feature = "NSView"
117))]
118extern_conformance!(
119    unsafe impl NSMenuItemValidation for NSImageView {}
120);
121
122#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
123extern_conformance!(
124    unsafe impl NSObjectProtocol for NSImageView {}
125);
126
127#[cfg(all(
128    feature = "NSControl",
129    feature = "NSResponder",
130    feature = "NSUserInterfaceItemIdentification",
131    feature = "NSView"
132))]
133extern_conformance!(
134    unsafe impl NSUserInterfaceItemIdentification for NSImageView {}
135);
136
137#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
138impl NSImageView {
139    extern_methods!(
140        #[cfg(feature = "NSImage")]
141        /// Creates a non-editable image view containing the provided image. The image is scaled proportionally down to fit the view, and is centered within the view.
142        ///
143        /// Parameter `image`: The image to display within the view.
144        ///
145        /// Returns: An initialized image view.
146        #[unsafe(method(imageViewWithImage:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn imageViewWithImage(image: &NSImage, mtm: MainThreadMarker) -> Retained<Self>;
149
150        #[cfg(feature = "NSImage")]
151        #[unsafe(method(image))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
154
155        #[cfg(feature = "NSImage")]
156        /// Setter for [`image`][Self::image].
157        #[unsafe(method(setImage:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setImage(&self, image: Option<&NSImage>);
160
161        #[unsafe(method(isEditable))]
162        #[unsafe(method_family = none)]
163        pub unsafe fn isEditable(&self) -> bool;
164
165        /// Setter for [`isEditable`][Self::isEditable].
166        #[unsafe(method(setEditable:))]
167        #[unsafe(method_family = none)]
168        pub unsafe fn setEditable(&self, editable: bool);
169
170        #[cfg(feature = "NSImageCell")]
171        #[unsafe(method(imageAlignment))]
172        #[unsafe(method_family = none)]
173        pub unsafe fn imageAlignment(&self) -> NSImageAlignment;
174
175        #[cfg(feature = "NSImageCell")]
176        /// Setter for [`imageAlignment`][Self::imageAlignment].
177        #[unsafe(method(setImageAlignment:))]
178        #[unsafe(method_family = none)]
179        pub unsafe fn setImageAlignment(&self, image_alignment: NSImageAlignment);
180
181        #[cfg(feature = "NSCell")]
182        #[unsafe(method(imageScaling))]
183        #[unsafe(method_family = none)]
184        pub unsafe fn imageScaling(&self) -> NSImageScaling;
185
186        #[cfg(feature = "NSCell")]
187        /// Setter for [`imageScaling`][Self::imageScaling].
188        #[unsafe(method(setImageScaling:))]
189        #[unsafe(method_family = none)]
190        pub unsafe fn setImageScaling(&self, image_scaling: NSImageScaling);
191
192        #[cfg(feature = "NSImageCell")]
193        #[unsafe(method(imageFrameStyle))]
194        #[unsafe(method_family = none)]
195        pub unsafe fn imageFrameStyle(&self) -> NSImageFrameStyle;
196
197        #[cfg(feature = "NSImageCell")]
198        /// Setter for [`imageFrameStyle`][Self::imageFrameStyle].
199        #[unsafe(method(setImageFrameStyle:))]
200        #[unsafe(method_family = none)]
201        pub unsafe fn setImageFrameStyle(&self, image_frame_style: NSImageFrameStyle);
202
203        #[cfg(feature = "NSImage")]
204        /// Specifies a combination of point size, weight, and scale to use when sizing and displaying symbol images. If a symbol configuration isn't provided, the image view uses a default size, weight, and scale provided by the system. The default value is `nil`.
205        #[unsafe(method(symbolConfiguration))]
206        #[unsafe(method_family = none)]
207        pub unsafe fn symbolConfiguration(&self) -> Option<Retained<NSImageSymbolConfiguration>>;
208
209        #[cfg(feature = "NSImage")]
210        /// Setter for [`symbolConfiguration`][Self::symbolConfiguration].
211        #[unsafe(method(setSymbolConfiguration:))]
212        #[unsafe(method_family = none)]
213        pub unsafe fn setSymbolConfiguration(
214            &self,
215            symbol_configuration: Option<&NSImageSymbolConfiguration>,
216        );
217
218        #[cfg(feature = "NSColor")]
219        /// A tint color to be used when rendering template image content. This color may be combined with other effects to produce a theme-appropriate rendition of the template image. A nil value indicates the standard set of effects without color modification. The default value is nil.
220        #[unsafe(method(contentTintColor))]
221        #[unsafe(method_family = none)]
222        pub unsafe fn contentTintColor(&self) -> Option<Retained<NSColor>>;
223
224        #[cfg(feature = "NSColor")]
225        /// Setter for [`contentTintColor`][Self::contentTintColor].
226        #[unsafe(method(setContentTintColor:))]
227        #[unsafe(method_family = none)]
228        pub unsafe fn setContentTintColor(&self, content_tint_color: Option<&NSColor>);
229
230        #[unsafe(method(animates))]
231        #[unsafe(method_family = none)]
232        pub unsafe fn animates(&self) -> bool;
233
234        /// Setter for [`animates`][Self::animates].
235        #[unsafe(method(setAnimates:))]
236        #[unsafe(method_family = none)]
237        pub unsafe fn setAnimates(&self, animates: bool);
238
239        #[unsafe(method(allowsCutCopyPaste))]
240        #[unsafe(method_family = none)]
241        pub unsafe fn allowsCutCopyPaste(&self) -> bool;
242
243        /// Setter for [`allowsCutCopyPaste`][Self::allowsCutCopyPaste].
244        #[unsafe(method(setAllowsCutCopyPaste:))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn setAllowsCutCopyPaste(&self, allows_cut_copy_paste: bool);
247
248        /// Default preferred image dynamic range. Defaults to `NSImageDynamicRangeConstrainedHigh` on macOS 14 and higher, `NSImageDynamicRangeStandard` otherwise. Set to another value to change the default for all subsequently created `NSImageView`s in your app.
249        #[unsafe(method(defaultPreferredImageDynamicRange))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn defaultPreferredImageDynamicRange(
252            mtm: MainThreadMarker,
253        ) -> NSImageDynamicRange;
254
255        /// Setter for [`defaultPreferredImageDynamicRange`][Self::defaultPreferredImageDynamicRange].
256        #[unsafe(method(setDefaultPreferredImageDynamicRange:))]
257        #[unsafe(method_family = none)]
258        pub unsafe fn setDefaultPreferredImageDynamicRange(
259            default_preferred_image_dynamic_range: NSImageDynamicRange,
260            mtm: MainThreadMarker,
261        );
262
263        /// Preferred dynamic range when displaying an image in the receiving image view.
264        #[unsafe(method(preferredImageDynamicRange))]
265        #[unsafe(method_family = none)]
266        pub unsafe fn preferredImageDynamicRange(&self) -> NSImageDynamicRange;
267
268        /// Setter for [`preferredImageDynamicRange`][Self::preferredImageDynamicRange].
269        #[unsafe(method(setPreferredImageDynamicRange:))]
270        #[unsafe(method_family = none)]
271        pub unsafe fn setPreferredImageDynamicRange(
272            &self,
273            preferred_image_dynamic_range: NSImageDynamicRange,
274        );
275
276        /// Resolved dynamic range based on fully resolved image content. Note: this will return `NSImageDynamicRangeUnspecified` if the image view has not or can not resolve the content (either because it has no resolvable image content or has not resolved because the image view hasn't displayed.)
277        #[unsafe(method(imageDynamicRange))]
278        #[unsafe(method_family = none)]
279        pub unsafe fn imageDynamicRange(&self) -> NSImageDynamicRange;
280    );
281}
282
283/// Methods declared on superclass `NSControl`.
284#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
285impl NSImageView {
286    extern_methods!(
287        #[unsafe(method(initWithFrame:))]
288        #[unsafe(method_family = init)]
289        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
290
291        #[unsafe(method(initWithCoder:))]
292        #[unsafe(method_family = init)]
293        pub unsafe fn initWithCoder(
294            this: Allocated<Self>,
295            coder: &NSCoder,
296        ) -> Option<Retained<Self>>;
297    );
298}
299
300/// Methods declared on superclass `NSResponder`.
301#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
302impl NSImageView {
303    extern_methods!(
304        #[unsafe(method(init))]
305        #[unsafe(method_family = init)]
306        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
307    );
308}
309
310/// Methods declared on superclass `NSObject`.
311#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
312impl NSImageView {
313    extern_methods!(
314        #[unsafe(method(new))]
315        #[unsafe(method_family = new)]
316        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
317    );
318}