gsk4/auto/
component_transfer_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, ComponentTransfer, RenderNode};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9    ///
10    #[doc(alias = "GskComponentTransferNode")]
11    pub struct ComponentTransferNode(Shared<ffi::GskComponentTransferNode>);
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 ComponentTransferNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_component_transfer_node_get_type()) }
22    }
23}
24
25impl ComponentTransferNode {
26    /// Creates a render node that will apply component
27    /// transfers to a child node.
28    /// ## `child`
29    /// The child to apply component transfers to
30    /// ## `r`
31    /// transfer for the red component
32    /// ## `g`
33    /// transfer for the green component
34    /// ## `b`
35    /// transfer for the blue component
36    /// ## `a`
37    /// transfer for the alpha component
38    ///
39    /// # Returns
40    ///
41    /// A new [`RenderNode`][crate::RenderNode]
42    #[doc(alias = "gsk_component_transfer_node_new")]
43    pub fn new(
44        child: impl AsRef<RenderNode>,
45        r: &ComponentTransfer,
46        g: &ComponentTransfer,
47        b: &ComponentTransfer,
48        a: &ComponentTransfer,
49    ) -> ComponentTransferNode {
50        skip_assert_initialized!();
51        unsafe {
52            from_glib_full(ffi::gsk_component_transfer_node_new(
53                child.as_ref().to_glib_none().0,
54                r.to_glib_none().0,
55                g.to_glib_none().0,
56                b.to_glib_none().0,
57                a.to_glib_none().0,
58            ))
59        }
60    }
61
62    /// Gets the child node that is getting drawn by the given @self.
63    ///
64    /// # Returns
65    ///
66    /// the child [`RenderNode`][crate::RenderNode]
67    #[doc(alias = "gsk_component_transfer_node_get_child")]
68    #[doc(alias = "get_child")]
69    pub fn child(&self) -> RenderNode {
70        unsafe {
71            from_glib_none(ffi::gsk_component_transfer_node_get_child(
72                self.to_glib_none().0,
73            ))
74        }
75    }
76
77    /// Gets the component transfer for one of the components.
78    /// ## `component`
79    /// a value between 0 and 3 to indicate the red, green, blue
80    ///   or alpha component
81    ///
82    /// # Returns
83    ///
84    /// the [`ComponentTransfer`][crate::ComponentTransfer]
85    #[doc(alias = "gsk_component_transfer_node_get_transfer")]
86    #[doc(alias = "get_transfer")]
87    pub fn transfer(&self, component: u32) -> ComponentTransfer {
88        unsafe {
89            from_glib_none(ffi::gsk_component_transfer_node_get_transfer(
90                self.to_glib_none().0,
91                component,
92            ))
93        }
94    }
95}