gsk4/auto/
repeat_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 repeating its single child node.
10    #[doc(alias = "GskRepeatNode")]
11    pub struct RepeatNode(Shared<ffi::GskRepeatNode>);
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 RepeatNode {
20    fn static_type() -> glib::Type {
21        unsafe { from_glib(ffi::gsk_repeat_node_get_type()) }
22    }
23}
24
25impl RepeatNode {
26    /// Creates a [`RenderNode`][crate::RenderNode] that will repeat the drawing of @child across
27    /// the given @bounds.
28    /// ## `bounds`
29    /// The bounds of the area to be painted
30    /// ## `child`
31    /// The child to repeat
32    /// ## `child_bounds`
33    /// The area of the child to repeat or [`None`] to
34    ///     use the child's bounds
35    ///
36    /// # Returns
37    ///
38    /// A new [`RenderNode`][crate::RenderNode]
39    #[doc(alias = "gsk_repeat_node_new")]
40    pub fn new(
41        bounds: &graphene::Rect,
42        child: impl AsRef<RenderNode>,
43        child_bounds: Option<&graphene::Rect>,
44    ) -> RepeatNode {
45        skip_assert_initialized!();
46        unsafe {
47            from_glib_full(ffi::gsk_repeat_node_new(
48                bounds.to_glib_none().0,
49                child.as_ref().to_glib_none().0,
50                child_bounds.to_glib_none().0,
51            ))
52        }
53    }
54
55    /// Retrieves the child of @self.
56    ///
57    /// # Returns
58    ///
59    /// a [`RenderNode`][crate::RenderNode]
60    #[doc(alias = "gsk_repeat_node_get_child")]
61    #[doc(alias = "get_child")]
62    pub fn child(&self) -> RenderNode {
63        unsafe { from_glib_none(ffi::gsk_repeat_node_get_child(self.to_glib_none().0)) }
64    }
65
66    /// Retrieves the bounding rectangle of the child of @self.
67    ///
68    /// # Returns
69    ///
70    /// a bounding rectangle
71    #[doc(alias = "gsk_repeat_node_get_child_bounds")]
72    #[doc(alias = "get_child_bounds")]
73    pub fn child_bounds(&self) -> graphene::Rect {
74        unsafe { from_glib_none(ffi::gsk_repeat_node_get_child_bounds(self.to_glib_none().0)) }
75    }
76}