gsk4/auto/composite_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, PorterDuff, RenderNode};
6use glib::{prelude::*, translate::*};
7
8glib::wrapper! {
9 /// A render node that uses Porter/Duff compositing operators to combine
10 /// its child with the background.
11 #[doc(alias = "GskCompositeNode")]
12 pub struct CompositeNode(Shared<ffi::GskCompositeNode>);
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 CompositeNode {
21 fn static_type() -> glib::Type {
22 unsafe { from_glib(ffi::gsk_composite_node_get_type()) }
23 }
24}
25
26impl CompositeNode {
27 /// Creates a [`RenderNode`][crate::RenderNode] that will composite the child onto the
28 /// background with the given operator wherever the mask is set.
29 ///
30 /// Note that various operations can modify the background outside of
31 /// the child's bounds, so the mask may cause visual changes outside
32 /// of the child.
33 /// ## `child`
34 /// The child to composite
35 /// ## `mask`
36 /// The mask where the compositing will apply
37 /// ## `op`
38 /// The compositing operator
39 ///
40 /// # Returns
41 ///
42 /// A new [`RenderNode`][crate::RenderNode]
43 #[doc(alias = "gsk_composite_node_new")]
44 pub fn new(
45 child: impl AsRef<RenderNode>,
46 mask: impl AsRef<RenderNode>,
47 op: PorterDuff,
48 ) -> CompositeNode {
49 skip_assert_initialized!();
50 unsafe {
51 from_glib_full(ffi::gsk_composite_node_new(
52 child.as_ref().to_glib_none().0,
53 mask.as_ref().to_glib_none().0,
54 op.into_glib(),
55 ))
56 }
57 }
58
59 /// Gets the child node that is getting composited by the given @self.
60 ///
61 /// # Returns
62 ///
63 /// the child [`RenderNode`][crate::RenderNode]
64 #[doc(alias = "gsk_composite_node_get_child")]
65 #[doc(alias = "get_child")]
66 pub fn child(&self) -> RenderNode {
67 unsafe { from_glib_none(ffi::gsk_composite_node_get_child(self.to_glib_none().0)) }
68 }
69
70 /// Gets the mask node that describes the region where the compositing
71 /// applies.
72 ///
73 /// # Returns
74 ///
75 /// the mask [`RenderNode`][crate::RenderNode]
76 #[doc(alias = "gsk_composite_node_get_mask")]
77 #[doc(alias = "get_mask")]
78 pub fn mask(&self) -> RenderNode {
79 unsafe { from_glib_none(ffi::gsk_composite_node_get_mask(self.to_glib_none().0)) }
80 }
81
82 /// Gets the compositing operator used by this node.
83 ///
84 /// # Returns
85 ///
86 /// The compositing operator
87 #[doc(alias = "gsk_composite_node_get_operator")]
88 #[doc(alias = "get_operator")]
89 pub fn operator(&self) -> PorterDuff {
90 unsafe { from_glib(ffi::gsk_composite_node_get_operator(self.to_glib_none().0)) }
91 }
92}