1use crate::ffi;
6use glib::translate::*;
7
8glib::wrapper! {
9 pub struct RGBA(BoxedInline<ffi::GdkRGBA>);
10
11 match fn {
12 copy => |ptr| ffi::gdk_rgba_copy(ptr),
13 free => |ptr| ffi::gdk_rgba_free(ptr),
14 type_ => || ffi::gdk_rgba_get_type(),
15 }
16}
17
18impl RGBA {
19 #[doc(alias = "gdk_rgba_equal")]
20 fn equal(&self, p2: &RGBA) -> bool {
21 unsafe {
22 from_glib(ffi::gdk_rgba_equal(
23 ToGlibPtr::<*const ffi::GdkRGBA>::to_glib_none(self).0 as glib::ffi::gconstpointer,
24 ToGlibPtr::<*const ffi::GdkRGBA>::to_glib_none(p2).0 as glib::ffi::gconstpointer,
25 ))
26 }
27 }
28
29 #[doc(alias = "gdk_rgba_hash")]
30 fn hash(&self) -> u32 {
31 unsafe {
32 ffi::gdk_rgba_hash(
33 ToGlibPtr::<*const ffi::GdkRGBA>::to_glib_none(self).0 as glib::ffi::gconstpointer,
34 )
35 }
36 }
37
38 #[doc(alias = "gdk_rgba_is_clear")]
39 pub fn is_clear(&self) -> bool {
40 unsafe { from_glib(ffi::gdk_rgba_is_clear(self.to_glib_none().0)) }
41 }
42
43 #[doc(alias = "gdk_rgba_is_opaque")]
44 pub fn is_opaque(&self) -> bool {
45 unsafe { from_glib(ffi::gdk_rgba_is_opaque(self.to_glib_none().0)) }
46 }
47
48 #[doc(alias = "gdk_rgba_to_string")]
49 #[doc(alias = "to_string")]
50 pub fn to_str(&self) -> glib::GString {
51 unsafe { from_glib_full(ffi::gdk_rgba_to_string(self.to_glib_none().0)) }
52 }
53}
54
55impl PartialEq for RGBA {
56 #[inline]
57 fn eq(&self, other: &Self) -> bool {
58 self.equal(other)
59 }
60}
61
62impl Eq for RGBA {}
63
64impl std::fmt::Display for RGBA {
65 #[inline]
66 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
67 f.write_str(&self.to_str())
68 }
69}
70
71impl std::hash::Hash for RGBA {
72 #[inline]
73 fn hash<H>(&self, state: &mut H)
74 where
75 H: std::hash::Hasher,
76 {
77 std::hash::Hash::hash(&self.hash(), state)
78 }
79}