iced_accessibility/
node.rs

1use crate::A11yId;
2
3#[derive(Debug, Clone, PartialEq)]
4pub struct A11yNode {
5    node: accesskit::NodeBuilder,
6    id: A11yId,
7}
8
9impl A11yNode {
10    pub fn new<T: Into<A11yId>>(node: accesskit::NodeBuilder, id: T) -> Self {
11        Self {
12            node,
13            id: id.into(),
14        }
15    }
16
17    pub fn id(&self) -> &A11yId {
18        &self.id
19    }
20
21    pub fn node_mut(&mut self) -> &mut accesskit::NodeBuilder {
22        &mut self.node
23    }
24
25    pub fn node(&self) -> &accesskit::NodeBuilder {
26        &self.node
27    }
28
29    pub fn add_children(&mut self, children: Vec<A11yId>) {
30        let mut children =
31            children.into_iter().map(|id| id.into()).collect::<Vec<_>>();
32        children.extend_from_slice(self.node.children());
33        self.node.set_children(children);
34    }
35}
36
37impl From<A11yNode> for (accesskit::NodeId, accesskit::Node) {
38    fn from(node: A11yNode) -> Self {
39        (node.id.into(), node.node.build())
40    }
41}