gdk4/auto/
cicp_params.rs
1use crate::{ffi, CicpRange, ColorState};
6use glib::{
7 prelude::*,
8 signal::{connect_raw, SignalHandlerId},
9 translate::*,
10};
11use std::boxed::Box as Box_;
12
13glib::wrapper! {
14 #[doc(alias = "GdkCicpParams")]
86 pub struct CicpParams(Object<ffi::GdkCicpParams, ffi::GdkCicpParamsClass>);
87
88 match fn {
89 type_ => || ffi::gdk_cicp_params_get_type(),
90 }
91}
92
93impl CicpParams {
94 #[doc(alias = "gdk_cicp_params_new")]
103 pub fn new() -> CicpParams {
104 assert_initialized_main_thread!();
105 unsafe { from_glib_full(ffi::gdk_cicp_params_new()) }
106 }
107
108 #[doc(alias = "gdk_cicp_params_build_color_state")]
118 pub fn build_color_state(&self) -> Result<ColorState, glib::Error> {
119 unsafe {
120 let mut error = std::ptr::null_mut();
121 let ret = ffi::gdk_cicp_params_build_color_state(self.to_glib_none().0, &mut error);
122 if error.is_null() {
123 Ok(from_glib_full(ret))
124 } else {
125 Err(from_glib_full(error))
126 }
127 }
128 }
129
130 #[doc(alias = "gdk_cicp_params_get_color_primaries")]
137 #[doc(alias = "get_color_primaries")]
138 #[doc(alias = "color-primaries")]
139 pub fn color_primaries(&self) -> u32 {
140 unsafe { ffi::gdk_cicp_params_get_color_primaries(self.to_glib_none().0) }
141 }
142
143 #[doc(alias = "gdk_cicp_params_get_matrix_coefficients")]
149 #[doc(alias = "get_matrix_coefficients")]
150 #[doc(alias = "matrix-coefficients")]
151 pub fn matrix_coefficients(&self) -> u32 {
152 unsafe { ffi::gdk_cicp_params_get_matrix_coefficients(self.to_glib_none().0) }
153 }
154
155 #[doc(alias = "gdk_cicp_params_get_range")]
161 #[doc(alias = "get_range")]
162 pub fn range(&self) -> CicpRange {
163 unsafe { from_glib(ffi::gdk_cicp_params_get_range(self.to_glib_none().0)) }
164 }
165
166 #[doc(alias = "gdk_cicp_params_get_transfer_function")]
172 #[doc(alias = "get_transfer_function")]
173 #[doc(alias = "transfer-function")]
174 pub fn transfer_function(&self) -> u32 {
175 unsafe { ffi::gdk_cicp_params_get_transfer_function(self.to_glib_none().0) }
176 }
177
178 #[doc(alias = "gdk_cicp_params_set_color_primaries")]
182 #[doc(alias = "color-primaries")]
183 pub fn set_color_primaries(&self, color_primaries: u32) {
184 unsafe {
185 ffi::gdk_cicp_params_set_color_primaries(self.to_glib_none().0, color_primaries);
186 }
187 }
188
189 #[doc(alias = "gdk_cicp_params_set_matrix_coefficients")]
194 #[doc(alias = "matrix-coefficients")]
195 pub fn set_matrix_coefficients(&self, matrix_coefficients: u32) {
196 unsafe {
197 ffi::gdk_cicp_params_set_matrix_coefficients(
198 self.to_glib_none().0,
199 matrix_coefficients,
200 );
201 }
202 }
203
204 #[doc(alias = "gdk_cicp_params_set_range")]
208 #[doc(alias = "range")]
209 pub fn set_range(&self, range: CicpRange) {
210 unsafe {
211 ffi::gdk_cicp_params_set_range(self.to_glib_none().0, range.into_glib());
212 }
213 }
214
215 #[doc(alias = "gdk_cicp_params_set_transfer_function")]
219 #[doc(alias = "transfer-function")]
220 pub fn set_transfer_function(&self, transfer_function: u32) {
221 unsafe {
222 ffi::gdk_cicp_params_set_transfer_function(self.to_glib_none().0, transfer_function);
223 }
224 }
225
226 #[cfg(feature = "v4_16")]
227 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
228 #[doc(alias = "color-primaries")]
229 pub fn connect_color_primaries_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
230 unsafe extern "C" fn notify_color_primaries_trampoline<F: Fn(&CicpParams) + 'static>(
231 this: *mut ffi::GdkCicpParams,
232 _param_spec: glib::ffi::gpointer,
233 f: glib::ffi::gpointer,
234 ) {
235 let f: &F = &*(f as *const F);
236 f(&from_glib_borrow(this))
237 }
238 unsafe {
239 let f: Box_<F> = Box_::new(f);
240 connect_raw(
241 self.as_ptr() as *mut _,
242 b"notify::color-primaries\0".as_ptr() as *const _,
243 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
244 notify_color_primaries_trampoline::<F> as *const (),
245 )),
246 Box_::into_raw(f),
247 )
248 }
249 }
250
251 #[cfg(feature = "v4_16")]
252 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
253 #[doc(alias = "matrix-coefficients")]
254 pub fn connect_matrix_coefficients_notify<F: Fn(&Self) + 'static>(
255 &self,
256 f: F,
257 ) -> SignalHandlerId {
258 unsafe extern "C" fn notify_matrix_coefficients_trampoline<F: Fn(&CicpParams) + 'static>(
259 this: *mut ffi::GdkCicpParams,
260 _param_spec: glib::ffi::gpointer,
261 f: glib::ffi::gpointer,
262 ) {
263 let f: &F = &*(f as *const F);
264 f(&from_glib_borrow(this))
265 }
266 unsafe {
267 let f: Box_<F> = Box_::new(f);
268 connect_raw(
269 self.as_ptr() as *mut _,
270 b"notify::matrix-coefficients\0".as_ptr() as *const _,
271 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
272 notify_matrix_coefficients_trampoline::<F> as *const (),
273 )),
274 Box_::into_raw(f),
275 )
276 }
277 }
278
279 #[cfg(feature = "v4_16")]
280 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
281 #[doc(alias = "range")]
282 pub fn connect_range_notify<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId {
283 unsafe extern "C" fn notify_range_trampoline<F: Fn(&CicpParams) + 'static>(
284 this: *mut ffi::GdkCicpParams,
285 _param_spec: glib::ffi::gpointer,
286 f: glib::ffi::gpointer,
287 ) {
288 let f: &F = &*(f as *const F);
289 f(&from_glib_borrow(this))
290 }
291 unsafe {
292 let f: Box_<F> = Box_::new(f);
293 connect_raw(
294 self.as_ptr() as *mut _,
295 b"notify::range\0".as_ptr() as *const _,
296 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
297 notify_range_trampoline::<F> as *const (),
298 )),
299 Box_::into_raw(f),
300 )
301 }
302 }
303
304 #[cfg(feature = "v4_16")]
305 #[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
306 #[doc(alias = "transfer-function")]
307 pub fn connect_transfer_function_notify<F: Fn(&Self) + 'static>(
308 &self,
309 f: F,
310 ) -> SignalHandlerId {
311 unsafe extern "C" fn notify_transfer_function_trampoline<F: Fn(&CicpParams) + 'static>(
312 this: *mut ffi::GdkCicpParams,
313 _param_spec: glib::ffi::gpointer,
314 f: glib::ffi::gpointer,
315 ) {
316 let f: &F = &*(f as *const F);
317 f(&from_glib_borrow(this))
318 }
319 unsafe {
320 let f: Box_<F> = Box_::new(f);
321 connect_raw(
322 self.as_ptr() as *mut _,
323 b"notify::transfer-function\0".as_ptr() as *const _,
324 Some(std::mem::transmute::<*const (), unsafe extern "C" fn()>(
325 notify_transfer_function_trampoline::<F> as *const (),
326 )),
327 Box_::into_raw(f),
328 )
329 }
330 }
331}
332
333#[cfg(feature = "v4_16")]
334#[cfg_attr(docsrs, doc(cfg(feature = "v4_16")))]
335impl Default for CicpParams {
336 fn default() -> Self {
337 Self::new()
338 }
339}