1use std::fmt;
4
5use crate::ffi;
6use gdk::RGBA;
7use glib::translate::*;
8
9glib::wrapper! {
10 #[doc(alias = "GskShadow")]
11 pub struct Shadow(BoxedInline<ffi::GskShadow>);
12}
13
14impl Shadow {
15 #[inline]
16 pub fn new(color: RGBA, dx: f32, dy: f32, radius: f32) -> Self {
17 assert_initialized_main_thread!();
18 unsafe {
19 Self::unsafe_from(ffi::GskShadow {
20 color: *color.to_glib_none().0,
21 dx,
22 dy,
23 radius,
24 })
25 }
26 }
27
28 #[inline]
29 pub fn color(&self) -> &RGBA {
30 unsafe { &*(&self.inner.color as *const gdk::ffi::GdkRGBA as *const RGBA) }
31 }
32
33 #[inline]
34 pub fn dx(&self) -> f32 {
35 self.inner.dx
36 }
37
38 #[inline]
39 pub fn dy(&self) -> f32 {
40 self.inner.dy
41 }
42
43 #[inline]
44 pub fn radius(&self) -> f32 {
45 self.inner.radius
46 }
47}
48
49impl fmt::Debug for Shadow {
50 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
51 f.debug_struct("Shadow")
52 .field("color", &self.color())
53 .field("dx", &self.dx())
54 .field("dy", &self.dy())
55 .field("radius", &self.radius())
56 .finish()
57 }
58}