gsk4/
container_node.rs

1// Take a look at the license at the top of the repository in the LICENSE file.
2
3use glib::translate::*;
4
5use crate::{ffi, ContainerNode, RenderNode, RenderNodeType};
6
7define_render_node!(
8    ContainerNode,
9    ffi::GskContainerNode,
10    RenderNodeType::ContainerNode
11);
12
13impl ContainerNode {
14    #[doc(alias = "gsk_container_node_get_child")]
15    #[doc(alias = "get_child")]
16    pub fn child(&self, idx: u32) -> RenderNode {
17        assert!(idx < self.n_children());
18        unsafe {
19            from_glib_none(ffi::gsk_container_node_get_child(
20                self.to_glib_none().0,
21                idx,
22            ))
23        }
24    }
25}
26
27impl std::fmt::Debug for ContainerNode {
28    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
29        f.debug_struct("ContainerNode")
30            .field("n_children", &self.n_children())
31            .finish()
32    }
33}