Skip to main content

gsk4/auto/
blur_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#![allow(deprecated)]
5
6use crate::{RenderNode, ffi};
7use glib::{prelude::*, translate::*};
8
9glib::wrapper! {
10    /// A render node applying a blur effect to its single child.
11    #[doc(alias = "GskBlurNode")]
12    pub struct BlurNode(Shared<ffi::GskBlurNode>);
13
14    match fn {
15        ref => |ptr| ffi::gsk_render_node_ref(ptr as *mut ffi::GskRenderNode),
16        unref => |ptr| ffi::gsk_render_node_unref(ptr as *mut ffi::GskRenderNode),
17    }
18}
19
20impl StaticType for BlurNode {
21    fn static_type() -> glib::Type {
22        unsafe { from_glib(ffi::gsk_blur_node_get_type()) }
23    }
24}
25
26impl BlurNode {
27    /// Creates a render node that blurs the child.
28    ///
29    /// The blur radius should be set to 2x the standard deviation.
30    /// ## `child`
31    /// the child node to blur
32    /// ## `radius`
33    /// the blur radius. Must be positive
34    ///
35    /// # Returns
36    ///
37    /// a new [`RenderNode`][crate::RenderNode]
38    #[doc(alias = "gsk_blur_node_new")]
39    pub fn new(child: impl AsRef<RenderNode>, radius: f32) -> BlurNode {
40        skip_assert_initialized!();
41        unsafe {
42            from_glib_full(ffi::gsk_blur_node_new(
43                child.as_ref().to_glib_none().0,
44                radius,
45            ))
46        }
47    }
48
49    /// Retrieves the blur radius of the @self.
50    ///
51    /// The blur radius is the standard deviation of the blur to apply
52    /// in the horizontal and vertical direction respectively.
53    ///
54    /// # Returns
55    ///
56    /// the blur radius
57    #[cfg(feature = "v4_26")]
58    #[cfg_attr(docsrs, doc(cfg(feature = "v4_26")))]
59    #[doc(alias = "gsk_blur_node_get_blur_radius")]
60    #[doc(alias = "get_blur_radius")]
61    pub fn blur_radius(&self) -> graphene::Size {
62        unsafe { from_glib_none(ffi::gsk_blur_node_get_blur_radius(self.to_glib_none().0)) }
63    }
64
65    /// Retrieves the child [`RenderNode`][crate::RenderNode] of the blur @self.
66    ///
67    /// # Returns
68    ///
69    /// the blurred child node
70    #[doc(alias = "gsk_blur_node_get_child")]
71    #[doc(alias = "get_child")]
72    pub fn child(&self) -> RenderNode {
73        unsafe { from_glib_none(ffi::gsk_blur_node_get_child(self.to_glib_none().0)) }
74    }
75
76    /// Retrieves the blur radius of the @self.
77    ///
78    /// The blur radius is 2x the standard deviation of the blur,
79    /// which, uhm, don't ask.
80    ///
81    /// # Deprecated since 4.26
82    ///
83    /// Use [`blur_radius()`][Self::blur_radius()] to
84    ///   get the separate horizontal and vertical radius.
85    ///   And to not get confused by this function multiplying the std
86    ///   deviation by 2.
87    ///
88    /// # Returns
89    ///
90    /// the blur radius
91    #[cfg_attr(feature = "v4_26", deprecated = "Since 4.26")]
92    #[allow(deprecated)]
93    #[doc(alias = "gsk_blur_node_get_radius")]
94    #[doc(alias = "get_radius")]
95    pub fn radius(&self) -> f32 {
96        unsafe { ffi::gsk_blur_node_get_radius(self.to_glib_none().0) }
97    }
98}