gdk4/auto/color_state.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::{ffi, CicpParams};
use glib::translate::*;
glib::wrapper! {
/// A [`ColorState`][crate::ColorState] object provides the information to interpret
/// colors and pixels in a variety of ways.
///
/// They are also known as
/// [*color spaces*](https://en.wikipedia.org/wiki/Color_space).
///
/// Crucially, GTK knows how to convert colors from one color
/// state to another.
///
/// [`ColorState`][crate::ColorState] objects are immutable and therefore threadsafe.
#[derive(Debug, PartialOrd, Ord, Hash)]
pub struct ColorState(Shared<ffi::GdkColorState>);
match fn {
ref => |ptr| ffi::gdk_color_state_ref(ptr),
unref => |ptr| ffi::gdk_color_state_unref(ptr),
type_ => || ffi::gdk_color_state_get_type(),
}
}
impl ColorState {
/// Create a [`CicpParams`][crate::CicpParams] representing the colorstate.
///
/// It is not guaranteed that every [`ColorState`][crate::ColorState] can be
/// represented with Cicp parameters. If that is the case,
/// this function returns `NULL`.
///
/// # Returns
///
/// A new [`CicpParams`][crate::CicpParams]
#[doc(alias = "gdk_color_state_create_cicp_params")]
pub fn create_cicp_params(&self) -> Option<CicpParams> {
unsafe {
from_glib_full(ffi::gdk_color_state_create_cicp_params(
self.to_glib_none().0,
))
}
}
#[doc(alias = "gdk_color_state_equal")]
fn equal(&self, other: &ColorState) -> bool {
unsafe {
from_glib(ffi::gdk_color_state_equal(
self.to_glib_none().0,
other.to_glib_none().0,
))
}
}
/// Returns the color state object representing the oklab color space.
///
/// This is a perceptually uniform color state.
///
/// # Returns
///
/// the color state object for oklab
#[cfg(feature = "v4_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
#[doc(alias = "gdk_color_state_get_oklab")]
#[doc(alias = "get_oklab")]
pub fn oklab() -> ColorState {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gdk_color_state_get_oklab()) }
}
/// Returns the color state object representing the oklch color space.
///
/// This is the polar variant of oklab, in which the hue is encoded as
/// a polar coordinate.
///
/// # Returns
///
/// the color state object for oklch
#[cfg(feature = "v4_18")]
#[cfg_attr(docsrs, doc(cfg(feature = "v4_18")))]
#[doc(alias = "gdk_color_state_get_oklch")]
#[doc(alias = "get_oklch")]
pub fn oklch() -> ColorState {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gdk_color_state_get_oklch()) }
}
/// Returns the color state object representing the linear rec2100 color space.
///
/// This color state uses the primaries defined by BT.2020-2 and BT.2100-0 and a linear
/// transfer function.
///
/// It is equivalent to the [Cicp](class.CicpParams.html) tuple 9/8/0/1.
///
/// See e.g. [the CSS HDR Module](https://drafts.csswg.org/css-color-hdr/#valdef-color-rec2100-linear)
/// for details about this colorstate.
///
/// # Returns
///
/// the color state object for linearized rec2100
#[doc(alias = "gdk_color_state_get_rec2100_linear")]
#[doc(alias = "get_rec2100_linear")]
pub fn rec2100_linear() -> ColorState {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gdk_color_state_get_rec2100_linear()) }
}
/// Returns the color state object representing the rec2100-pq color space.
///
/// This color state uses the primaries defined by BT.2020-2 and BT.2100-0 and the transfer
/// function defined by SMPTE ST 2084 and BT.2100-2.
///
/// It is equivalent to the [Cicp](class.CicpParams.html) tuple 9/16/0/1.
///
/// See e.g. [the CSS HDR Module](https://drafts.csswg.org/css-color-hdr/#valdef-color-rec2100-pq)
/// for details about this colorstate.
///
/// # Returns
///
/// the color state object for rec2100-pq
#[doc(alias = "gdk_color_state_get_rec2100_pq")]
#[doc(alias = "get_rec2100_pq")]
pub fn rec2100_pq() -> ColorState {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gdk_color_state_get_rec2100_pq()) }
}
/// Returns the color state object representing the sRGB color space.
///
/// This color state uses the primaries defined by BT.709-6 and the transfer function
/// defined by IEC 61966-2-1.
///
/// It is equivalent to the [Cicp](class.CicpParams.html) tuple 1/13/0/1.
///
/// See e.g. [the CSS Color Module](https://www.w3.org/TR/css-color-4/#predefined-sRGB)
/// for details about this colorstate.
///
/// # Returns
///
/// the color state object for sRGB
#[doc(alias = "gdk_color_state_get_srgb")]
#[doc(alias = "get_srgb")]
pub fn srgb() -> ColorState {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gdk_color_state_get_srgb()) }
}
/// Returns the color state object representing the linearized sRGB color space.
///
/// This color state uses the primaries defined by BT.709-6 and a linear transfer function.
///
/// It is equivalent to the [Cicp](class.CicpParams.html) tuple 1/8/0/1.
///
/// See e.g. [the CSS Color Module](https://www.w3.org/TR/css-color-4/#predefined-sRGB-linear)
/// for details about this colorstate.
///
/// # Returns
///
/// the color state object for linearized sRGB
#[doc(alias = "gdk_color_state_get_srgb_linear")]
#[doc(alias = "get_srgb_linear")]
pub fn srgb_linear() -> ColorState {
assert_initialized_main_thread!();
unsafe { from_glib_full(ffi::gdk_color_state_get_srgb_linear()) }
}
}
impl PartialEq for ColorState {
#[inline]
fn eq(&self, other: &Self) -> bool {
self.equal(other)
}
}
impl Eq for ColorState {}