clay_layout/
id.rs

1use crate::bindings::*;
2
3#[derive(Debug, Copy, Clone)]
4pub struct Id {
5    pub id: Clay_ElementId,
6}
7
8impl Id {
9    /// Creates a clay id using the `label`
10    #[inline]
11    pub(crate) fn new(label: &str) -> Id {
12        Self::new_index(label, 0)
13    }
14
15    /// Creates a clay id using the `label` and the `index`
16    #[inline]
17    pub(crate) fn new_index(label: &str, index: u32) -> Id {
18        Self::new_index_internal(label, index)
19    }
20
21    #[inline]
22    pub(crate) fn new_index_internal(label: &str, index: u32) -> Id {
23        let id = unsafe { Clay__HashString(label.into(), index, 0) };
24        Id { id }
25    }
26
27    #[inline]
28    pub(crate) fn new_index_local(label: &str, index: u32) -> Id {
29        let id = unsafe { Clay__HashString(label.into(), index, Clay__GetParentElementId()) };
30        Id { id }
31    }
32}