gsk4/auto/
opacity_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, RenderNode};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    /// A render node controlling the opacity of its single child node.
10    #[doc(alias = "GskOpacityNode")]
11    pub struct OpacityNode(Shared<ffi::GskOpacityNode>);
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 OpacityNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_opacity_node_get_type()) }
22    }
23}
24
25impl OpacityNode {
26    /// Creates a [`RenderNode`][crate::RenderNode] that will drawn the @child with reduced
27    /// @opacity.
28    /// ## `child`
29    /// The node to draw
30    /// ## `opacity`
31    /// The opacity to apply
32    ///
33    /// # Returns
34    ///
35    /// A new [`RenderNode`][crate::RenderNode]
36    #[doc(alias = "gsk_opacity_node_new")]
37    pub fn new(child: impl AsRef<RenderNode>, opacity: f32) -> OpacityNode {
38        skip_assert_initialized!();
39        unsafe {
40            from_glib_full(ffi::gsk_opacity_node_new(
41                child.as_ref().to_glib_none().0,
42                opacity,
43            ))
44        }
45    }
46
47    /// Gets the child node that is getting opacityed by the given @self.
48    ///
49    /// # Returns
50    ///
51    /// The child that is getting opacityed
52    #[doc(alias = "gsk_opacity_node_get_child")]
53    #[doc(alias = "get_child")]
54    pub fn child(&self) -> RenderNode {
55        unsafe { from_glib_none(ffi::gsk_opacity_node_get_child(self.to_glib_none().0)) }
56    }
57
58    /// Gets the transparency factor for an opacity node.
59    ///
60    /// # Returns
61    ///
62    /// the opacity factor
63    #[doc(alias = "gsk_opacity_node_get_opacity")]
64    #[doc(alias = "get_opacity")]
65    pub fn opacity(&self) -> f32 {
66        unsafe { ffi::gsk_opacity_node_get_opacity(self.to_glib_none().0) }
67    }
68}