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
// Take a look at the license at the top of the repository in the LICENSE file.

use std::fmt;

use gdk::RGBA;
use glib::translate::*;

glib::wrapper! {
    /// The shadow parameters in a shadow node.
    #[doc(alias = "GskShadow")]
    pub struct Shadow(BoxedInline<ffi::GskShadow>);
}

impl Shadow {
    #[inline]
    pub fn new(color: RGBA, dx: f32, dy: f32, radius: f32) -> Self {
        assert_initialized_main_thread!();
        unsafe {
            Self::unsafe_from(ffi::GskShadow {
                color: *color.to_glib_none().0,
                dx,
                dy,
                radius,
            })
        }
    }

    #[inline]
    pub fn color(&self) -> &RGBA {
        unsafe { &*(&self.inner.color as *const gdk::ffi::GdkRGBA as *const RGBA) }
    }

    #[inline]
    pub fn dx(&self) -> f32 {
        self.inner.dx
    }

    #[inline]
    pub fn dy(&self) -> f32 {
        self.inner.dy
    }

    #[inline]
    pub fn radius(&self) -> f32 {
        self.inner.radius
    }
}

impl fmt::Debug for Shadow {
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        f.debug_struct("Shadow")
            .field("color", &self.color())
            .field("dx", &self.dx())
            .field("dy", &self.dy())
            .field("radius", &self.radius())
            .finish()
    }
}