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