Skip to main content

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