gsk4/auto/
clip_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 applying a rectangular clip to its single child node.
10    #[doc(alias = "GskClipNode")]
11    pub struct ClipNode(Shared<ffi::GskClipNode>);
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 ClipNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_clip_node_get_type()) }
22    }
23}
24
25impl ClipNode {
26    /// Creates a [`RenderNode`][crate::RenderNode] that will clip the @child to the area
27    /// given by @clip.
28    /// ## `child`
29    /// The node to draw
30    /// ## `clip`
31    /// The clip to apply
32    ///
33    /// # Returns
34    ///
35    /// A new [`RenderNode`][crate::RenderNode]
36    #[doc(alias = "gsk_clip_node_new")]
37    pub fn new(child: impl AsRef<RenderNode>, clip: &graphene::Rect) -> ClipNode {
38        skip_assert_initialized!();
39        unsafe {
40            from_glib_full(ffi::gsk_clip_node_new(
41                child.as_ref().to_glib_none().0,
42                clip.to_glib_none().0,
43            ))
44        }
45    }
46
47    /// Gets the child node that is getting clipped by the given @self.
48    ///
49    /// # Returns
50    ///
51    /// The child that is getting clipped
52    #[doc(alias = "gsk_clip_node_get_child")]
53    #[doc(alias = "get_child")]
54    pub fn child(&self) -> RenderNode {
55        unsafe { from_glib_none(ffi::gsk_clip_node_get_child(self.to_glib_none().0)) }
56    }
57
58    /// Retrieves the clip rectangle for @self.
59    ///
60    /// # Returns
61    ///
62    /// a clip rectangle
63    #[doc(alias = "gsk_clip_node_get_clip")]
64    #[doc(alias = "get_clip")]
65    pub fn clip(&self) -> graphene::Rect {
66        unsafe { from_glib_none(ffi::gsk_clip_node_get_clip(self.to_glib_none().0)) }
67    }
68}