gsk4/auto/
inset_shadow_node.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use crate::{ffi, RoundedRect};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A render node for an inset shadow.
10    #[doc(alias = "GskInsetShadowNode")]
11    pub struct InsetShadowNode(Shared<ffi::GskInsetShadowNode>);
12
13    match fn {
14        ref => |ptr| ffi::gsk_render_node_ref(ptr as *mut ffi::GskRenderNode),
15        unref => |ptr| ffi::gsk_render_node_unref(ptr as *mut ffi::GskRenderNode),
16    }
17}
18
19impl StaticType for InsetShadowNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_inset_shadow_node_get_type()) }
22    }
23}
24
25impl InsetShadowNode {
26    /// Creates a [`RenderNode`][crate::RenderNode] that will render an inset shadow
27    /// into the box given by @outline.
28    /// ## `outline`
29    /// outline of the region containing the shadow
30    /// ## `color`
31    /// color of the shadow
32    /// ## `dx`
33    /// horizontal offset of shadow
34    /// ## `dy`
35    /// vertical offset of shadow
36    /// ## `spread`
37    /// how far the shadow spreads towards the inside
38    /// ## `blur_radius`
39    /// how much blur to apply to the shadow
40    ///
41    /// # Returns
42    ///
43    /// A new [`RenderNode`][crate::RenderNode]
44    #[doc(alias = "gsk_inset_shadow_node_new")]
45    pub fn new(
46        outline: &RoundedRect,
47        color: &gdk::RGBA,
48        dx: f32,
49        dy: f32,
50        spread: f32,
51        blur_radius: f32,
52    ) -> InsetShadowNode {
53        assert_initialized_main_thread!();
54        unsafe {
55            from_glib_full(ffi::gsk_inset_shadow_node_new(
56                outline.to_glib_none().0,
57                color.to_glib_none().0,
58                dx,
59                dy,
60                spread,
61                blur_radius,
62            ))
63        }
64    }
65
66    /// Retrieves the blur radius to apply to the shadow.
67    ///
68    /// # Returns
69    ///
70    /// the blur radius, in pixels
71    #[doc(alias = "gsk_inset_shadow_node_get_blur_radius")]
72    #[doc(alias = "get_blur_radius")]
73    pub fn blur_radius(&self) -> f32 {
74        unsafe { ffi::gsk_inset_shadow_node_get_blur_radius(self.to_glib_none().0) }
75    }
76
77    /// Retrieves the color of the inset shadow.
78    ///
79    /// The value returned by this function will not be correct
80    /// if the render node was created for a non-sRGB color.
81    ///
82    /// # Returns
83    ///
84    /// the color of the shadow
85    #[doc(alias = "gsk_inset_shadow_node_get_color")]
86    #[doc(alias = "get_color")]
87    pub fn color(&self) -> gdk::RGBA {
88        unsafe { from_glib_none(ffi::gsk_inset_shadow_node_get_color(self.to_glib_none().0)) }
89    }
90
91    /// Retrieves the horizontal offset of the inset shadow.
92    ///
93    /// # Returns
94    ///
95    /// an offset, in pixels
96    #[doc(alias = "gsk_inset_shadow_node_get_dx")]
97    #[doc(alias = "get_dx")]
98    pub fn dx(&self) -> f32 {
99        unsafe { ffi::gsk_inset_shadow_node_get_dx(self.to_glib_none().0) }
100    }
101
102    /// Retrieves the vertical offset of the inset shadow.
103    ///
104    /// # Returns
105    ///
106    /// an offset, in pixels
107    #[doc(alias = "gsk_inset_shadow_node_get_dy")]
108    #[doc(alias = "get_dy")]
109    pub fn dy(&self) -> f32 {
110        unsafe { ffi::gsk_inset_shadow_node_get_dy(self.to_glib_none().0) }
111    }
112
113    /// Retrieves the outline rectangle of the inset shadow.
114    ///
115    /// # Returns
116    ///
117    /// a rounded rectangle
118    #[doc(alias = "gsk_inset_shadow_node_get_outline")]
119    #[doc(alias = "get_outline")]
120    pub fn outline(&self) -> RoundedRect {
121        unsafe {
122            from_glib_none(ffi::gsk_inset_shadow_node_get_outline(
123                self.to_glib_none().0,
124            ))
125        }
126    }
127
128    /// Retrieves how much the shadow spreads inwards.
129    ///
130    /// # Returns
131    ///
132    /// the size of the shadow, in pixels
133    #[doc(alias = "gsk_inset_shadow_node_get_spread")]
134    #[doc(alias = "get_spread")]
135    pub fn spread(&self) -> f32 {
136        unsafe { ffi::gsk_inset_shadow_node_get_spread(self.to_glib_none().0) }
137    }
138}