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    /// Gets one of the children of @container.
15    /// ## `idx`
16    /// the position of the child to get
17    ///
18    /// # Returns
19    ///
20    /// the @idx'th child of @container
21    #[doc(alias = "gsk_container_node_get_child")]
22    #[doc(alias = "get_child")]
23    pub fn child(&self, idx: u32) -> RenderNode {
24        assert!(idx < self.n_children());
25        unsafe {
26            from_glib_none(ffi::gsk_container_node_get_child(
27                self.to_glib_none().0,
28                idx,
29            ))
30        }
31    }
32}
33
34impl std::fmt::Debug for ContainerNode {
35    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
36        f.debug_struct("ContainerNode")
37            .field("n_children", &self.n_children())
38            .finish()
39    }
40}