1use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9 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 #[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 #[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 #[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}