Skip to main content

gdk4/auto/
rgba.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9    /// s way to deal with colors and mirrors its behavior. All values
10    /// are in the range from 0.0 to 1.0 inclusive. So the color
11    /// (0.0, 0.0, 0.0, 0.0) represents transparent black and
12    /// (1.0, 1.0, 1.0, 1.0) is opaque white. Other values will
13    /// be clamped to this range when drawing.
14    pub struct RGBA(BoxedInline<ffi::GdkRGBA>);
15
16    match fn {
17        copy => |ptr| ffi::gdk_rgba_copy(ptr),
18        free => |ptr| ffi::gdk_rgba_free(ptr),
19        type_ => || ffi::gdk_rgba_get_type(),
20    }
21}
22
23impl RGBA {
24    #[doc(alias = "gdk_rgba_equal")]
25    fn equal(&self, p2: &RGBA) -> bool {
26        unsafe {
27            from_glib(ffi::gdk_rgba_equal(
28                ToGlibPtr::<*const ffi::GdkRGBA>::to_glib_none(self).0 as glib::ffi::gconstpointer,
29                ToGlibPtr::<*const ffi::GdkRGBA>::to_glib_none(p2).0 as glib::ffi::gconstpointer,
30            ))
31        }
32    }
33
34    #[doc(alias = "gdk_rgba_hash")]
35    fn hash(&self) -> u32 {
36        unsafe {
37            ffi::gdk_rgba_hash(
38                ToGlibPtr::<*const ffi::GdkRGBA>::to_glib_none(self).0 as glib::ffi::gconstpointer,
39            )
40        }
41    }
42
43    /// Checks if an @self value is transparent.
44    ///
45    /// That is, drawing with the value would not produce any change.
46    ///
47    /// # Returns
48    ///
49    /// [`true`] if the @self is clear
50    #[doc(alias = "gdk_rgba_is_clear")]
51    pub fn is_clear(&self) -> bool {
52        unsafe { from_glib(ffi::gdk_rgba_is_clear(self.to_glib_none().0)) }
53    }
54
55    /// Checks if an @self value is opaque.
56    ///
57    /// That is, drawing with the value will not retain any results
58    /// from previous contents.
59    ///
60    /// # Returns
61    ///
62    /// [`true`] if the @self is opaque
63    #[doc(alias = "gdk_rgba_is_opaque")]
64    pub fn is_opaque(&self) -> bool {
65        unsafe { from_glib(ffi::gdk_rgba_is_opaque(self.to_glib_none().0)) }
66    }
67
68    ///  are represented as 8-bit integers. If
69    /// this is a concern, you should use a different representation.
70    ///
71    /// # Returns
72    ///
73    /// A newly allocated text string
74    #[doc(alias = "gdk_rgba_to_string")]
75    #[doc(alias = "to_string")]
76    pub fn to_str(&self) -> glib::GString {
77        unsafe { from_glib_full(ffi::gdk_rgba_to_string(self.to_glib_none().0)) }
78    }
79}
80
81impl PartialEq for RGBA {
82    #[inline]
83    fn eq(&self, other: &Self) -> bool {
84        self.equal(other)
85    }
86}
87
88impl Eq for RGBA {}
89
90impl std::fmt::Display for RGBA {
91    #[inline]
92    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
93        f.write_str(&self.to_str())
94    }
95}
96
97impl std::hash::Hash for RGBA {
98    #[inline]
99    fn hash<H>(&self, state: &mut H)
100    where
101        H: std::hash::Hasher,
102    {
103        std::hash::Hash::hash(&self.hash(), state)
104    }
105}