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 fn imageViewWithImage(image: &NSImage, mtm: MainThreadMarker) -> Retained<Self>;
149
150        #[cfg(feature = "NSImage")]
151        #[unsafe(method(image))]
152        #[unsafe(method_family = none)]
153        pub 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 fn setImage(&self, image: Option<&NSImage>);
160
161        #[unsafe(method(isEditable))]
162        #[unsafe(method_family = none)]
163        pub fn isEditable(&self) -> bool;
164
165        /// Setter for [`isEditable`][Self::isEditable].
166        #[unsafe(method(setEditable:))]
167        #[unsafe(method_family = none)]
168        pub fn setEditable(&self, editable: bool);
169
170        #[cfg(feature = "NSImageCell")]
171        #[unsafe(method(imageAlignment))]
172        #[unsafe(method_family = none)]
173        pub 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 fn setImageAlignment(&self, image_alignment: NSImageAlignment);
180
181        #[cfg(feature = "NSCell")]
182        #[unsafe(method(imageScaling))]
183        #[unsafe(method_family = none)]
184        pub 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 fn setImageScaling(&self, image_scaling: NSImageScaling);
191
192        #[cfg(feature = "NSImageCell")]
193        #[unsafe(method(imageFrameStyle))]
194        #[unsafe(method_family = none)]
195        pub 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 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 fn symbolConfiguration(&self) -> Option<Retained<NSImageSymbolConfiguration>>;
208
209        #[cfg(feature = "NSImage")]
210        /// Setter for [`symbolConfiguration`][Self::symbolConfiguration].
211        ///
212        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
213        #[unsafe(method(setSymbolConfiguration:))]
214        #[unsafe(method_family = none)]
215        pub fn setSymbolConfiguration(
216            &self,
217            symbol_configuration: Option<&NSImageSymbolConfiguration>,
218        );
219
220        #[cfg(feature = "NSColor")]
221        /// 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.
222        #[unsafe(method(contentTintColor))]
223        #[unsafe(method_family = none)]
224        pub fn contentTintColor(&self) -> Option<Retained<NSColor>>;
225
226        #[cfg(feature = "NSColor")]
227        /// Setter for [`contentTintColor`][Self::contentTintColor].
228        ///
229        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
230        #[unsafe(method(setContentTintColor:))]
231        #[unsafe(method_family = none)]
232        pub fn setContentTintColor(&self, content_tint_color: Option<&NSColor>);
233
234        #[unsafe(method(animates))]
235        #[unsafe(method_family = none)]
236        pub fn animates(&self) -> bool;
237
238        /// Setter for [`animates`][Self::animates].
239        #[unsafe(method(setAnimates:))]
240        #[unsafe(method_family = none)]
241        pub fn setAnimates(&self, animates: bool);
242
243        #[unsafe(method(allowsCutCopyPaste))]
244        #[unsafe(method_family = none)]
245        pub fn allowsCutCopyPaste(&self) -> bool;
246
247        /// Setter for [`allowsCutCopyPaste`][Self::allowsCutCopyPaste].
248        #[unsafe(method(setAllowsCutCopyPaste:))]
249        #[unsafe(method_family = none)]
250        pub fn setAllowsCutCopyPaste(&self, allows_cut_copy_paste: bool);
251
252        /// 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.
253        #[unsafe(method(defaultPreferredImageDynamicRange))]
254        #[unsafe(method_family = none)]
255        pub fn defaultPreferredImageDynamicRange(mtm: MainThreadMarker) -> NSImageDynamicRange;
256
257        /// Setter for [`defaultPreferredImageDynamicRange`][Self::defaultPreferredImageDynamicRange].
258        #[unsafe(method(setDefaultPreferredImageDynamicRange:))]
259        #[unsafe(method_family = none)]
260        pub fn setDefaultPreferredImageDynamicRange(
261            default_preferred_image_dynamic_range: NSImageDynamicRange,
262            mtm: MainThreadMarker,
263        );
264
265        /// Preferred dynamic range when displaying an image in the receiving image view.
266        #[unsafe(method(preferredImageDynamicRange))]
267        #[unsafe(method_family = none)]
268        pub fn preferredImageDynamicRange(&self) -> NSImageDynamicRange;
269
270        /// Setter for [`preferredImageDynamicRange`][Self::preferredImageDynamicRange].
271        #[unsafe(method(setPreferredImageDynamicRange:))]
272        #[unsafe(method_family = none)]
273        pub fn setPreferredImageDynamicRange(
274            &self,
275            preferred_image_dynamic_range: NSImageDynamicRange,
276        );
277
278        /// 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.)
279        #[unsafe(method(imageDynamicRange))]
280        #[unsafe(method_family = none)]
281        pub fn imageDynamicRange(&self) -> NSImageDynamicRange;
282    );
283}
284
285/// Methods declared on superclass `NSControl`.
286#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
287impl NSImageView {
288    extern_methods!(
289        #[unsafe(method(initWithFrame:))]
290        #[unsafe(method_family = init)]
291        pub fn initWithFrame(this: Allocated<Self>, frame_rect: NSRect) -> Retained<Self>;
292
293        /// # Safety
294        ///
295        /// `coder` possibly has further requirements.
296        #[unsafe(method(initWithCoder:))]
297        #[unsafe(method_family = init)]
298        pub unsafe fn initWithCoder(
299            this: Allocated<Self>,
300            coder: &NSCoder,
301        ) -> Option<Retained<Self>>;
302    );
303}
304
305/// Methods declared on superclass `NSResponder`.
306#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
307impl NSImageView {
308    extern_methods!(
309        #[unsafe(method(init))]
310        #[unsafe(method_family = init)]
311        pub fn init(this: Allocated<Self>) -> Retained<Self>;
312    );
313}
314
315/// Methods declared on superclass `NSObject`.
316#[cfg(all(feature = "NSControl", feature = "NSResponder", feature = "NSView"))]
317impl NSImageView {
318    extern_methods!(
319        #[unsafe(method(new))]
320        #[unsafe(method_family = new)]
321        pub fn new(mtm: MainThreadMarker) -> Retained<Self>;
322    );
323}