Skip to main content

gsk4/
repeat_node.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use crate::{RenderNodeType, RepeatNode};
4
5define_render_node!(
6    RepeatNode,
7    crate::ffi::GskRepeatNode,
8    RenderNodeType::RepeatNode
9);
10
11impl RepeatNode {
12    /// Retrieves the snap value for the child's bounding
13    /// rectangle.
14    ///
15    /// # Returns
16    ///
17    /// the snap value
18    #[cfg(feature = "v4_24")]
19    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
20    #[doc(alias = "gsk_repeat_node_get_child_snap")]
21    #[doc(alias = "get_child_snap")]
22    pub fn child_snap(&self) -> crate::RectSnap {
23        unsafe {
24            glib::translate::from_glib(crate::ffi::gsk_repeat_node_get_child_snap(
25                glib::translate::ToGlibPtr::to_glib_none(self).0,
26            ))
27        }
28    }
29
30    /// Retrieves the snap value for this node
31    ///
32    /// # Returns
33    ///
34    /// the snap value
35    #[cfg(feature = "v4_24")]
36    #[cfg_attr(docsrs, doc(cfg(feature = "v4_24")))]
37    #[doc(alias = "gsk_repeat_node_get_snap")]
38    #[doc(alias = "get_snap")]
39    pub fn snap(&self) -> crate::RectSnap {
40        unsafe {
41            glib::translate::from_glib(crate::ffi::gsk_repeat_node_get_snap(
42                glib::translate::ToGlibPtr::to_glib_none(self).0,
43            ))
44        }
45    }
46}
47
48impl std::fmt::Debug for RepeatNode {
49    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
50        f.debug_struct("RepeatNode")
51            .field("child_bounds", &self.child_bounds())
52            .field("child", &self.child())
53            .finish()
54    }
55}