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))]
53unsafe impl NSAccessibility for NSImageView {}
54
55#[cfg(all(
56    feature = "NSAccessibilityProtocols",
57    feature = "NSControl",
58    feature = "NSResponder",
59    feature = "NSView"
60))]
61unsafe impl NSAccessibilityElementProtocol for NSImageView {}
62
63#[cfg(all(
64    feature = "NSAccessibilityProtocols",
65    feature = "NSControl",
66    feature = "NSResponder",
67    feature = "NSView"
68))]
69unsafe impl NSAccessibilityImage for NSImageView {}
70
71#[cfg(all(
72    feature = "NSAnimation",
73    feature = "NSControl",
74    feature = "NSResponder",
75    feature = "NSView"
76))]
77unsafe impl NSAnimatablePropertyContainer for NSImageView {}
78
79#[cfg(all(
80    feature = "NSAppearance",
81    feature = "NSControl",
82    feature = "NSResponder",
83    feature = "NSView"
84))]
85unsafe impl NSAppearanceCustomization for NSImageView {}
86
87#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
88unsafe impl NSCoding for NSImageView {}
89
90#[cfg(all(
91    feature = "NSControl",
92    feature = "NSDragging",
93    feature = "NSResponder",
94    feature = "NSView"
95))]
96unsafe impl NSDraggingDestination for NSImageView {}
97
98#[cfg(all(
99    feature = "NSControl",
100    feature = "NSMenu",
101    feature = "NSResponder",
102    feature = "NSView"
103))]
104unsafe impl NSMenuItemValidation for NSImageView {}
105
106#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
107unsafe impl NSObjectProtocol for NSImageView {}
108
109#[cfg(all(
110    feature = "NSControl",
111    feature = "NSResponder",
112    feature = "NSUserInterfaceItemIdentification",
113    feature = "NSView"
114))]
115unsafe impl NSUserInterfaceItemIdentification for NSImageView {}
116
117#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
118impl NSImageView {
119    extern_methods!(
120        #[cfg(feature = "NSImage")]
121        /// 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.
122        ///
123        /// Parameter `image`: The image to display within the view.
124        ///
125        /// Returns: An initialized image view.
126        #[unsafe(method(imageViewWithImage:))]
127        #[unsafe(method_family = none)]
128        pub unsafe fn imageViewWithImage(image: &NSImage, mtm: MainThreadMarker) -> Retained<Self>;
129
130        #[cfg(feature = "NSImage")]
131        #[unsafe(method(image))]
132        #[unsafe(method_family = none)]
133        pub unsafe fn image(&self) -> Option<Retained<NSImage>>;
134
135        #[cfg(feature = "NSImage")]
136        /// Setter for [`image`][Self::image].
137        #[unsafe(method(setImage:))]
138        #[unsafe(method_family = none)]
139        pub unsafe fn setImage(&self, image: Option<&NSImage>);
140
141        #[unsafe(method(isEditable))]
142        #[unsafe(method_family = none)]
143        pub unsafe fn isEditable(&self) -> bool;
144
145        /// Setter for [`isEditable`][Self::isEditable].
146        #[unsafe(method(setEditable:))]
147        #[unsafe(method_family = none)]
148        pub unsafe fn setEditable(&self, editable: bool);
149
150        #[cfg(feature = "NSImageCell")]
151        #[unsafe(method(imageAlignment))]
152        #[unsafe(method_family = none)]
153        pub unsafe fn imageAlignment(&self) -> NSImageAlignment;
154
155        #[cfg(feature = "NSImageCell")]
156        /// Setter for [`imageAlignment`][Self::imageAlignment].
157        #[unsafe(method(setImageAlignment:))]
158        #[unsafe(method_family = none)]
159        pub unsafe fn setImageAlignment(&self, image_alignment: NSImageAlignment);
160
161        #[cfg(feature = "NSCell")]
162        #[unsafe(method(imageScaling))]
163        #[unsafe(method_family = none)]
164        pub unsafe fn imageScaling(&self) -> NSImageScaling;
165
166        #[cfg(feature = "NSCell")]
167        /// Setter for [`imageScaling`][Self::imageScaling].
168        #[unsafe(method(setImageScaling:))]
169        #[unsafe(method_family = none)]
170        pub unsafe fn setImageScaling(&self, image_scaling: NSImageScaling);
171
172        #[cfg(feature = "NSImageCell")]
173        #[unsafe(method(imageFrameStyle))]
174        #[unsafe(method_family = none)]
175        pub unsafe fn imageFrameStyle(&self) -> NSImageFrameStyle;
176
177        #[cfg(feature = "NSImageCell")]
178        /// Setter for [`imageFrameStyle`][Self::imageFrameStyle].
179        #[unsafe(method(setImageFrameStyle:))]
180        #[unsafe(method_family = none)]
181        pub unsafe fn setImageFrameStyle(&self, image_frame_style: NSImageFrameStyle);
182
183        #[cfg(feature = "NSImage")]
184        /// 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`.
185        #[unsafe(method(symbolConfiguration))]
186        #[unsafe(method_family = none)]
187        pub unsafe fn symbolConfiguration(&self) -> Option<Retained<NSImageSymbolConfiguration>>;
188
189        #[cfg(feature = "NSImage")]
190        /// Setter for [`symbolConfiguration`][Self::symbolConfiguration].
191        #[unsafe(method(setSymbolConfiguration:))]
192        #[unsafe(method_family = none)]
193        pub unsafe fn setSymbolConfiguration(
194            &self,
195            symbol_configuration: Option<&NSImageSymbolConfiguration>,
196        );
197
198        #[cfg(feature = "NSColor")]
199        /// 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.
200        #[unsafe(method(contentTintColor))]
201        #[unsafe(method_family = none)]
202        pub unsafe fn contentTintColor(&self) -> Option<Retained<NSColor>>;
203
204        #[cfg(feature = "NSColor")]
205        /// Setter for [`contentTintColor`][Self::contentTintColor].
206        #[unsafe(method(setContentTintColor:))]
207        #[unsafe(method_family = none)]
208        pub unsafe fn setContentTintColor(&self, content_tint_color: Option<&NSColor>);
209
210        #[unsafe(method(animates))]
211        #[unsafe(method_family = none)]
212        pub unsafe fn animates(&self) -> bool;
213
214        /// Setter for [`animates`][Self::animates].
215        #[unsafe(method(setAnimates:))]
216        #[unsafe(method_family = none)]
217        pub unsafe fn setAnimates(&self, animates: bool);
218
219        #[unsafe(method(allowsCutCopyPaste))]
220        #[unsafe(method_family = none)]
221        pub unsafe fn allowsCutCopyPaste(&self) -> bool;
222
223        /// Setter for [`allowsCutCopyPaste`][Self::allowsCutCopyPaste].
224        #[unsafe(method(setAllowsCutCopyPaste:))]
225        #[unsafe(method_family = none)]
226        pub unsafe fn setAllowsCutCopyPaste(&self, allows_cut_copy_paste: bool);
227
228        /// 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.
229        #[unsafe(method(defaultPreferredImageDynamicRange))]
230        #[unsafe(method_family = none)]
231        pub unsafe fn defaultPreferredImageDynamicRange(
232            mtm: MainThreadMarker,
233        ) -> NSImageDynamicRange;
234
235        /// Setter for [`defaultPreferredImageDynamicRange`][Self::defaultPreferredImageDynamicRange].
236        #[unsafe(method(setDefaultPreferredImageDynamicRange:))]
237        #[unsafe(method_family = none)]
238        pub unsafe fn setDefaultPreferredImageDynamicRange(
239            default_preferred_image_dynamic_range: NSImageDynamicRange,
240            mtm: MainThreadMarker,
241        );
242
243        /// Preferred dynamic range when displaying an image in the receiving image view.
244        #[unsafe(method(preferredImageDynamicRange))]
245        #[unsafe(method_family = none)]
246        pub unsafe fn preferredImageDynamicRange(&self) -> NSImageDynamicRange;
247
248        /// Setter for [`preferredImageDynamicRange`][Self::preferredImageDynamicRange].
249        #[unsafe(method(setPreferredImageDynamicRange:))]
250        #[unsafe(method_family = none)]
251        pub unsafe fn setPreferredImageDynamicRange(
252            &self,
253            preferred_image_dynamic_range: NSImageDynamicRange,
254        );
255
256        /// 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.)
257        #[unsafe(method(imageDynamicRange))]
258        #[unsafe(method_family = none)]
259        pub unsafe fn imageDynamicRange(&self) -> NSImageDynamicRange;
260    );
261}
262
263/// Methods declared on superclass `NSControl`.
264#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
265impl NSImageView {
266    extern_methods!(
267        #[unsafe(method(initWithFrame:))]
268        #[unsafe(method_family = init)]
269        pub unsafe fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
270
271        #[unsafe(method(initWithCoder:))]
272        #[unsafe(method_family = init)]
273        pub unsafe fn initWithCoder(
274            this: Allocated<Self>,
275            coder: &NSCoder,
276        ) -> Option<Retained<Self>>;
277    );
278}
279
280/// Methods declared on superclass `NSResponder`.
281#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
282impl NSImageView {
283    extern_methods!(
284        #[unsafe(method(init))]
285        #[unsafe(method_family = init)]
286        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;
287    );
288}
289
290/// Methods declared on superclass `NSObject`.
291#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
292impl NSImageView {
293    extern_methods!(
294        #[unsafe(method(new))]
295        #[unsafe(method_family = new)]
296        pub unsafe fn new(mtm: MainThreadMarker) -> Retained<Self>;
297    );
298}